adoroszlai commented on code in PR #6078:
URL: https://github.com/apache/ozone/pull/6078#discussion_r1464042966


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/helpers/TestContainerUtils.java:
##########
@@ -122,6 +127,23 @@ public void testDatanodeIDPersistent(@TempDir File 
tempDir) throws Exception {
     assertWriteRead(tempDir, id1);
   }
 
+  @Test
+  public void testVerifyInconsistentChecksumShouldFail() throws Exception {
+    ContainerData containerData = mock(ContainerData.class);
+    when(containerData.getContainerType()).thenReturn(
+        ContainerProtos.ContainerType.KeyValueContainer);
+    // mock to return different checksum
+    when(containerData.getChecksum()).thenReturn("checksum1", "checksum2");
+    
conf.setBoolean(HddsConfigKeys.HDDS_CONTAINER_CHECKSUM_VERIFICATION_ENABLED, 
true);
+    try {
+      ContainerUtils.verifyChecksum(containerData, conf);
+      fail("code should not reach here, exception should have been thrown.");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Container checksum error"));
+    }
+  }

Review Comment:
   We already have this test case:
   
   
https://github.com/apache/ozone/blob/422df39669f424d62e98de061be6b90190907e91/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDataYaml.java#L289-L301
   
   New functionality is in `ContainerImporter#importContainer`, should be 
tested in `TestContainerImporter`.



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