aswinshakil commented on code in PR #7293:
URL: https://github.com/apache/ozone/pull/7293#discussion_r1834894429


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/checksum/TestContainerChecksumTreeManager.java:
##########
@@ -299,6 +319,64 @@ public void testEmptyFile() throws Exception {
     assertEquals(CONTAINER_ID, info.getContainerID());
   }
 
+  @Test
+  public void testContainerWithNoDiff() throws IOException {
+    ContainerMerkleTree ourMerkleTree = buildTestTree(config);
+    ContainerMerkleTree peerMerkleTree = buildTestTree(config);
+    checksumManager.writeContainerDataTree(container, ourMerkleTree);
+    ContainerChecksumTreeManager containerChecksumTreeManager = new 
ContainerChecksumTreeManager(
+        new OzoneConfiguration());
+    ContainerProtos.ContainerChecksumInfo peerChecksumInfo = 
ContainerProtos.ContainerChecksumInfo.newBuilder()
+            .setContainerID(container.getContainerID())
+            .setContainerMerkleTree(peerMerkleTree.toProto()).build();
+    ContainerChecksumTreeManager.ContainerDiff diff =
+        containerChecksumTreeManager.diff(container, peerChecksumInfo);
+    assertTrue(diff.isHealthy());
+  }
+
+  @ParameterizedTest
+  @MethodSource("getParameters")
+  public void testContainerDiffWithMismatches(int numMissingBlock, int 
numMissingChunk,
+                                              int numCorruptChunk) throws 
IOException {
+    Pair<ContainerMerkleTree, ContainerChecksumTreeManager.ContainerDiff> 
buildResult =
+        buildTestTreeWithMismatches(config, numMissingBlock, numMissingChunk, 
numCorruptChunk);
+    ContainerChecksumTreeManager.ContainerDiff expectedDiff = 
buildResult.getRight();
+    ContainerMerkleTree ourMerkleTree = buildResult.getLeft();
+    ContainerMerkleTree peerMerkleTree = buildTestTree(config);
+    checksumManager.writeContainerDataTree(container, ourMerkleTree);
+    ContainerChecksumTreeManager containerChecksumTreeManager = new 
ContainerChecksumTreeManager(
+        new OzoneConfiguration());
+    ContainerProtos.ContainerChecksumInfo peerChecksumInfo = 
ContainerProtos.ContainerChecksumInfo.newBuilder()
+        .setContainerID(container.getContainerID())
+        .setContainerMerkleTree(peerMerkleTree.toProto()).build();
+    ContainerChecksumTreeManager.ContainerDiff diff =
+        containerChecksumTreeManager.diff(container, peerChecksumInfo);
+    assertContainerDiffMatch(expectedDiff, diff);
+  }
+
+  /**
+   * Test if a peer which has missing blocks and chunks affects our container 
diff.
+   * Only if our merkle tree has missing entries from the peer we need to add 
it the Container Diff.
+   */
+  @ParameterizedTest
+  @MethodSource("getParameters")
+  public void testPeerWithMissingBlockAndMissingChunks(int numMissingBlock, 
int numMissingChunk,

Review Comment:
   I have added a description for the test above. I'll add more specific name 
for the function.



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