You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2011/04/28 00:41:18 UTC

svn commit: r1097265 - /hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java

Author: jdcryans
Date: Wed Apr 27 22:41:17 2011
New Revision: 1097265

URL: http://svn.apache.org/viewvc?rev=1097265&view=rev
Log:
Committing a fix for TestZKBasedOpenCloseRegion for HBASE-3741 since I
found a race where not all regions where assigned when the test starts

Modified:
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java?rev=1097265&r1=1097264&r2=1097265&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java Wed Apr 27 22:41:17 2011
@@ -60,6 +60,7 @@ public class TestZKBasedOpenCloseRegion 
   private static final String TABLENAME = "TestZKBasedOpenCloseRegion";
   private static final byte [][] FAMILIES = new byte [][] {Bytes.toBytes("a"),
     Bytes.toBytes("b"), Bytes.toBytes("c")};
+  private static int countOfRegions;
 
   @BeforeClass public static void beforeAllTests() throws Exception {
     Configuration c = TEST_UTIL.getConfiguration();
@@ -68,8 +69,8 @@ public class TestZKBasedOpenCloseRegion 
     TEST_UTIL.startMiniCluster(2);
     TEST_UTIL.createTable(Bytes.toBytes(TABLENAME), FAMILIES);
     HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
-    int countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
-    waitUntilAllRegionsAssigned(countOfRegions);
+    countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
+    waitUntilAllRegionsAssigned();
     addToEachStartKey(countOfRegions);
   }
 
@@ -84,6 +85,7 @@ public class TestZKBasedOpenCloseRegion 
         TEST_UTIL.getHBaseCluster().startRegionServer());
 
     }
+    waitUntilAllRegionsAssigned();
   }
 
   /**
@@ -298,7 +300,7 @@ public class TestZKBasedOpenCloseRegion 
 
   }
 
-  private static void waitUntilAllRegionsAssigned(final int countOfRegions)
+  private static void waitUntilAllRegionsAssigned()
   throws IOException {
     HTable meta = new HTable(TEST_UTIL.getConfiguration(),
       HConstants.META_TABLE_NAME);
@@ -317,7 +319,7 @@ public class TestZKBasedOpenCloseRegion 
       }
       s.close();
       // If I get to here and all rows have a Server, then all have been assigned.
-      if (rows == countOfRegions) {
+      if (rows >= countOfRegions) {
         break;
       }
       LOG.info("Found=" + rows);