HBASE-24712 : Remove flakes from TestMasterNoCluster#testStopDuringStart (#2045)

Forward-port from 91da188d78
This commit is contained in:
Viraj Jasani 2020-07-10 20:41:03 +05:30 committed by GitHub
parent 67dfbe0406
commit f0bc33122e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
@ -43,6 +44,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Standup the master and fake it to test various aspects of master function.
@ -59,6 +62,8 @@ public class TestMasterNoCluster {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestMasterNoCluster.class);
private static final Logger LOG = LoggerFactory.getLogger(TestMasterNoCluster.class);
private static final HBaseTestingUtility TESTUTIL = new HBaseTestingUtility();
@Rule
@ -95,7 +100,20 @@ public class TestMasterNoCluster {
return false;
}
});
ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode);
// Before fails sometimes so retry.
try {
TESTUTIL.waitFor(10000, (Waiter.Predicate<Exception>) () -> {
try {
ZKUtil.deleteNodeRecursively(zkw, zkw.getZNodePaths().baseZNode);
return true;
} catch (KeeperException.NotEmptyException e) {
LOG.info("Failed delete, retrying", e);
}
return false;
});
} catch (Exception e) {
LOG.info("Failed zk clear", e);
}
zkw.close();
}