timmylicheng commented on a change in pull request #291: HDDS-1574 Average out pipeline allocation on datanodes and add metrcs/test URL: https://github.com/apache/hadoop-ozone/pull/291#discussion_r354286217
########## File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestRatisPipelineProvider.java ########## @@ -130,6 +140,49 @@ public void testCreatePipelineWithNodes() { Pipeline.PipelineState.OPEN); } + @Test + public void testComputeNodeIdsHash() { + int total = HddsProtos.ReplicationFactor.THREE.getNumber(); + List<DatanodeDetails> nodes1 = new ArrayList<>(); + for (int i = 0; i < total; i++) { + nodes1.add(TestUtils.createDatanodeDetails( + UUID.fromString("00000-11000-00000-00000-0000" + (i + 1)))); + } + + Assert.assertEquals(total, nodes1.size()); + Assert.assertNotEquals(0, + RatisPipelineUtils.encodeNodeIdsOfFactorThreePipeline(nodes1)); + + List<DatanodeDetails> nodes2 = new ArrayList<>(); + for (int i = 0; i < total; i++) { + nodes2.add(TestUtils.createDatanodeDetails( + UUID.fromString("00000-11000-00000-00000-0000" + (total - i)))); + } + Assert.assertEquals(total, nodes2.size()); + Assert.assertNotEquals(0, + RatisPipelineUtils.encodeNodeIdsOfFactorThreePipeline(nodes2)); + + Assert.assertEquals( + RatisPipelineUtils.encodeNodeIdsOfFactorThreePipeline(nodes1), + RatisPipelineUtils.encodeNodeIdsOfFactorThreePipeline(nodes2)); + } + + @Test + public void testCreateFactorTHREEPipelineWithSameDatanodes() { + List<DatanodeDetails> healthyNodes = nodeManager + .getNodes(HddsProtos.NodeState.HEALTHY).stream() + .limit(3).collect(Collectors.toList()); + + Pipeline pipeline1 = provider.create( + HddsProtos.ReplicationFactor.THREE, healthyNodes); + Pipeline pipeline2 = provider.create( + HddsProtos.ReplicationFactor.THREE, healthyNodes); + + Assert.assertTrue(pipeline1.getNodes().parallelStream() + .allMatch(pipeline2.getNodes()::contains)); + Assert.assertEquals(pipeline1.getNodeIdsHash(), pipeline2.getNodeIdsHash()); + } Review comment: Done in another test. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org