kerneltime commented on code in PR #7943:
URL: https://github.com/apache/ozone/pull/7943#discussion_r1968688424
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/impl/TestBlockManagerImpl.java:
##########
@@ -196,6 +198,52 @@ public void testPutAndGetBlock(ContainerTestVersionInfo
versionInfo)
}
+ @ContainerTestVersionInfo.ContainerTest
+ public void testPutBlockForClosed(ContainerTestVersionInfo versionInfo)
+ throws Exception {
+ initTest(versionInfo);
+ assertEquals(0, keyValueContainer.getContainerData().getBlockCount());
+ // 1. Put Block with bcsId = 2, Overwrite = true
+ blockManager.putBlockForClosedContainer(keyValueContainer, blockData1,
true);
+
+ BlockData fromGetBlockData;
+ //Check Container's bcsId
+ fromGetBlockData = blockManager.getBlock(keyValueContainer,
blockData1.getBlockID());
+ assertEquals(1, keyValueContainer.getContainerData().getBlockCount());
+ assertEquals(1,
keyValueContainer.getContainerData().getBlockCommitSequenceId());
+ assertEquals(1, fromGetBlockData.getBlockCommitSequenceId());
+
+ // 2. Put Block with bcsId = 3, 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
+ // fails during block read.
+ Assertions.assertThrows(StorageContainerException.class, () -> blockManager
+ .getBlock(keyValueContainer, blockData2.getBlockID()));
+ assertEquals(2, keyValueContainer.getContainerData().getBlockCount());
+ // BcsId should still be 1, as the BcsId is not overwritten
+ assertEquals(1,
keyValueContainer.getContainerData().getBlockCommitSequenceId());
+
+ // 3. Put Block with bcsId = 3, Overwrite = true
+ // This should succeed as we are overwriting the BcsId, The container
BcsId should be updated to 3
+ // The block count should not change.
+ blockManager.putBlockForClosedContainer(keyValueContainer, blockData2,
true);
+ fromGetBlockData = blockManager.getBlock(keyValueContainer,
blockData2.getBlockID());
+ assertEquals(2, keyValueContainer.getContainerData().getBlockCount());
+ assertEquals(2,
keyValueContainer.getContainerData().getBlockCommitSequenceId());
+ assertEquals(2, fromGetBlockData.getBlockCommitSequenceId());
Review Comment:
Comment says `BSCIS==3` but the test is for 2 and it passes.
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/impl/TestBlockManagerImpl.java:
##########
@@ -196,6 +198,52 @@ public void testPutAndGetBlock(ContainerTestVersionInfo
versionInfo)
}
+ @ContainerTestVersionInfo.ContainerTest
+ public void testPutBlockForClosed(ContainerTestVersionInfo versionInfo)
+ throws Exception {
+ initTest(versionInfo);
+ assertEquals(0, keyValueContainer.getContainerData().getBlockCount());
Review Comment:
`assertEquals(State.CLOSED,
keyValueContainer.getContainerData().getState());` fails. The container should
be closed to test the method.
--
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]