Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ public void testCreatePipelineWithNodes() {
@Test
public void testCreatePipelinesDnExclude() throws IOException {

// We have 10 DNs in MockNodeManager.
// We need 9 Healthy DNs in MockNodeManager.
NodeManager mockNodeManager = new MockNodeManager(true, 12);
PipelineStateManager stateManagerMock =
new PipelineStateManager(new OzoneConfiguration());
PipelineProvider providerMock = new MockRatisPipelineProvider(
mockNodeManager, stateManagerMock, new OzoneConfiguration());

// Use up first 3 DNs for an open pipeline.
List<DatanodeDetails> openPiplineDns = nodeManager.getAllNodes()
List<DatanodeDetails> openPiplineDns = mockNodeManager.getAllNodes()
.subList(0, 3);
HddsProtos.ReplicationFactor factor = HddsProtos.ReplicationFactor.THREE;

Expand All @@ -153,10 +159,10 @@ public void testCreatePipelinesDnExclude() throws IOException {
.setId(PipelineID.randomId())
.build();

stateManager.addPipeline(openPipeline);
stateManagerMock.addPipeline(openPipeline);

// Use up next 3 DNs also for an open pipeline.
List<DatanodeDetails> moreOpenPiplineDns = nodeManager.getAllNodes()
List<DatanodeDetails> moreOpenPiplineDns = mockNodeManager.getAllNodes()
.subList(3, 6);
Pipeline anotherOpenPipeline = Pipeline.newBuilder()
.setType(HddsProtos.ReplicationType.RATIS)
Expand All @@ -165,10 +171,10 @@ public void testCreatePipelinesDnExclude() throws IOException {
.setState(Pipeline.PipelineState.OPEN)
.setId(PipelineID.randomId())
.build();
stateManager.addPipeline(anotherOpenPipeline);
stateManagerMock.addPipeline(anotherOpenPipeline);

// Use up next 3 DNs also for a closed pipeline.
List<DatanodeDetails> closedPiplineDns = nodeManager.getAllNodes()
List<DatanodeDetails> closedPiplineDns = mockNodeManager.getAllNodes()
.subList(6, 9);
Pipeline anotherClosedPipeline = Pipeline.newBuilder()
.setType(HddsProtos.ReplicationType.RATIS)
Expand All @@ -177,9 +183,9 @@ public void testCreatePipelinesDnExclude() throws IOException {
.setState(Pipeline.PipelineState.CLOSED)
.setId(PipelineID.randomId())
.build();
stateManager.addPipeline(anotherClosedPipeline);
stateManagerMock.addPipeline(anotherClosedPipeline);

Pipeline pipeline = provider.create(factor);
Pipeline pipeline = providerMock.create(factor);
Assert.assertEquals(pipeline.getType(), HddsProtos.ReplicationType.RATIS);
Assert.assertEquals(pipeline.getFactor(), factor);
Assert.assertEquals(pipeline.getPipelineState(),
Expand All @@ -193,8 +199,8 @@ public void testCreatePipelinesDnExclude() throws IOException {
(openPiplineDns.contains(dn) || moreOpenPiplineDns.contains(dn)))
.count() == 0);

// Since we have only 10 DNs, at least 1 pipeline node should have been
// from the closed pipeline DN list.
// Since we have only 9 Healthy DNs, at least 1 pipeline node should have
// been from the closed pipeline DN list.
Assert.assertTrue(pipelineNodes.parallelStream().filter(
closedPiplineDns::contains).count() > 0);
}
Expand Down