From 5b665ad594910ee02f50c6a2929d1b666ea2e9b9 Mon Sep 17 00:00:00 2001 From: larsh Date: Thu, 31 Jan 2013 19:24:48 +0000 Subject: [PATCH] HBASE-7717 addendum, really wait for all tables in TestSplitTransactionOnCluster. git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1441150 13f79535-47bb-0310-9956-ffa450edef68 --- .../TestSplitTransactionOnCluster.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java index 8e63561d70c..d7c34406930 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java @@ -127,8 +127,7 @@ public class TestSplitTransactionOnCluster { HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration()); try { // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, Bytes.toBytes("cf")); - + HTable t = createTableAndWait(tableName, Bytes.toBytes("cf")); final List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName()); @@ -217,8 +216,7 @@ public class TestSplitTransactionOnCluster { Bytes.toBytes("ephemeral"); // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); - + HTable t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); @@ -288,8 +286,7 @@ public class TestSplitTransactionOnCluster { Bytes.toBytes("testExistingZnodeBlocksSplitAndWeRollback"); // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); - + HTable t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); @@ -347,8 +344,7 @@ public class TestSplitTransactionOnCluster { final byte [] tableName = Bytes.toBytes("testShutdownSimpleFixup"); // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); - + HTable t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); @@ -400,8 +396,7 @@ public class TestSplitTransactionOnCluster { Bytes.toBytes("testShutdownFixupWhenDaughterHasSplit"); // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); - + HTable t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); @@ -477,8 +472,7 @@ public class TestSplitTransactionOnCluster { final byte[] tableName = Bytes.toBytes("testMasterRestartWhenSplittingIsPartial"); // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); - + HTable t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); @@ -551,8 +545,7 @@ public class TestSplitTransactionOnCluster { final byte[] tableName = Bytes.toBytes("testMasterRestartAtRegionSplitPendingCatalogJanitor"); // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); - + HTable t = createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); @@ -636,8 +629,7 @@ public class TestSplitTransactionOnCluster { HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration()); try { // Create table then get the single region for our new table. - HTable t = TESTING_UTIL.createTable(tableName, Bytes.toBytes("cf")); - + HTable t = createTableAndWait(tableName, Bytes.toBytes("cf")); regions = cluster.getRegions(tableName); int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName()); regionServer = cluster.getRegionServer(regionServerIndex); @@ -689,7 +681,7 @@ public class TestSplitTransactionOnCluster { throws Exception { final byte[] tableName = Bytes.toBytes("testRollBackShudBeSuccessfulIfStoreFileIsEmpty"); // Create table then get the single region for our new table. - TESTING_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY); + createTableAndWait(tableName, HConstants.CATALOG_FAMILY); List regions = cluster.getRegions(tableName); HRegionInfo hri = getAndCheckSingleTableRegion(regions); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); @@ -964,6 +956,17 @@ public class TestSplitTransactionOnCluster { } } + private HTable createTableAndWait(byte[] tableName, byte[] cf) throws IOException, + InterruptedException { + HTable t = TESTING_UTIL.createTable(tableName, cf); + for (int i = 0; cluster.getRegions(tableName).size() == 0 && i < 100; i++) { + Thread.sleep(100); + } + assertTrue("Table not online: " + Bytes.toString(tableName), cluster.getRegions(tableName) + .size() != 0); + return t; + } + public static class MockMasterWithoutCatalogJanitor extends HMaster { public MockMasterWithoutCatalogJanitor(Configuration conf) throws IOException, KeeperException,