diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestRatisPipelineProvider.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestRatisPipelineProvider.java index 6f4934f32a..6f385de1d7 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestRatisPipelineProvider.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestRatisPipelineProvider.java @@ -50,6 +50,28 @@ public void init() throws Exception { 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 void testCreatePipelineWithFactor() throws IOException { 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 createListOfNodes(int nodeCount) { List nodes = new ArrayList<>(); for (int i = 0; i < nodeCount; i++) {