hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1415005 - /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
Date Thu, 29 Nov 2012 00:12:58 GMT
Author: enis
Date: Thu Nov 29 00:12:57 2012
New Revision: 1415005

URL: http://svn.apache.org/viewvc?rev=1415005&view=rev
Log:
HBASE-7235 TestMasterObserver is flaky

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

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java?rev=1415005&r1=1415004&r2=1415005&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
Thu Nov 29 00:12:57 2012
@@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Threads;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -796,7 +797,7 @@ public class TestMasterObserver {
 
     // modify table
     htd.setMaxFileSize(512 * 1024 * 1024);
-    admin.modifyTable(TEST_TABLE, htd);
+    modifyTableSync(admin, TEST_TABLE, htd);
     // preModifyTable can't bypass default action.
     assertTrue("Test table should have been modified",
       cp.wasModifyTableCalled());
@@ -847,7 +848,7 @@ public class TestMasterObserver {
 
     // modify table
     htd.setMaxFileSize(512 * 1024 * 1024);
-    admin.modifyTable(TEST_TABLE, htd);
+    modifyTableSync(admin, TEST_TABLE, htd);
     assertTrue("Test table should have been modified",
         cp.wasModifyTableCalled());
     // add a column family
@@ -906,6 +907,19 @@ public class TestMasterObserver {
         cp.wasDeleteTableHandlerCalled());
   }
 
+  private void modifyTableSync(HBaseAdmin admin, byte[] tableName, HTableDescriptor htd)
+      throws IOException {
+    admin.modifyTable(tableName, htd);
+    //wait until modify table finishes
+    for (int t = 0; t < 100; t++) { //10 sec timeout
+      HTableDescriptor td = admin.getTableDescriptor(htd.getName());
+      if (td.equals(htd)) {
+        break;
+      }
+      Threads.sleep(100);
+    }
+  }
+
   @Test
   public void testRegionTransitionOperations() throws Exception {
     MiniHBaseCluster cluster = UTIL.getHBaseCluster();



Mime
View raw message