use of org.apache.hadoop.ozone.OzoneConfigKeys.DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY in project ozone by apache.
the class TestRatisPipelineLeader method testLeaderIdAfterLeaderChange.
@Test(timeout = 120000)
public void testLeaderIdAfterLeaderChange() throws Exception {
List<Pipeline> pipelines = cluster.getStorageContainerManager().getPipelineManager().getPipelines(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
Assert.assertFalse(pipelines.isEmpty());
Pipeline ratisPipeline = pipelines.iterator().next();
Assert.assertTrue(ratisPipeline.isHealthy());
Optional<HddsDatanodeService> dnToStop = cluster.getHddsDatanodes().stream().filter(s -> !s.getDatanodeStateMachine().getDatanodeDetails().getUuid().equals(ratisPipeline.getLeaderId())).findAny();
Assert.assertTrue(dnToStop.isPresent());
dnToStop.get().stop();
// wait long enough based on leader election min timeout
Thread.sleep(4000 * conf.getTimeDuration(DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY, 5, TimeUnit.SECONDS));
GenericTestUtils.waitFor(() -> {
try {
return verifyLeaderInfo(ratisPipeline);
} catch (Exception e) {
LOG.error("Failed verifying the leader info.", e);
Assert.fail("Failed getting leader info.");
return false;
}
}, 200, 20000);
}
Aggregations