Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 91a13438c -> 39ac60156
Prevent IndexLoadBalancerIT from hanging Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/39ac6015 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/39ac6015 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/39ac6015 Branch: refs/heads/4.x-HBase-0.98 Commit: 39ac60156aa6bc591461f1ef458f47565c925776 Parents: 91a1343 Author: Samarth <[email protected]> Authored: Tue Jan 12 12:54:25 2016 -0800 Committer: Samarth <[email protected]> Committed: Tue Jan 12 12:54:25 2016 -0800 ---------------------------------------------------------------------- .../index/balancer/IndexLoadBalancerIT.java | 65 +++++++++----------- 1 file changed, 29 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/39ac6015/phoenix-core/src/it/java/org/apache/phoenix/hbase/index/balancer/IndexLoadBalancerIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/hbase/index/balancer/IndexLoadBalancerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/hbase/index/balancer/IndexLoadBalancerIT.java index d534b6a..7729d6d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/hbase/index/balancer/IndexLoadBalancerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/hbase/index/balancer/IndexLoadBalancerIT.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -52,10 +53,11 @@ import org.apache.phoenix.hbase.index.IndexTestingUtils; import org.apache.phoenix.hbase.index.Indexer; import org.apache.phoenix.hbase.index.master.IndexMasterObserver; import org.apache.phoenix.util.ConfigUtil; -import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.Timeout; @Category(NeedsOwnMiniClusterTest.class) public class IndexLoadBalancerIT { @@ -63,6 +65,9 @@ public class IndexLoadBalancerIT { private static HBaseTestingUtility UTIL = new HBaseTestingUtility(); private static HBaseAdmin admin = null; + + @Rule + public Timeout timeout = new Timeout(180, TimeUnit.SECONDS); @BeforeClass public static void setupCluster() throws Exception { @@ -81,21 +86,8 @@ public class IndexLoadBalancerIT { UTIL.startMiniCluster(NUM_RS); admin = UTIL.getHBaseAdmin(); } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - try { - if (admin != null) { - admin.disableTables(".*"); - admin.deleteTables(".*"); - admin.close(); - } - } finally { - UTIL.shutdownMiniCluster(); - } - } - - @Test(timeout = 180000) + + @Test public void testRoundRobinAssignmentDuringIndexTableCreation() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -108,8 +100,8 @@ public class IndexLoadBalancerIT { .getNameAsString()); assertTrue("User regions and index regions should colocate.", isRegionColocated); } - - @Test(timeout = 180000) + + @Test public void testColocationAfterSplit() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -161,8 +153,8 @@ public class IndexLoadBalancerIT { .getNameAsString()); assertTrue("User regions and index regions should colocate.", isRegionColocated); } - - @Test(timeout = 180000) + + @Test public void testColocationAfterRegionsMerge() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -253,8 +245,8 @@ public class IndexLoadBalancerIT { table.put(p4); admin.flush(tableName.getNameAsString()); } - - @Test(timeout = 180000) + + @Test public void testRandomAssignmentDuringIndexTableEnable() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -273,8 +265,8 @@ public class IndexLoadBalancerIT { assertTrue("User regions and index regions should colocate.", isRegionColocated); } - - @Test(timeout = 180000) + + @Test public void testBalanceCluster() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -305,10 +297,10 @@ public class IndexLoadBalancerIT { .getNameAsString()); assertTrue("User regions and index regions should colocate.", isRegionsColocated); } - - @Test(timeout = 180000) + + @Test public void testBalanceByTable() throws Exception { - ZooKeeperWatcher zkw = UTIL.getZooKeeperWatcher(UTIL); + ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL); MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); master.getConfiguration().setBoolean("hbase.master.loadbalance.bytable", true); @@ -342,10 +334,10 @@ public class IndexLoadBalancerIT { .getNameAsString()); assertTrue("User regions and index regions should colocate.", isRegionColocated); } - - @Test(timeout = 180000) + + @Test public void testRoundRobinAssignmentAfterRegionServerDown() throws Exception { - ZooKeeperWatcher zkw = UTIL.getZooKeeperWatcher(UTIL); + ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL); MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); TableName tableName = TableName.valueOf("testRoundRobinAssignmentAfterRegionServerDown"); @@ -367,10 +359,10 @@ public class IndexLoadBalancerIT { assertTrue("User regions and index regions should colocate.", isRegionColocated); } - - @Test(timeout = 180000) + + @Test public void testRetainAssignmentDuringMasterStartUp() throws Exception { - ZooKeeperWatcher zkw = UTIL.getZooKeeperWatcher(UTIL); + ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL); MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); master.getConfiguration().setBoolean("hbase.master.startup.retainassign", true); @@ -396,8 +388,8 @@ public class IndexLoadBalancerIT { assertTrue("User regions and index regions should colocate.", isRegionColocated); } - - @Test(timeout = 300000) + + @Test public void testRoundRobinAssignmentDuringMasterStartUp() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -461,7 +453,8 @@ public class IndexLoadBalancerIT { return startKeyAndLocationPairs; } - + + @Test public boolean checkForColocation(HMaster master, String tableName, String indexTableName) throws IOException, InterruptedException { List<Pair<byte[], ServerName>> uTableStartKeysAndLocations =
