Author: alfonsonishikawa Date: Mon Apr 15 19:20:24 2013 New Revision: 1468198
URL: http://svn.apache.org/r1468198 Log: Merge from /trunk r1466967 Added: gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/util/HBaseClusterSingleton.java - copied unchanged from r1468188, gora/trunk/gora-hbase/src/test/java/org/apache/gora/hbase/util/HBaseClusterSingleton.java Modified: gora/branches/GORA_174/ (props changed) gora/branches/GORA_174/CHANGES.txt gora/branches/GORA_174/gora-core/src/examples/java/org/apache/gora/examples/mapreduce/QueryCounter.java gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/GoraHBaseTestDriver.java gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreCountQuery.java gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreWordCount.java gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/store/TestHBaseStore.java Propchange: gora/branches/GORA_174/ ------------------------------------------------------------------------------ Merged /gora/trunk:r1458775-1468188 Modified: gora/branches/GORA_174/CHANGES.txt URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/CHANGES.txt?rev=1468198&r1=1468197&r2=1468198&view=diff ============================================================================== --- gora/branches/GORA_174/CHANGES.txt (original) +++ gora/branches/GORA_174/CHANGES.txt Mon Apr 15 19:20:24 2013 @@ -5,6 +5,9 @@ Gora Change Log trunk (current development) +* GORA-159 gora-hbase MR tests should use HBaseTestingUtility instead of deprecated HBaseClusterTestCase via GORA-89 + +* GORA-89 Avoid HBase MiniCluster restarts to shorten gora-hbase tests (hsaputra, alfonso, Ioan eugen Stan) * GORA-203 Bug in setting column field attribute "qualifier" in CassandraMapping (rmarroquin, lewismc, kazk) Modified: gora/branches/GORA_174/gora-core/src/examples/java/org/apache/gora/examples/mapreduce/QueryCounter.java URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-core/src/examples/java/org/apache/gora/examples/mapreduce/QueryCounter.java?rev=1468198&r1=1468197&r2=1468198&view=diff ============================================================================== --- gora/branches/GORA_174/gora-core/src/examples/java/org/apache/gora/examples/mapreduce/QueryCounter.java (original) +++ gora/branches/GORA_174/gora-core/src/examples/java/org/apache/gora/examples/mapreduce/QueryCounter.java Mon Apr 15 19:20:24 2013 @@ -47,8 +47,7 @@ public class QueryCounter<K, T extends P } public static class QueryCounterMapper<K, T extends Persistent> - extends GoraMapper<K, T - , NullWritable, NullWritable> { + extends GoraMapper<K, T, NullWritable, NullWritable> { @Override protected void map(K key, T value, @@ -95,6 +94,7 @@ public class QueryCounter<K, T extends P public long countQuery(DataStore<K,T> dataStore, Query<K,T> query) throws Exception { Job job = createJob(dataStore, query); job.waitForCompletion(true); + assert(job.isComplete() == true); return job.getCounters().findCounter(COUNTER_GROUP, ROWS).getValue(); } @@ -108,6 +108,7 @@ public class QueryCounter<K, T extends P Job job = createJob(dataStore, query); job.waitForCompletion(true); + assert(job.isComplete() == true); return job.getCounters().findCounter(COUNTER_GROUP, ROWS).getValue(); } Modified: gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/GoraHBaseTestDriver.java URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/GoraHBaseTestDriver.java?rev=1468198&r1=1468197&r2=1468198&view=diff ============================================================================== --- gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/GoraHBaseTestDriver.java (original) +++ gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/GoraHBaseTestDriver.java Mon Apr 15 19:20:24 2013 @@ -20,6 +20,7 @@ package org.apache.gora.hbase; import org.apache.gora.GoraTestDriver; import org.apache.gora.hbase.store.HBaseStore; +import org.apache.gora.hbase.util.HBaseClusterSingleton; import org.apache.hadoop.conf.Configuration; //HBase imports @@ -32,56 +33,45 @@ import org.apache.hadoop.hbase.client.HB * @see GoraTestDriver */ public class GoraHBaseTestDriver extends GoraTestDriver { + private static final HBaseClusterSingleton cluster = HBaseClusterSingleton.build(1); - protected HBaseTestingUtility hbaseUtil; - protected int numServers = 1; - public GoraHBaseTestDriver() { super(HBaseStore.class); - hbaseUtil = new HBaseTestingUtility(); - } - - public void setNumServers(int numServers) { - this.numServers = numServers; - } - - public int getNumServers() { - return numServers; } @Override public void setUpClass() throws Exception { super.setUpClass(); - log.info("Starting HBase cluster"); - hbaseUtil.startMiniCluster(numServers); + log.info("Setting up HBase Test Driver"); } @Override public void tearDownClass() throws Exception { super.tearDownClass(); - log.info("Stoping HBase cluster"); - hbaseUtil.shutdownMiniCluster(); + log.info("Teardown HBase test driver"); } @Override public void setUp() throws Exception { - super.setUp(); + cluster.truncateAllTables(); + // super.setUp() deletes all tables, but must only truncate in the right way -HBaseClusterSingleton- + //super.setUp(); } + @Override + public void tearDown() throws Exception { + // Do nothing. setUp() must ensure the right data. + } public void deleteAllTables() throws Exception { - HBaseAdmin admin = hbaseUtil.getHBaseAdmin(); - for(HTableDescriptor table:admin.listTables()) { - admin.disableTable(table.getName()); - admin.deleteTable(table.getName()); - } + cluster.deleteAllTables(); } public Configuration getConf() { - return hbaseUtil.getConfiguration(); + return cluster.getHbaseTestingUtil().getConfiguration(); } public HBaseTestingUtility getHbaseUtil() { - return hbaseUtil; + return cluster.getHbaseTestingUtil(); } } Modified: gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreCountQuery.java URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreCountQuery.java?rev=1468198&r1=1468197&r2=1468198&view=diff ============================================================================== --- gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreCountQuery.java (original) +++ gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreCountQuery.java Mon Apr 15 19:20:24 2013 @@ -21,9 +21,10 @@ package org.apache.gora.hbase.mapreduce; import org.apache.gora.examples.generated.TokenDatum; import org.apache.gora.examples.generated.WebPage; import org.apache.gora.hbase.store.HBaseStore; +import org.apache.gora.hbase.util.HBaseClusterSingleton; import org.apache.gora.mapreduce.MapReduceTestUtils; import org.apache.gora.store.DataStoreFactory; -import org.apache.hadoop.hbase.HBaseClusterTestCase; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -31,28 +32,26 @@ import org.junit.Test; /** * Tests related to {@link HBaseStore} using mapreduce. */ -public class TestHBaseStoreCountQuery extends HBaseClusterTestCase{ +public class TestHBaseStoreCountQuery { + private static final HBaseClusterSingleton cluster = HBaseClusterSingleton.build(1); private HBaseStore<String, WebPage> webPageStore; - + @Before - @Override public void setUp() throws Exception { - super.setUp(); + cluster.deleteAllTables(); webPageStore = DataStoreFactory.getDataStore( - HBaseStore.class, String.class, WebPage.class, conf); + HBaseStore.class, String.class, WebPage.class, cluster.getConf()); } @After - @Override public void tearDown() throws Exception { webPageStore.close(); - super.tearDown(); } @Test public void testCountQuery() throws Exception { - MapReduceTestUtils.testCountQuery(webPageStore, conf); + MapReduceTestUtils.testCountQuery(webPageStore, cluster.getConf()); } public static void main(String[] args) throws Exception { Modified: gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreWordCount.java URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreWordCount.java?rev=1468198&r1=1468197&r2=1468198&view=diff ============================================================================== --- gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreWordCount.java (original) +++ gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/mapreduce/TestHBaseStoreWordCount.java Mon Apr 15 19:20:24 2013 @@ -21,9 +21,10 @@ package org.apache.gora.hbase.mapreduce; import org.apache.gora.examples.generated.TokenDatum; import org.apache.gora.examples.generated.WebPage; import org.apache.gora.hbase.store.HBaseStore; +import org.apache.gora.hbase.util.HBaseClusterSingleton; import org.apache.gora.mapreduce.MapReduceTestUtils; import org.apache.gora.store.DataStoreFactory; -import org.apache.hadoop.hbase.HBaseClusterTestCase; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -31,32 +32,30 @@ import org.junit.Test; /** * Tests related to {@link org.apache.gora.hbase.store.HBaseStore} using mapreduce. */ -public class TestHBaseStoreWordCount extends HBaseClusterTestCase{ +public class TestHBaseStoreWordCount { + private static final HBaseClusterSingleton cluster = HBaseClusterSingleton.build(1); private HBaseStore<String, WebPage> webPageStore; private HBaseStore<String, TokenDatum> tokenStore; @Before - @Override public void setUp() throws Exception { - super.setUp(); + cluster.deleteAllTables(); webPageStore = DataStoreFactory.getDataStore( - HBaseStore.class, String.class, WebPage.class, conf); + HBaseStore.class, String.class, WebPage.class, cluster.getConf()); tokenStore = DataStoreFactory.getDataStore(HBaseStore.class, - String.class, TokenDatum.class, conf); + String.class, TokenDatum.class, cluster.getConf()); } @After - @Override public void tearDown() throws Exception { webPageStore.close(); tokenStore.close(); - super.tearDown(); } @Test public void testWordCount() throws Exception { - MapReduceTestUtils.testWordCount(conf, webPageStore, tokenStore); + MapReduceTestUtils.testWordCount(cluster.getConf(), webPageStore, tokenStore); } public static void main(String[] args) throws Exception { Modified: gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/store/TestHBaseStore.java URL: http://svn.apache.org/viewvc/gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/store/TestHBaseStore.java?rev=1468198&r1=1468197&r2=1468198&view=diff ============================================================================== --- gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/store/TestHBaseStore.java (original) +++ gora/branches/GORA_174/gora-hbase/src/test/java/org/apache/gora/hbase/store/TestHBaseStore.java Mon Apr 15 19:20:24 2013 @@ -26,7 +26,6 @@ import junit.framework.Assert; import org.apache.gora.examples.generated.Employee; import org.apache.gora.examples.generated.WebPage; import org.apache.gora.hbase.GoraHBaseTestDriver; -import org.apache.gora.hbase.store.HBaseStore; import org.apache.gora.store.DataStore; import org.apache.gora.store.DataStoreFactory; import org.apache.gora.store.DataStoreTestBase; @@ -127,31 +126,31 @@ public class TestHBaseStore extends Data } - @Override - public void testQueryEndKey() throws IOException { - //We need to skip this test since gora considers endRow inclusive, while its exclusinve for HBase. - //TODO: We should raise an issue for HBase to allow us to specify if the endRow will be inclussive or exclusive. - } - - @Override - public void testQueryKeyRange() throws IOException { - //We need to skip this test since gora considers endRow inclusive, while its exclusinve for HBase. - //TODO: We should raise an issue for HBase to allow us to specify if the endRow will be inclussive or exclusive. - } - - @Override - public void testDeleteByQuery() throws IOException { - //We need to skip this test since gora considers endRow inclusive, while its exclusinve for HBase. - //TODO: We should raise an issue for HBase to allow us to specify if the endRow will be inclussive or exclusive. - } + @Override + public void testQueryEndKey() throws IOException { + //We need to skip this test since gora considers endRow inclusive, while its exclusinve for HBase. + //TODO: We should raise an issue for HBase to allow us to specify if the endRow will be inclussive or exclusive. + } + + @Override + public void testQueryKeyRange() throws IOException { + //We need to skip this test since gora considers endRow inclusive, while its exclusinve for HBase. + //TODO: We should raise an issue for HBase to allow us to specify if the endRow will be inclussive or exclusive. + } + + @Override + public void testDeleteByQuery() throws IOException { + //We need to skip this test since gora considers endRow inclusive, while its exclusinve for HBase. + //TODO: We should raise an issue for HBase to allow us to specify if the endRow will be inclussive or exclusive. + } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception { TestHBaseStore test = new TestHBaseStore(); test.setUpClass(); test.setUp(); - + test.testQuery(); - + test.tearDown(); test.tearDownClass(); }
