HBASE-14650  Reenable TestNamespaceAuditor (Heng Chen)

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

Branch: refs/heads/hbase-12439
Commit: 84f4cceb485379d080ec9fb000c9ce5a77638d89
Parents: bdf11be
Author: stack <st...@apache.org>
Authored: Thu Oct 29 21:44:23 2015 -0700
Committer: stack <st...@apache.org>
Committed: Thu Oct 29 21:44:23 2015 -0700

----------------------------------------------------------------------
 .../hbase/namespace/TestNamespaceAuditor.java   | 27 ++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/84f4cceb/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
index 41a9713..764cf13 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
@@ -77,6 +77,8 @@ import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.regionserver.Region;
 import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.Store;
+import org.apache.hadoop.hbase.regionserver.StoreFile;
 import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -85,7 +87,6 @@ import org.apache.zookeeper.KeeperException;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -135,7 +136,7 @@ public class TestNamespaceAuditor {
       }
     }
     assertTrue("Quota manager not enabled", UTIL.getHBaseCluster().getMaster()
-      .getMasterQuotaManager().isQuotaEnabled());
+        .getMasterQuotaManager().isQuotaEnabled());
   }
 
   @Test
@@ -425,7 +426,7 @@ public class TestNamespaceAuditor {
     assertEquals(initialRegions, ADMIN.getTableRegions(tableTwo).size());
   }
 
-  @Ignore("Hangs on occasion waiting on countdown latch") @Test
+  @Test
   public void testRegionOperations() throws Exception {
     String nsp1 = prefix + "_regiontest";
     NamespaceDescriptor nspDesc = NamespaceDescriptor.create(nsp1)
@@ -458,17 +459,24 @@ public class TestNamespaceAuditor {
     assertEquals(1, stateInfo.getTables().size());
     assertEquals(1, stateInfo.getRegionCount());
     restartMaster();
-    ADMIN.split(tableOne, Bytes.toBytes("500"));
+
     HRegion actualRegion = UTIL.getHBaseCluster().getRegions(tableOne).get(0);
     CustomObserver observer = (CustomObserver) 
actualRegion.getCoprocessorHost().findCoprocessor(
-      CustomObserver.class.getName());
+        CustomObserver.class.getName());
     assertNotNull(observer);
+
+    ADMIN.split(tableOne, Bytes.toBytes("500"));
     observer.postSplit.await();
     assertEquals(2, ADMIN.getTableRegions(tableOne).size());
     actualRegion = UTIL.getHBaseCluster().getRegions(tableOne).get(0);
     observer = (CustomObserver) 
actualRegion.getCoprocessorHost().findCoprocessor(
       CustomObserver.class.getName());
     assertNotNull(observer);
+
+    //Before we go on split, we should remove all reference store files.
+    ADMIN.compact(tableOne);
+    observer.postCompact.await();
+
     ADMIN.split(tableOne, 
getSplitKey(actualRegion.getRegionInfo().getStartKey(),
       actualRegion.getRegionInfo().getEndKey()));
     observer.postSplit.await();
@@ -551,6 +559,7 @@ public class TestNamespaceAuditor {
   public static class CustomObserver extends BaseRegionObserver{
     volatile CountDownLatch postSplit;
     volatile CountDownLatch preSplitBeforePONR;
+    volatile CountDownLatch postCompact;
 
     @Override
     public void 
postCompleteSplit(ObserverContext<RegionCoprocessorEnvironment> ctx)
@@ -559,15 +568,23 @@ public class TestNamespaceAuditor {
     }
 
     @Override
+    public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e,
+                            Store store, StoreFile resultFile) throws 
IOException {
+      postCompact.countDown();
+    }
+
+    @Override
     public void 
preSplitBeforePONR(ObserverContext<RegionCoprocessorEnvironment> ctx,
         byte[] splitKey, List<Mutation> metaEntries) throws IOException {
       preSplitBeforePONR.countDown();
     }
 
+
     @Override
     public void start(CoprocessorEnvironment e) throws IOException {
       postSplit = new CountDownLatch(1);
       preSplitBeforePONR = new CountDownLatch(1);
+      postCompact = new CountDownLatch(1);
     }
   }
 

Reply via email to