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


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/TestDeletedBlockLog.java:
##########
@@ -895,6 +909,102 @@ public void 
testDeletedBlockTransactionsOfDeletedContainer() throws IOException
     assertEquals(0, blocks.size());
   }
 
+  @ParameterizedTest
+  @ValueSource(ints = {1, 10, 25, 50, 100})
+  public void testTransactionSerializedSize(int blockCount) {
+    long txID = 10000000;
+    long containerID = 1000000;
+    List<DeletedBlock> blocks = new ArrayList<>();
+    for (int i = 0; i < blockCount; i++) {
+      blocks.add(new DeletedBlock(new BlockID(containerID, 100000000 + i), 128 
* 1024 * 1024, 128 * 1024 * 1024));
+    }
+    List<Long> localIdList = blocks.stream().map(b -> 
b.getBlockID().getLocalID()).collect(Collectors.toList());
+    DeletedBlocksTransaction tx1 = DeletedBlocksTransaction.newBuilder()
+        .setTxID(txID)
+        .setContainerID(containerID)
+        .addAllLocalID(localIdList)
+        .setCount(0)
+        
.setTotalBlockSize(blocks.stream().mapToLong(DeletedBlock::getSize).sum())
+        
.setTotalBlockReplicatedSize(blocks.stream().mapToLong(DeletedBlock::getReplicatedSize).sum())
+        .build();
+    DeletedBlocksTransaction tx2 = DeletedBlocksTransaction.newBuilder()
+        .setTxID(txID)
+        .setContainerID(containerID)
+        .addAllLocalID(localIdList)
+        .setCount(0)
+        .build();
+    /*
+     *  1 blocks tx with totalBlockSize size is 26
+     *  1 blocks tx without totalBlockSize size is 16
+     *  10 blocks tx with totalBlockSize size is 73
+     *  10 blocks tx without totalBlockSize size is 61
+     *  25 blocks tx with totalBlockSize size is 148
+     *  25 blocks tx without totalBlockSize size is 136
+     *  50 blocks tx with totalBlockSize size is 273
+     *  50 blocks tx without totalBlockSize size is 261
+     *  100 blocks tx with totalBlockSize size is 523
+     *  100 blocks tx without totalBlockSize size is 511
+     */
+    System.out.println(blockCount + " blocks tx with totalBlockSize size is " 
+ tx1.getSerializedSize());
+    System.out.println(blockCount + " blocks tx without totalBlockSize size is 
" + tx2.getSerializedSize());

Review Comment:
    `assert` can be done instead of just printing like 
   ```
    @CsvSource({
       "1, 26, 16",
          ....})
   ```
   



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