From 80f83db0b843378e842fa09195fc764b7c8157db Mon Sep 17 00:00:00 2001 From: Enis Soztutar Date: Tue, 28 Oct 2014 17:10:50 -0700 Subject: [PATCH] HBASE-12367 Integration tests should not restore the cluster if the CM is not destructive --- .../java/org/apache/hadoop/hbase/IntegrationTestBase.java | 3 +++ .../apache/hadoop/hbase/chaos/monkies/CalmChaosMonkey.java | 5 +++++ .../org/apache/hadoop/hbase/chaos/monkies/ChaosMonkey.java | 6 ++++++ .../hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java | 6 ++++++ 4 files changed, 20 insertions(+) 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; + } }