neils-dev commented on code in PR #3741:
URL: https://github.com/apache/ozone/pull/3741#discussion_r1122580398
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java:
##########
@@ -286,19 +288,161 @@ public void testDeleteContainer() throws Exception {
BlockData someKey1 = new BlockData(blockID1);
someKey1.setChunks(new LinkedList<ContainerProtos.ChunkInfo>());
blockManager.putBlock(container1, someKey1);
+ }
+
+ @Test
+ public void testDeleteNonEmptyContainer() throws Exception {
+ long testContainerID2 = getTestContainerID();
+ Container container2 = addContainer(containerSet, testContainerID2);
+ container2.close();
+
+ Assert.assertTrue(containerSet.getContainerMapCopy()
+ .containsKey(testContainerID2));
+
+ // With schema v3, we don't have a container dedicated db,
+ // so skip check the behaviors related to it.
+ assumeFalse(schemaVersion.contains(OzoneConsts.SCHEMA_V3));
// Deleting a non-empty container should fail.
BlockID blockID2 = ContainerTestHelper.getTestBlockID(testContainerID2);
BlockData someKey2 = new BlockData(blockID2);
someKey2.setChunks(new LinkedList<ContainerProtos.ChunkInfo>());
blockManager.putBlock(container2, someKey2);
+ // KeyValueHandler setup
+ String datanodeId = UUID.randomUUID().toString();
+
+ int[] interval = new int[1];
+ interval[0] = 2;
+ ContainerMetrics metrics = new ContainerMetrics(interval);
+
+ AtomicInteger icrReceived = new AtomicInteger(0);
+
+ KeyValueHandler kvHandler = new KeyValueHandler(conf,
+ datanodeId, containerSet, volumeSet, metrics,
+ c -> icrReceived.incrementAndGet());
+
exception.expect(StorageContainerException.class);
exception.expectMessage(
- "Container cannot be deleted because it is not empty.");
- container2.delete();
+ "Non-force deletion of non-empty container is not allowed.");
+ kvHandler.deleteContainer(container2, false);
+ Assert.assertTrue(containerSet.getContainerMapCopy()
+ .containsKey(testContainerID2));
+ }
+
+ /**
+ * If SchemaV3 is enabled, HddsVolume has already been
+ * formatted and initialized in
+ * setupPaths#createDbInstancesForTestIfNeeded.
+ * @throws Exception
+ */
+ @Test
+ public void testDeleteContainerWithRenaming()
+ throws Exception {
+ HddsVolume hddsVolume = null;
+ if (!schemaVersion.contains(OzoneConsts.SCHEMA_V3)) {
Review Comment:
Are we not handling container delete with rename for all schemas now? If
so, this test does the same thing 3 times, once for each schema without
altering behavior. The differences between < V3 and V3 was the db delete. It
doesn;t look to be involved in this test.
--
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]