hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [2/2] hbase git commit: HBASE-13179 TestMasterObserver deleteTable is flaky
Date Mon, 09 Mar 2015 20:06:08 GMT
HBASE-13179 TestMasterObserver deleteTable is flaky


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5197640c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5197640c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5197640c

Branch: refs/heads/branch-1
Commit: 5197640c3095c2a0d4ca0b78361fa5645f54a0e2
Parents: f7c35f8
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Mon Mar 9 19:47:27 2015 +0000
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Mon Mar 9 19:47:53 2015 +0000

----------------------------------------------------------------------
 .../hbase/coprocessor/TestMasterObserver.java   | 23 +++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5197640c/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
index 7b0594c..c85ba83 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
@@ -75,6 +75,7 @@ public class TestMasterObserver {
   private static final Log LOG = LogFactory.getLog(TestMasterObserver.class);
 
   public static CountDownLatch tableCreationLatch = new CountDownLatch(1);
+  public static CountDownLatch tableDeletionLatch = new CountDownLatch(1);
 
   public static class CPMasterObserver implements MasterObserver {
 
@@ -854,6 +855,7 @@ public class TestMasterObserver {
         ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName)
         throws IOException {
       postDeleteTableHandlerCalled = true;
+      tableDeletionLatch.countDown();
     }
 
     public boolean wasDeleteTableHandlerCalled() {
@@ -1212,7 +1214,7 @@ public class TestMasterObserver {
     // delete table
     admin.disableTable(tableName);
     assertTrue(admin.isTableDisabled(tableName));
-    admin.deleteTable(tableName);
+    deleteTable(admin, tableName);
     assertFalse("Test table should have been deleted",
         admin.tableExists(tableName));
     // preDeleteTable can't bypass default action.
@@ -1295,7 +1297,7 @@ public class TestMasterObserver {
     assertFalse("No table deleted yet", cp.wasDeleteTableCalled());
     assertFalse("Delete table handler should not be called.",
         cp.wasDeleteTableHandlerCalled());
-    admin.deleteTable(tableName);
+    deleteTable(admin, tableName);
     assertFalse("Test table should have been deleted",
         admin.tableExists(tableName));
     assertTrue("Coprocessor should have been called on table delete",
@@ -1343,7 +1345,7 @@ public class TestMasterObserver {
         cp.wasRestoreSnapshotCalled());
       admin.disableTable(TEST_CLONE);
       assertTrue(admin.isTableDisabled(tableName));
-      admin.deleteTable(TEST_CLONE);
+      deleteTable(admin, TEST_CLONE);
 
       // Test restore operation
       cp.resetStates();
@@ -1357,7 +1359,7 @@ public class TestMasterObserver {
       assertTrue("Coprocessor should have been called on snapshot delete",
         cp.wasDeleteSnapshotCalled());
     } finally {
-      admin.deleteTable(tableName);
+      deleteTable(admin, tableName);
     }
   }
 
@@ -1537,7 +1539,9 @@ public class TestMasterObserver {
       assertTrue("Coprocessor should be called on region rebalancing",
           cp.wasBalanceCalled());
     } finally {
-      UTIL.deleteTable(tableName);
+      Admin admin = UTIL.getHBaseAdmin();
+      admin.disableTable(tableName);
+      deleteTable(admin, tableName);
     }
   }
 
@@ -1584,4 +1588,13 @@ public class TestMasterObserver {
     assertTrue("Coprocessor should be called on table names request",
       cp.wasGetTableNamesCalled());
   }
+
+  private void deleteTable(Admin admin, TableName tableName) throws Exception {
+    // NOTE: We need a latch because admin is not sync,
+    // so the postOp coprocessor method may be called after the admin operation returned.
+    tableDeletionLatch = new CountDownLatch(1);
+    admin.deleteTable(tableName);
+    tableDeletionLatch.await();
+    tableDeletionLatch = new CountDownLatch(1);
+  }
 }


Mime
View raw message