Gargi-jais11 commented on code in PR #10395:
URL: https://github.com/apache/ozone/pull/10395#discussion_r3332258018
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/diskbalancer/TestDiskBalancerYaml.java:
##########
@@ -101,4 +102,50 @@ public void testReadYamlNullContainerStatesUsesDefault()
throws IOException {
DiskBalancerInfo info = DiskBalancerYaml.readDiskBalancerInfoFile(file);
Assertions.assertEquals(DiskBalancerConfiguration.DEFAULT_CONTAINER_STATES,
info.getContainerStates());
}
+
+ @ParameterizedTest
+ @MethodSource("invalidDiskBalancerYamlCases")
+ public void testReadYamlRejectsInvalidPersistedInfo(String yaml,
+ String expectedMessage) throws IOException {
+ File file = new File(tmpDir.toString(),
+ OZONE_SCM_DATANODE_DISK_BALANCER_INFO_FILE_DEFAULT);
+ Files.write(file.toPath(), yaml.getBytes(StandardCharsets.UTF_8));
+
+ IOException ex = assertThrows(IOException.class,
+ () -> DiskBalancerYaml.readDiskBalancerInfoFile(file));
+
+ Assertions.assertTrue(ex.getMessage().contains(expectedMessage),
+ () -> "Expected message to contain '" + expectedMessage + "': "
+ + ex.getMessage());
+ }
+
+ public static Stream<Arguments> invalidDiskBalancerYamlCases() {
+ return Stream.of(
+ Arguments.of(validYaml()
+ .replace("version: 1\n", "version: 99\n"),
+ "Unsupported DiskBalancer info version: 99"),
+ Arguments.of(validYaml()
+ .replace("version: 1\n", ""),
+ "DiskBalancer info version is missing"),
+ Arguments.of(validYaml()
+ .replace("operationalState: RUNNING\n", ""),
+ "DiskBalancer operationalState is missing"),
+ Arguments.of(validYaml()
+ .replace("threshold: 10.0\n", "threshold: 0.0\n"),
Review Comment:
Add similar cases for **bandwidth** and **parallelThread** (zero values)
since they follow the same validation path.
--
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]