siddhantsangwan commented on PR #6305:
URL: https://github.com/apache/ozone/pull/6305#issuecomment-1993801520
@Tejaskriya We were discussing how to test this change earlier. I came up
with a bit of a hack to test it.
```
@Test
public void testSourceDatanodeAddedBack()
throws NodeNotFoundException, IOException,
IllegalContainerBalancerStateException,
InvalidContainerBalancerConfigurationException, TimeoutException,
InterruptedException {
when(moveManager.move(any(ContainerID.class),
any(DatanodeDetails.class),
any(DatanodeDetails.class)))
.thenReturn(CompletableFuture.completedFuture(MoveManager.MoveResult.REPLICATION_FAIL_NOT_EXIST_IN_SOURCE))
.thenReturn(CompletableFuture.completedFuture(MoveManager.MoveResult.COMPLETED));
balancerConfiguration.setThreshold(10);
balancerConfiguration.setIterations(1);
balancerConfiguration.setMaxSizeEnteringTarget(10 * STORAGE_UNIT);
balancerConfiguration.setMaxSizeToMovePerIteration(100 * STORAGE_UNIT);
balancerConfiguration.setMaxDatanodesPercentageToInvolvePerIteration(100);
String includeNodes =
nodesInCluster.get(0).getDatanodeDetails().getHostName() + "," +
nodesInCluster.get(nodesInCluster.size() -
1).getDatanodeDetails().getHostName();
balancerConfiguration.setIncludeNodes(includeNodes);
startBalancer(balancerConfiguration);
GenericTestUtils.waitFor(() ->
ContainerBalancerTask.IterationResult.ITERATION_COMPLETED ==
containerBalancerTask.getIterationResult(), 10, 50);
assertEquals(2,
containerBalancerTask.getCountDatanodesInvolvedPerIteration());
assertTrue(containerBalancerTask.getMetrics().getNumContainerMovesCompletedInLatestIteration()
>= 1);
assertThat(containerBalancerTask.getMetrics().getNumContainerMovesFailed()).isEqualTo(1);
stopBalancer();
}
```
It uses the includeNodes configuration to ensure only one under and one over
utilized node is involved in balancing. This way we're able to test whether the
same source was or wasn't added back. What do you think?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]