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


##########
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));

Review Comment:
   This test the same TxID as container's containerSet.getDeleteTransactionId() 
case, can we add more steps to test a duplicate tx whose ID is smaller than 
containerSet.getDeleteTransactionId() ? 



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