ashishkumar50 commented on code in PR #11028:
URL: https://github.com/apache/ozone/pull/11028#discussion_r3797659323


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestKeyDeletingService.java:
##########
@@ -350,6 +338,44 @@ void checkDeletionForKeysWithMultipleVersions() throws 
Exception {
           .isGreaterThanOrEqualTo(initialDeletedBlockCount + 3);
     }
 
+    @Test
+    void checkPurgedBytesMatchBlocksQueuedForDeletion() throws Exception {
+      final String volumeName = getTestName();
+      final String bucketName = uniqueObjectName("bucket");
+      final String keyName = uniqueObjectName("key");
+      final long initialDeletedCount = getDeletedKeyCount();
+
+      // Versioning keeps both committed versions on the key, so the delete 
entry spans two version groups.
+      createVolumeAndBucket(volumeName, bucketName, true);
+
+      keyDeletingService.suspend();
+      OmKeyArgs keyArgs = createAndCommitKey(volumeName, bucketName, keyName, 
1);
+      createAndCommitKey(volumeName, bucketName, keyName, 3);
+      writeClient.deleteKey(keyArgs);
+      // The delete has to reach RocksDB before getPendingDeletionKeys() can 
see it.
+      om.awaitDoubleBufferFlush();
+
+      Map<String, PurgedKey> purgedKeys =
+          keyManager.getPendingDeletionKeys((kv) -> true, 
Integer.MAX_VALUE).getPurgedKeys();
+      assertThat(purgedKeys).isNotEmpty();
+
+      for (PurgedKey purgedKey : purgedKeys.values()) {
+        assertEquals(4, purgedKey.getBlockGroup().getDeletedBlocks().size(),
+            "both committed versions must be queued for deletion");
+        long blockSum = purgedKey.getBlockGroup().getDeletedBlocks().stream()
+            .mapToLong(DeletedBlock::getReplicatedSize)
+            .sum();
+        assertEquals(blockSum, purgedKey.getPurgedBytes(),
+            "purged bytes must cover exactly the blocks queued for deletion");

Review Comment:
   This is exactly the implementation formula used in test which will always be 
success. Instead assert the actual key size to validate whether the purge key 
yields the correct size.



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