priyeshkaratha commented on code in PR #8827:
URL: https://github.com/apache/ozone/pull/8827#discussion_r2292753838


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestDeleteBlocksCommandHandler.java:
##########
@@ -371,6 +371,128 @@ public void testDuplicateDeleteBlocksCommand(
         ((KeyValueContainerData) 
container.getContainerData()).getNumPendingDeletionBlocks());
   }
 
+  @ContainerTestVersionInfo.ContainerTest
+  public void testDuplicateTxFromSCMHandledByDeleteBlocksCommandHandler(
+      ContainerTestVersionInfo versionInfo) throws Exception {
+    prepareTest(versionInfo);
+    assertThat(containerSet.containerCount()).isGreaterThan(0);
+    Container<?> container = containerSet.getContainerIterator(volume1).next();
+    KeyValueContainerData containerData = (KeyValueContainerData) 
container.getContainerData();
+
+    // Create a delete transaction with specific block count and size
+    DeletedBlocksTransaction transaction = 
DeletedBlocksTransaction.newBuilder()
+        .setContainerID(container.getContainerData().getContainerID())
+        .setCount(0)
+        .addLocalID(1L)
+        .addLocalID(2L)
+        .addLocalID(3L) // 3 blocks
+        .setTxID(100)
+        .setTotalBlockSize(768L) // 3 blocks * 256 bytes each
+        .build();
+
+    // Record initial state
+    long initialPendingBlocks = containerData.getNumPendingDeletionBlocks();
+    long initialPendingBytes = containerData.getBlockPendingDeletionBytes();
+
+    // Execute the first transaction - should succeed
+    List<DeleteBlockTransactionResult> results1 =
+        handler.executeCmdWithRetry(Arrays.asList(transaction));
+
+    // Verify first execution succeeded
+    assertEquals(1, results1.size());
+    assertTrue(results1.get(0).getSuccess());
+
+    // Verify pending block count and size increased
+    long afterFirstPendingBlocks = containerData.getNumPendingDeletionBlocks();
+    long afterFirstPendingBytes = containerData.getBlockPendingDeletionBytes();
+    assertEquals(initialPendingBlocks + 3, afterFirstPendingBlocks);
+    assertEquals(initialPendingBytes + 768L, afterFirstPendingBytes);
+
+    // Execute the same transaction again (duplicate) - should be handled as 
duplicate
+    List<DeleteBlockTransactionResult> results2 =
+        handler.executeCmdWithRetry(Arrays.asList(transaction));
+
+    // Verify duplicate execution succeeded but didn't change counters
+    assertEquals(1, results2.size());
+    assertTrue(results2.get(0).getSuccess());
+
+    // Verify pending block count and size remained the same (no double 
counting)
+    assertEquals(afterFirstPendingBlocks, 
containerData.getNumPendingDeletionBlocks());
+    assertEquals(afterFirstPendingBytes, 
containerData.getBlockPendingDeletionBytes());
+  }
+
+  @ContainerTestVersionInfo.ContainerTest
+  public void 
testDuplicateTxExecutedByContainerBlockInfoInBlockDeletingService(

Review Comment:
   I removed the test and added new test case to check  blockdeletion metrics 
updates. Duplicate transaction checks and related test cases will be added as 
part of separate PR. 



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