GeorgeJahad commented on code in PR #4182:
URL: https://github.com/apache/ozone/pull/4182#discussion_r1120936022


##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestContainerEndpoint.java:
##########
@@ -280,6 +340,34 @@ public void testGetKeysForContainer() {
     assertEquals(3, data.getTotalCount());
   }
 
+  @Test
+  public void testGetFileTableKeysForContainer() throws IOException {
+    // test to check if the ContainerEndpoint also reads the File table
+
+    // Set up test data for FSO keys
+    setUpMultiBlockKey();
+    // Reprocess the container key mapper to ensure the latest mapping is used
+    reprocessContainerKeyMapper();
+    Response response = containerEndpoint.getKeysForContainer(20L, -1, "");
+
+    // Ensure that the expected number of keys is returned
+    KeysResponse data = (KeysResponse) response.getEntity();
+    Collection<KeyMetadata> keyMetadataList = data.getKeys();
+
+    assertEquals(1, data.getTotalCount());
+    assertEquals(1, keyMetadataList.size());
+
+    // Retrieve the first key from the list and verify its metadata
+    Iterator<KeyMetadata> iterator = keyMetadataList.iterator();
+    KeyMetadata keyMetadata = iterator.next();
+    assertEquals("dir1/file7", keyMetadata.getKey());
+    assertEquals(1, keyMetadata.getVersions().size());
+    assertEquals(1, keyMetadata.getBlockIds().size());
+    Map<Long, List<KeyMetadata.ContainerBlockMetadata>> blockIds =
+        keyMetadata.getBlockIds();
+    assertEquals(0, blockIds.get(0L).iterator().next().getLocalID());

Review Comment:
   Please create a static final for the LOCAL_ID.  Also "iterator().next()" 
seems convoluted, doesn't it?  couldn't it just be "get(0)"?



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