From a3f588b26f00115e48b6bf87573e2c2bc4c09be8 Mon Sep 17 00:00:00 2001 From: stack Date: Wed, 14 Oct 2015 23:02:17 -0700 Subject: [PATCH] HBASE-14608 testWalRollOnLowReplication has some risk to assert failed after HBASE-14600 (Heng Chen) --- .../TestWALProcedureStoreOnHDFS.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java index 25af47cff9d..1d7dc8391c3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestWALProcedureStoreOnHDFS.java @@ -71,6 +71,17 @@ public class TestWALProcedureStoreOnHDFS { private WALProcedureStore store; + private ProcedureStore.ProcedureStoreListener stopProcedureListener = new ProcedureStore.ProcedureStoreListener() { + @Override + public void postSync() {} + + @Override + public void abortProcess() { + LOG.fatal("Abort the Procedure Store"); + store.stop(true); + } + }; + private static void setupConf(Configuration conf) { conf.setInt("dfs.replication", 3); conf.setInt("dfs.namenode.replication.min", 3); @@ -89,16 +100,7 @@ public class TestWALProcedureStoreOnHDFS { Path logDir = new Path(new Path(dfs.getFileSystem().getUri()), "/test-logs"); store = ProcedureTestingUtility.createWalStore( UTIL.getConfiguration(), dfs.getFileSystem(), logDir); - store.registerListener(new ProcedureStore.ProcedureStoreListener() { - @Override - public void postSync() {} - - @Override - public void abortProcess() { - LOG.fatal("Abort the Procedure Store"); - store.stop(true); - } - }); + store.registerListener(stopProcedureListener); store.start(8); store.recoverLease(); } @@ -136,7 +138,6 @@ public class TestWALProcedureStoreOnHDFS { @Test(timeout=60000) public void testWalAbortOnLowReplicationWithQueuedWriters() throws Exception { assertEquals(3, UTIL.getDFSCluster().getDataNodes().size()); - store.registerListener(new ProcedureStore.ProcedureStoreListener() { @Override public void postSync() { @@ -182,6 +183,15 @@ public class TestWALProcedureStoreOnHDFS { @Test(timeout=60000) public void testWalRollOnLowReplication() throws Exception { + store.unregisterListener(stopProcedureListener); + store.registerListener(new ProcedureStore.ProcedureStoreListener() { + @Override + public void postSync() {} + + @Override + public void abortProcess() { + } + }); int dnCount = 0; store.insert(new TestProcedure(1, -1), null); UTIL.getDFSCluster().restartDataNode(dnCount);