ChenSammi commented on code in PR #8239:
URL: https://github.com/apache/ozone/pull/8239#discussion_r2065260166
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/node/TestDiskBalancer.java:
##########
@@ -86,6 +90,53 @@ public void testDatanodeDiskBalancerReport() throws
IOException {
>= reportProtoList.get(1).getCurrentVolumeDensitySum());
}
+ @Test
+ public void testDiskBalancerStopAfterEven() throws IOException,
+ InterruptedException, TimeoutException {
+ String datanodeHostName1 = cluster.getStorageContainerManager()
+ .getScmNodeManager()
+ .getAllNodes()
+ .get(0)
+ .getHostName();
+
+ // Start the DiskBalancer with specific parameters
+ diskBalancerManager.startDiskBalancer(
+ Optional.of(10.0), // threshold
+ Optional.of(10L), // bandwidth in MB
+ Optional.of(5), // parallel threads
+ Optional.of(true), // stopAfterDiskEven
+ Optional.of(Collections.singletonList(datanodeHostName1))//apply to
one datanode
+ );
+
+ // Wait until the DiskBalancer status becomes RUNNING for that datanode
+ GenericTestUtils.waitFor(() -> {
+ try {
+ List<HddsProtos.DatanodeDiskBalancerInfoProto> statusList =
+
storageClient.getDiskBalancerStatus(Optional.of(Collections.singletonList(datanodeHostName1)),
+ Optional.empty());
+
+ return statusList.size() == 1 &&
statusList.get(0).getNode().getHostName().equals(datanodeHostName1) &&
+ statusList.get(0).getRunningStatus() ==
HddsProtos.DiskBalancerRunningStatus.RUNNING;
+ } catch (IOException e) {
+ return false;
+ }
+ }, 5000, 60000); // poll every 5s, timeout after 60s
Review Comment:
Or there is another way to verify the disk balancer has started and stopped,
by using GenericTestUtils.LogCapturer to verify the expected logs.
I will let you decide which one to go, as long as the test goal can be
achieved.
--
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]