From 98dd7c48ff539198e94f5f314184f0a661a2f857 Mon Sep 17 00:00:00 2001 From: Nanda kumar Date: Fri, 9 Aug 2019 23:58:38 +0530 Subject: [PATCH] HDDS-1906. TestScmSafeMode#testSCMSafeModeRestrictedOp is failing. (#1260) --- .../org/apache/hadoop/ozone/MiniOzoneCluster.java | 5 +++++ .../org/apache/hadoop/ozone/MiniOzoneClusterImpl.java | 11 +++++++++++ .../org/apache/hadoop/ozone/om/TestScmSafeMode.java | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java index d3c96554d6c..44c005c29ec 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java @@ -226,6 +226,11 @@ void restartHddsDatanode(DatanodeDetails dn, boolean waitForDatanode) */ void startHddsDatanodes(); + /** + * Shuts down all the DataNodes. + */ + void shutdownHddsDatanodes(); + /** * Builder class for MiniOzoneCluster. */ diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java index e6f09a84fbe..be1b77b2303 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java @@ -375,6 +375,17 @@ public void startHddsDatanodes() { }); } + @Override + public void shutdownHddsDatanodes() { + hddsDatanodes.forEach((datanode) -> { + try { + shutdownHddsDatanode(datanode.getDatanodeDetails()); + } catch (IOException e) { + LOG.error("Exception while trying to shutdown datanodes:", e); + } + }); + } + private CertificateClient getCAClient() { return this.caClient; } diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java index 9f300d66320..04368b2fb42 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java @@ -58,6 +58,8 @@ import java.util.List; import java.util.Map; +import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_DEADNODE_INTERVAL; +import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_STALENODE_INTERVAL; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -91,6 +93,8 @@ public class TestScmSafeMode { @Before public void init() throws Exception { conf = new OzoneConfiguration(); + conf.set(OZONE_SCM_STALENODE_INTERVAL, "10s"); + conf.set(OZONE_SCM_DEADNODE_INTERVAL, "25s"); builder = MiniOzoneCluster.newBuilder(conf) .setHbInterval(1000) .setHbProcessorInterval(500) @@ -328,6 +332,8 @@ public void testSCMSafeModeRestrictedOp() throws Exception { }, 50, 1000 * 30); assertTrue(clientProtocolServer.getSafeModeStatus()); + cluster.shutdownHddsDatanodes(); + Thread.sleep(30000); LambdaTestUtils.intercept(SCMException.class, "Open container " + containers.get(0).getContainerID() + " " + "doesn't have enough replicas to service this operation in Safe"