HDDS-1906. TestScmSafeMode#testSCMSafeModeRestrictedOp is failing. (#1260)

This commit is contained in:
Nanda kumar 2019-08-09 23:58:38 +05:30 committed by Xiaoyu Yao
parent 6ff0453ede
commit 98dd7c48ff
3 changed files with 22 additions and 0 deletions

View File

@ -226,6 +226,11 @@ public interface MiniOzoneCluster {
*/ */
void startHddsDatanodes(); void startHddsDatanodes();
/**
* Shuts down all the DataNodes.
*/
void shutdownHddsDatanodes();
/** /**
* Builder class for MiniOzoneCluster. * Builder class for MiniOzoneCluster.
*/ */

View File

@ -375,6 +375,17 @@ public class MiniOzoneClusterImpl implements MiniOzoneCluster {
}); });
} }
@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() { private CertificateClient getCAClient() {
return this.caClient; return this.caClient;
} }

View File

@ -58,6 +58,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; 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.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -91,6 +93,8 @@ public class TestScmSafeMode {
@Before @Before
public void init() throws Exception { public void init() throws Exception {
conf = new OzoneConfiguration(); conf = new OzoneConfiguration();
conf.set(OZONE_SCM_STALENODE_INTERVAL, "10s");
conf.set(OZONE_SCM_DEADNODE_INTERVAL, "25s");
builder = MiniOzoneCluster.newBuilder(conf) builder = MiniOzoneCluster.newBuilder(conf)
.setHbInterval(1000) .setHbInterval(1000)
.setHbProcessorInterval(500) .setHbProcessorInterval(500)
@ -328,6 +332,8 @@ public class TestScmSafeMode {
}, 50, 1000 * 30); }, 50, 1000 * 30);
assertTrue(clientProtocolServer.getSafeModeStatus()); assertTrue(clientProtocolServer.getSafeModeStatus());
cluster.shutdownHddsDatanodes();
Thread.sleep(30000);
LambdaTestUtils.intercept(SCMException.class, LambdaTestUtils.intercept(SCMException.class,
"Open container " + containers.get(0).getContainerID() + " " "Open container " + containers.get(0).getContainerID() + " "
+ "doesn't have enough replicas to service this operation in Safe" + "doesn't have enough replicas to service this operation in Safe"