smengcl commented on a change in pull request #108: HDDS-1987. Fix listStatus API URL: https://github.com/apache/hadoop-ozone/pull/108#discussion_r353170030
########## File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestKeyManagerImpl.java ########## @@ -784,6 +790,235 @@ public void testLookupKeyWithLocation() throws IOException { .getLocationList().get(0).getPipeline().getClosestNode()); } + @Test + public void testListStatusWithTableCache() throws Exception { + // Inspired by TestOmMetadataManager#testListKeys + String prefixKeyInDB = "key-d"; + String prefixKeyInCache = "key-c"; + + // Add a total of 100 key entries to DB and TableCache (50 entries each) + for (int i = 1; i <= 100; i++) { + if (i % 2 == 0) { // Add to DB + TestOMRequestUtils.addKeyToTable(false, + VOLUME_NAME, BUCKET_NAME, prefixKeyInDB + i, + 1000L, HddsProtos.ReplicationType.RATIS, + HddsProtos.ReplicationFactor.ONE, metadataManager); + } else { // Add to TableCache + TestOMRequestUtils.addKeyToTableCache( + VOLUME_NAME, BUCKET_NAME, prefixKeyInCache + i, + HddsProtos.ReplicationType.RATIS, HddsProtos.ReplicationFactor.ONE, + metadataManager); + } + } + + OmKeyArgs rootDirArgs = createKeyArgs(""); + // Get entries in both TableCache and DB + List<OzoneFileStatus> fileStatuses = + keyManager.listStatus(rootDirArgs, true, "", 1000); + Assert.assertEquals(100, fileStatuses.size()); + + // Get entries with startKey=prefixKeyInDB + fileStatuses = + keyManager.listStatus(rootDirArgs, true, prefixKeyInDB, 1000); + Assert.assertEquals(50, fileStatuses.size()); + + // Get entries with startKey=prefixKeyInCache + fileStatuses = + keyManager.listStatus(rootDirArgs, true, prefixKeyInCache, 1000); + Assert.assertEquals(100, fileStatuses.size()); Review comment: @bharatviswa504 No it should be `100`. Because `prefixKeyInCache = "key-c"` and `prefixKeyInDB = "key-d"`, it will continue to list all entries beginning with `key-d`. ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org