kerneltime commented on code in PR #7943:
URL: https://github.com/apache/ozone/pull/7943#discussion_r1978299816


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/impl/TestBlockManagerImpl.java:
##########
@@ -196,6 +200,65 @@ public void testPutAndGetBlock(ContainerTestVersionInfo 
versionInfo)
 
   }
 
+  @ContainerTestVersionInfo.ContainerTest
+  public void testPutBlockForClosed(ContainerTestVersionInfo versionInfo)
+      throws Exception {
+    initTest(versionInfo);
+    KeyValueContainerData containerData = keyValueContainer.getContainerData();
+    assertEquals(0, containerData.getBlockCount());
+    keyValueContainer.close();
+    assertEquals(CLOSED, keyValueContainer.getContainerState());
+    // 1. Put Block with bcsId = 2, Overwrite = true
+    blockManager.putBlockForClosedContainer(keyValueContainer, blockData1, 
true);
+
+    try (DBHandle db = BlockUtils.getDB(containerData, config)) {
+      BlockData fromGetBlockData;
+      //Check Container's bcsId
+      fromGetBlockData = blockManager.getBlock(keyValueContainer, 
blockData1.getBlockID());
+      assertEquals(1, containerData.getBlockCount());
+      assertEquals(1, containerData.getBlockCommitSequenceId());
+      assertEquals(1, fromGetBlockData.getBlockCommitSequenceId());
+      assertEquals(1, 
db.getStore().getMetadataTable().get(containerData.getBcsIdKey()));
+      assertEquals(1, 
db.getStore().getMetadataTable().get(containerData.getBlockCountKey()));
+
+      // 2. Put Block with bcsId = 2, Overwrite = false
+      BlockData blockData2 = createBlockData(1L, 3L, 1, 0, 2048, 2);
+      blockManager.putBlockForClosedContainer(keyValueContainer, blockData2, 
false);
+
+      // The block should be written, but we won't be able to read it, As 
BcsId < container's BcsId

Review Comment:
   ```
   -      // The block should be written, but we won't be able to read it, As 
BcsId < container's BcsId
   +      // The block should be written, but we won't be able to read it, As 
expected BcsId < container's BcsId
          // fails during block read.
   -      Assertions.assertThrows(StorageContainerException.class, () -> 
blockManager
   +      assertThrows(StorageContainerException.class, () -> {
   +        BlockData block = blockManager.getBlock(keyValueContainer, 
blockData2.getBlockID());
   +        ;});
   +      assertThrows(StorageContainerException.class, () -> blockManager
   ```



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