xloya commented on code in PR #4920:
URL: https://github.com/apache/gravitino/pull/4920#discussion_r1758125700


##########
catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java:
##########
@@ -609,6 +613,82 @@ public void testDropCatalogWithEmptySchema() {
     Assertions.assertFalse(metalake.catalogExists(catalogName), "catalog 
should not be exists");
   }
 
+  @Test
+  public void testGetFileLocation() {
+    String filesetName = GravitinoITUtils.genRandomName("fileset");
+    NameIdentifier filesetIdent = NameIdentifier.of(schemaName, filesetName);
+    
Assertions.assertFalse(catalog.asFilesetCatalog().filesetExists(filesetIdent));
+    Fileset expectedFileset =
+        catalog
+            .asFilesetCatalog()
+            .createFileset(
+                filesetIdent,
+                "fileset comment",
+                Fileset.Type.MANAGED,
+                generateLocation(filesetName),
+                Maps.newHashMap());
+    
Assertions.assertTrue(catalog.asFilesetCatalog().filesetExists(filesetIdent));
+    // test without caller context
+    try {
+      String actualFileLocation =
+          catalog.asFilesetCatalog().getFileLocation(filesetIdent, 
"/test1.par");
+
+      Assertions.assertEquals(expectedFileset.storageLocation() + 
"/test1.par", actualFileLocation);
+    } finally {
+      CallerContext.CallerContextHolder.remove();
+    }
+
+    // test with caller context
+    try {
+      Map<String, String> context = new HashMap<>();
+      context.put(
+          FilesetAuditConstants.HTTP_HEADER_INTERNAL_CLIENT_TYPE,
+          InternalClientType.HADOOP_GVFS.name());
+      context.put(
+          FilesetAuditConstants.HTTP_HEADER_FILESET_DATA_OPERATION,
+          FilesetDataOperation.CREATE.name());
+      CallerContext callerContext = 
CallerContext.builder().withContext(context).build();
+      CallerContext.CallerContextHolder.set(callerContext);
+
+      String actualFileLocation =
+          catalog.asFilesetCatalog().getFileLocation(filesetIdent, 
"/test2.par");
+
+      Assertions.assertEquals(expectedFileset.storageLocation() + 
"/test2.par", actualFileLocation);

Review Comment:
   Add a test case in the server-side unit 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]

Reply via email to