diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java index 085c252b719..f45fb048314 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java @@ -178,6 +178,9 @@ public abstract class IntegrationTestBase extends AbstractHBaseTool { public abstract void setUpCluster() throws Exception; public void cleanUpCluster() throws Exception { + if (util.isDistributedCluster() && (monkey == null || !monkey.isDestructive())) { + noClusterCleanUp = true; + } if (noClusterCleanUp) { LOG.debug("noClusterCleanUp is set, skip restoring the cluster"); return; diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/CalmChaosMonkey.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/CalmChaosMonkey.java index bcf45dd1a23..bcf7d85ee75 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/CalmChaosMonkey.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/CalmChaosMonkey.java @@ -41,4 +41,9 @@ public class CalmChaosMonkey extends ChaosMonkey { public void waitForStop() throws InterruptedException { } + + @Override + public boolean isDestructive() { + return false; + } } diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/ChaosMonkey.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/ChaosMonkey.java index da75c3be480..86cbfe5c612 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/ChaosMonkey.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/ChaosMonkey.java @@ -51,4 +51,10 @@ public abstract class ChaosMonkey implements Stoppable { public abstract boolean isStopped(); public abstract void waitForStop() throws InterruptedException; + + /** + * Returns whether the CM does destructive actions (killing servers) so that a cluster restore + * is needed after CM is stopped. Otherwise cluster will be left as it is + */ + public abstract boolean isDestructive(); } diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java index f42f903473e..9152cb2a3a0 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java @@ -149,4 +149,10 @@ public class PolicyBasedChaosMonkey extends ChaosMonkey { monkeyThread.join(); } } + + @Override + public boolean isDestructive() { + // TODO: we can look at the actions, and decide to do the restore cluster or not based on them. + return true; + } }