hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1373521 - in /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase: HBaseTestingUtility.java coprocessor/TestClassLoading.java
Date Wed, 15 Aug 2012 16:34:46 GMT
Author: apurtell
Date: Wed Aug 15 16:34:45 2012
New Revision: 1373521

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

Modified:
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1373521&r1=1373520&r2=1373521&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Wed
Aug 15 16:34:45 2012
@@ -1522,8 +1522,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/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java?rev=1373521&r1=1373520&r2=1373521&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
Wed Aug 15 16:34:45 2012
@@ -234,7 +234,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,
@@ -277,7 +277,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;
@@ -303,7 +303,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;
@@ -369,7 +369,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,
@@ -472,7 +472,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,
@@ -544,7 +544,7 @@ 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));
@@ -564,7 +564,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));
 
@@ -659,6 +659,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();



Mime
View raw message