Gargi-jais11 commented on code in PR #9587:
URL: https://github.com/apache/ozone/pull/9587#discussion_r2664404006


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/diskbalancer/TestDefaultVolumeChoosingPolicy.java:
##########
@@ -0,0 +1,500 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.container.diskbalancer;
+
+import static 
org.apache.hadoop.ozone.container.diskbalancer.DiskBalancerVolumeCalculation.getVolumeUsages;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Stream;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.fs.MockSpaceUsageCheckFactory;
+import org.apache.hadoop.hdds.fs.MockSpaceUsageSource;
+import org.apache.hadoop.hdds.fs.SpaceUsageCheckFactory;
+import org.apache.hadoop.hdds.fs.SpaceUsagePersistence;
+import org.apache.hadoop.hdds.fs.SpaceUsageSource;
+import org.apache.hadoop.ozone.container.common.volume.HddsVolume;
+import org.apache.hadoop.ozone.container.common.volume.MutableVolumeSet;
+import org.apache.hadoop.ozone.container.common.volume.StorageVolume;
+import 
org.apache.hadoop.ozone.container.diskbalancer.DiskBalancerVolumeCalculation.VolumeFixedUsage;
+import 
org.apache.hadoop.ozone.container.diskbalancer.policy.DefaultVolumeChoosingPolicy;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Unit tests for DefaultVolumeChoosingPolicy.
+ */
+public class TestDefaultVolumeChoosingPolicy {
+
+  @TempDir
+  private Path baseDir;
+
+  private static final long MB = 1024L * 1024L;
+  private static final long VOLUME_CAPACITY = 2500L * MB; // 2500MB - same for 
all volumes
+  private static final long DEFAULT_CONTAINER_SIZE = 100L * MB; // 100MB
+  private DefaultVolumeChoosingPolicy policy;
+  private MutableVolumeSet volumeSet;
+  private String datanodeUuid;
+  private Map<HddsVolume, Long> deltaMap;
+
+  @BeforeEach
+  public void setup() {
+    datanodeUuid = UUID.randomUUID().toString();
+    policy = new DefaultVolumeChoosingPolicy(new ReentrantLock());
+    deltaMap = new HashMap<>();
+  }
+
+  /**
+   * Test case data structure for volume configuration.
+   */
+  public static class VolumeTestConfig {
+    private final String name;
+    private final double utilization;
+    private final Long customCapacity; // null means use default 
VOLUME_CAPACITY
+
+    public VolumeTestConfig(String name, double utilization) {
+      this.name = name;
+      this.utilization = utilization;
+      this.customCapacity = null;
+    }
+
+    public VolumeTestConfig(String name, double utilization, long 
customCapacity) {
+      this.name = name;
+      this.utilization = utilization;
+      this.customCapacity = customCapacity;
+    }
+
+    public String getName() {
+      return name;
+    }
+
+    public double getUtilization() {
+      return utilization;
+    }
+
+    public Long getCustomCapacity() {
+      return customCapacity;
+    }
+  }
+
+  /**
+   * Test scenario configuration.
+   */
+  public static class TestScenario {
+    private final String name;
+    private final List<VolumeTestConfig> volumes;
+    private final double thresholdPercentage;
+    private final long containerSize;
+    private final boolean shouldFindPair;
+    private final String expectedSourceDisk;
+    private final String expectedDestinationDisk;
+
+    public TestScenario(String name, List<VolumeTestConfig> volumes, double 
thresholdPercentage,
+                       long containerSize, boolean shouldFindPair,

Review Comment:
   sorry, missed this to correct.
   



-- 
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]

Reply via email to