errose28 commented on a change in pull request #1298: URL: https://github.com/apache/hadoop-ozone/pull/1298#discussion_r482283211
########## File path: hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java ########## @@ -471,4 +470,59 @@ public void testBlockThrottle() throws Exception { service.shutdown(); } } + + @Test + public void testDeletedChunkInfo() throws Exception { + OzoneConfiguration conf = new OzoneConfiguration(); + conf.setInt(OZONE_BLOCK_DELETING_CONTAINER_LIMIT_PER_INTERVAL, 10); + conf.setInt(OZONE_BLOCK_DELETING_LIMIT_PER_CONTAINER, 2); + ContainerSet containerSet = new ContainerSet(); + createToDeleteBlocks(containerSet, conf, 1, 2, 3); + + List<ContainerData> containerData = Lists.newArrayList(); + containerSet.listContainer(0L, 1, containerData); + + try(ReferenceCountedDB meta = BlockUtils.getDB( + (KeyValueContainerData) containerData.get(0), conf)) { + + // Collect all ChunkInfo from blocks marked for deletion. + List<? extends Table.KeyValue<String, BlockData>> deletingBlocks = + meta.getStore().getBlockDataTable() + .getRangeKVs(null, 100, + MetadataKeyFilters.getDeletingKeyFilter()); + + // Delete all blocks marked for deletion. + BlockDeletingServiceTestImpl svc = + getBlockDeletingService(containerSet, conf); + svc.start(); + GenericTestUtils.waitFor(svc::isStarted, 100, 3000); + deleteAndWait(svc, 1); + svc.shutdown(); + + // Get deleted blocks from their table, and check their ChunkInfo lists + // against those we saved for them before deletion. + List<? extends Table.KeyValue<String, ChunkInfoList>> deletedBlocks = + meta.getStore().getDeletedBlocksTable() + .getRangeKVs(null, 100); + + Assert.assertEquals(deletingBlocks.size(), deletedBlocks.size()); + + Iterator<? extends Table.KeyValue<String, BlockData>> + deletingBlocksIter = deletingBlocks.iterator(); + Iterator<? extends Table.KeyValue<String, ChunkInfoList>> + deletedBlocksIter = deletedBlocks.iterator(); + + while(deletingBlocksIter.hasNext() && deletedBlocksIter.hasNext()) { + List<ContainerProtos.ChunkInfo> deletingChunks = + deletingBlocksIter.next().getValue().getChunks(); + List<ContainerProtos.ChunkInfo> deletedChunks = + deletedBlocksIter.next().getValue().asList(); + Review comment: Yes, the iterator will return blocks in sorted order. The existing code already depends on this property in the existing test cases found in `TestKeyValueBlockIterator`. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org