ChenSammi commented on code in PR #8056:
URL: https://github.com/apache/ozone/pull/8056#discussion_r1995250267


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/diskbalancer/TestDiskBalancerService.java:
##########
@@ -170,6 +180,86 @@ private DiskBalancerServiceTestImpl getDiskBalancerService(
         threadCount);
   }
 
+  static List<Integer> createVolumeSet() {
+    List<Integer> params = new ArrayList<>();
+    for (int i = 0; i < 4; i++) {
+      params.add(i);
+    }
+    return params;
+  }
+
+  @ParameterizedTest
+  @MethodSource("createVolumeSet")
+  public void testCalculateBytesToMove(Integer i) throws IOException {
+    try {
+      conf.set(ScmConfigKeys.HDDS_DATANODE_DIR_KEY,
+          generateVolumeLocation(testRoot.getAbsolutePath(), i));
+      volumeSet = new MutableVolumeSet(datanodeUuid, scmId, conf, null,
+          StorageVolume.VolumeType.DATA_VOLUME, null);
+      createDbInstancesForTestIfNeeded(volumeSet, scmId, scmId, conf);
+
+      double num1 = 0.02;
+      List<StorageVolume> volumes = new ArrayList<>();
+
+      for (StorageVolume volume : volumeSet.getVolumesList()) {
+        volume.incrementUsedSpace((long) 
(volume.getCurrentUsage().getCapacity() * num1));
+        volumes.add(volume);
+        num1 = 0.8;
+      }
+
+      ContainerSet containerSet = new ContainerSet(1000);
+      ContainerMetrics metrics = ContainerMetrics.create(conf);
+      KeyValueHandler keyValueHandler =
+          new KeyValueHandler(conf, datanodeUuid, containerSet, volumeSet,
+              metrics, c -> {
+          });
+      DiskBalancerServiceTestImpl svc =
+          getDiskBalancerService(containerSet, conf, keyValueHandler, null, 1);
+      svc.setShouldRun(true);
+      svc.setThreshold(10);
+      svc.setQueueSize(2);

Review Comment:
   You can pass the volumeSet and OzoneConfiguration to calculateBytesToMove() 
and make it public, so that you can directly call calculateBytesToMove from the 
unit test, and don't have to deal with the containerChoosingPolicy.  



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to