HDDS-1047. Fix TestRatisPipelineProvider#testCreatePipelineWithFactor. Contributed by Nilotpal Nandi.

This commit is contained in:
Yiqun Lin 2019-02-13 10:50:57 +08:00
parent 3dc2523266
commit 06d7890bdd
1 changed files with 32 additions and 0 deletions

View File

@ -50,6 +50,28 @@ public class TestRatisPipelineProvider {
stateManager, new OzoneConfiguration());
}
private void createPipelineAndAssertions(
HddsProtos.ReplicationFactor factor) throws IOException {
Pipeline pipeline = provider.create(factor);
stateManager.addPipeline(pipeline);
Assert.assertEquals(pipeline.getType(), HddsProtos.ReplicationType.RATIS);
Assert.assertEquals(pipeline.getFactor(), factor);
Assert.assertEquals(pipeline.getPipelineState(),
Pipeline.PipelineState.OPEN);
Assert.assertEquals(pipeline.getNodes().size(), factor.getNumber());
Pipeline pipeline1 = provider.create(factor);
stateManager.addPipeline(pipeline1);
// New pipeline should not overlap with the previous created pipeline
Assert.assertTrue(
CollectionUtils.intersection(pipeline.getNodes(), pipeline1.getNodes())
.isEmpty());
Assert.assertEquals(pipeline1.getType(), HddsProtos.ReplicationType.RATIS);
Assert.assertEquals(pipeline1.getFactor(), factor);
Assert.assertEquals(pipeline1.getPipelineState(),
Pipeline.PipelineState.OPEN);
Assert.assertEquals(pipeline1.getNodes().size(), factor.getNumber());
}
@Test
public void testCreatePipelineWithFactor() throws IOException {
HddsProtos.ReplicationFactor factor = HddsProtos.ReplicationFactor.THREE;
@ -76,6 +98,16 @@ public class TestRatisPipelineProvider {
Assert.assertEquals(pipeline1.getNodes().size(), factor.getNumber());
}
@Test
public void testCreatePipelineWithFactorThree() throws IOException {
createPipelineAndAssertions(HddsProtos.ReplicationFactor.THREE);
}
@Test
public void testCreatePipelineWithFactorOne() throws IOException {
createPipelineAndAssertions(HddsProtos.ReplicationFactor.ONE);
}
private List<DatanodeDetails> createListOfNodes(int nodeCount) {
List<DatanodeDetails> nodes = new ArrayList<>();
for (int i = 0; i < nodeCount; i++) {