HDDS-1047. Fix TestRatisPipelineProvider#testCreatePipelineWithFactor. Contributed...
authorYiqun Lin <yqlin@apache.org>
Wed, 13 Feb 2019 02:50:57 +0000 (10:50 +0800)
committerYiqun Lin <yqlin@apache.org>
Wed, 13 Feb 2019 02:50:57 +0000 (10:50 +0800)
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestRatisPipelineProvider.java

index 6f4934f..6f385de 100644 (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++) {