From 8aa8abfcb672e4b905c487a10f1511db431f7006 Mon Sep 17 00:00:00 2001 From: Stephen Yuan Jiang Date: Wed, 18 May 2016 09:41:13 -0700 Subject: [PATCH] HBASE-15850 Localize the configuration change in testCheckTableLocks to reduce flakiness of TestHBaseFsck test suite (Stephen Yuan Jiang) --- .../hadoop/hbase/util/TestHBaseFsckOneRS.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java index 165fea601fe..57bc77ed513 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java @@ -1472,7 +1472,8 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck { TableLockManager.DEFAULT_TABLE_LOCK_EXPIRE_TIMEOUT_MS)); // let table lock expire hbck = doFsck(conf, false); - assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] {HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK}); + assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] { + HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK}); final CountDownLatch latch = new CountDownLatch(1); new Thread() { @@ -1496,24 +1497,27 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck { Threads.sleep(300); // wait some more to ensure writeLock.acquire() is called hbck = doFsck(conf, false); + // still one expired, one not-expired assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] { - HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK}); // still one expired, one not-expired + HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK}); edge.incrementTime(conf.getLong(TableLockManager.TABLE_LOCK_EXPIRE_TIMEOUT, TableLockManager.DEFAULT_TABLE_LOCK_EXPIRE_TIMEOUT_MS)); // let table lock expire hbck = doFsck(conf, false); - assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] {HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK, + assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] { + HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK, HBaseFsck.ErrorReporter.ERROR_CODE.EXPIRED_TABLE_LOCK}); // both are expired - conf.setLong(TableLockManager.TABLE_LOCK_EXPIRE_TIMEOUT, 1); + Configuration localConf = new Configuration(conf); // reaping from ZKInterProcessWriteLock uses znode cTime, // which is not injectable through EnvironmentEdge + localConf.setLong(TableLockManager.TABLE_LOCK_EXPIRE_TIMEOUT, 1); Threads.sleep(10); - hbck = doFsck(conf, true); // now fix both cases + hbck = doFsck(localConf, true); // now fix both cases - hbck = doFsck(conf, false); + hbck = doFsck(localConf, false); assertNoErrors(hbck); // ensure that locks are deleted