You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2012/08/15 18:33:40 UTC

svn commit: r1373520 - in /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase: HBaseTestingUtility.java coprocessor/TestClassLoading.java

Author: apurtell
Date: Wed Aug 15 16:33:40 2012
New Revision: 1373520

URL: http://svn.apache.org/viewvc?rev=1373520&view=rev
Log:
HBASE-6478. TestClassLoading.testClassLoadingFromLibDirInJar occasionally fails

Modified:
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1373520&r1=1373519&r2=1373520&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Wed Aug 15 16:33:40 2012
@@ -1652,8 +1652,21 @@ public class HBaseTestingUtility {
   throws InterruptedException, IOException {
     long startWait = System.currentTimeMillis();
     while (!getHBaseAdmin().isTableAvailable(table)) {
-      assertTrue("Timed out waiting for table " + Bytes.toStringBinary(table),
-          System.currentTimeMillis() - startWait < timeoutMillis);
+      assertTrue("Timed out waiting for table to become available " +
+        Bytes.toStringBinary(table),
+        System.currentTimeMillis() - startWait < timeoutMillis);
+      Thread.sleep(200);
+    }
+  }
+
+  public void waitTableEnabled(byte[] table, long timeoutMillis)
+  throws InterruptedException, IOException {
+    long startWait = System.currentTimeMillis();
+    while (!getHBaseAdmin().isTableAvailable(table) &&
+           !getHBaseAdmin().isTableEnabled(table)) {
+      assertTrue("Timed out waiting for table to become available and enabled " +
+         Bytes.toStringBinary(table),
+         System.currentTimeMillis() - startWait < timeoutMillis);
       Thread.sleep(200);
     }
   }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java?rev=1373520&r1=1373519&r2=1373520&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java Wed Aug 15 16:33:40 2012
@@ -240,7 +240,7 @@ public class TestClassLoading {
       admin.deleteTable(tableName);
     }
     admin.createTable(htd);
-    TEST_UTIL.waitTableAvailable(htd.getName(), 5000);
+    waitForTable(htd.getName());
 
     // verify that the coprocessors were loaded
     boolean found1 = false, found2 = false, found2_k1 = false,
@@ -283,7 +283,7 @@ public class TestClassLoading {
       Coprocessor.PRIORITY_USER);
     HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
     admin.createTable(htd);
-    TEST_UTIL.waitTableAvailable(htd.getName(), 5000);
+    waitForTable(htd.getName());
 
     // verify that the coprocessor was loaded
     boolean found = false;
@@ -309,7 +309,7 @@ public class TestClassLoading {
       Coprocessor.PRIORITY_USER);
     HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
     admin.createTable(htd);
-    TEST_UTIL.waitTableAvailable(htd.getName(), 5000);
+    waitForTable(htd.getName());
 
     // verify that the coprocessor was loaded correctly
     boolean found = false;
@@ -377,7 +377,7 @@ public class TestClassLoading {
       admin.deleteTable(tableName);
     }
     admin.createTable(htd);
-    TEST_UTIL.waitTableAvailable(htd.getName(), 5000);
+    waitForTable(htd.getName());
 
     // verify that the coprocessor was loaded
     boolean found_2 = false, found_1 = false, found_3 = false,
@@ -482,7 +482,7 @@ public class TestClassLoading {
       admin.deleteTable(tableName);
     }
     admin.createTable(htd);
-    TEST_UTIL.waitTableAvailable(htd.getName(), 5000);
+    waitForTable(htd.getName());
 
     // verify that the coprocessors were loaded
     boolean found1 = false, found2 = false, found2_k1 = false,
@@ -554,7 +554,8 @@ public class TestClassLoading {
     String userTable1 = "userTable1";
     HTableDescriptor userTD1 = new HTableDescriptor(userTable1);
     admin.createTable(userTD1);
-    TEST_UTIL.waitTableAvailable(userTD1.getName(), 5000);
+    waitForTable(userTD1.getName());
+
     // table should be enabled now.
     assertTrue(admin.isTableEnabled(userTable1));
     assertAllRegionServers(regionServerSystemAndUserCoprocessors, userTable1);
@@ -573,7 +574,7 @@ public class TestClassLoading {
     htd2.setValue("COPROCESSOR$1", jarFile1.toString() + "|" + userTableCP +
       "|" + Coprocessor.PRIORITY_USER);
     admin.createTable(htd2);
-    TEST_UTIL.waitTableAvailable(htd2.getName(), 5000);
+    waitForTable(htd2.getName());
     // table should be enabled now.
     assertTrue(admin.isTableEnabled(userTable2));
 
@@ -668,6 +669,13 @@ public class TestClassLoading {
     assertEquals(loadedMasterCoprocessorsVerify, loadedMasterCoprocessors);
   }
 
+  private void waitForTable(byte[] name) throws InterruptedException, IOException {
+    // First wait until all regions are online
+    TEST_UTIL.waitTableEnabled(name, 5000);
+    // Now wait a bit longer for the coprocessor hosts to load the CPs
+    Thread.sleep(1000);
+  }
+
   @org.junit.Rule
   public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
     new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();