liamzwbao commented on code in PR #1126:
URL: https://github.com/apache/polaris/pull/1126#discussion_r2009154136


##########
quarkus/service/src/intTest/java/org/apache/polaris/service/quarkus/it/QuarkusRestCatalogViewFileIT.java:
##########
@@ -20,20 +20,37 @@
 
 import io.quarkus.test.junit.QuarkusIntegrationTest;
 import java.lang.reflect.Field;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import org.apache.iceberg.view.ViewCatalogTests;
 import 
org.apache.polaris.service.it.test.PolarisRestCatalogViewFileIntegrationTest;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.AnnotatedElementContext;
+import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.io.TempDirFactory;
 
 @QuarkusIntegrationTest
 public class QuarkusRestCatalogViewFileIT extends 
PolarisRestCatalogViewFileIntegrationTest {
 
   @BeforeEach
-  public void setUpTempDir(@TempDir Path tempDir) throws Exception {
+  public void setUpTempDir(@TempDir(factory = CustomTempDirFactory.class) Path 
tempDir)
+      throws Exception {
     // see https://github.com/quarkusio/quarkus/issues/13261
     Field field = ViewCatalogTests.class.getDeclaredField("tempDir");
     field.setAccessible(true);
     field.set(this, tempDir);
   }
+
+  private static class CustomTempDirFactory implements TempDirFactory {
+    @Override
+    public Path createTempDirectory(
+        AnnotatedElementContext elementContext, ExtensionContext 
extensionContext)
+        throws Exception {
+      Path basePath = Paths.get(BASE_LOCATION.replaceFirst("file://", ""));

Review Comment:
   > was it because the customMetadataLocation configured with 
.withProperty(ViewProperties.WRITE_METADATA_LOCATION, customLocation) is not in 
the allowed location, and Polaris fails during validation? and you are changing 
the temp dir here to be under the allowed location?
   
   Yes.
   
   I've tried overriding the test and adding custom config, but since `tempDir` 
is a private field in the superclass, I can't access it to include it in the 
storage config when recreating the catalog using `managementApi.createCatalog`. 
The workaround is to hardcode a path like `file:///var/folders/6k` as `tempDir` 
is always generated under this path, but it isn't ideal. I have no control over 
the `tempDir` generation unless I rewrite the factory.



-- 
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: issues-unsubscr...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to