Skip to content

Commit 23385a0

Browse files
XJDKCsfc-gh-rxing
andauthored
Extend FileIOFactory to Improve Customization (apache#724)
* Initial Commit * Fix test errors * Resolved some comments * Resolved some comments * Removed unused package * Make FileIOFactory as an ApplicationScoped bean * Revert some changes * Use FileIOFactory to get the creds for cleanup task * Use new interface in tests * Move some util classes to polaris-service-common as test fixtures * Delete the interface in FileIOFactory that is only used for testing * Refactor TestServices and use it in FileIOFactoryTest * Small change * Rename TestFileIOFactory to MeasuredFileIOFactory * Use FileIOFactory to load catalog default FileIO in tests, fix log level for FileIOUtil --------- Co-authored-by: Rulin Xing <rulin.xing@snowflake.com>
1 parent c3b86b0 commit 23385a0

23 files changed

+947
-384
lines changed

quarkus/service/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ dependencies {
9090
testFixturesApi(project(":polaris-tests"))
9191

9292
testImplementation(project(":polaris-api-management-model"))
93+
testImplementation(testFixtures(project(":polaris-service-common")))
9394

9495
testImplementation("org.apache.iceberg:iceberg-api:${libs.versions.iceberg.get()}:tests")
9596
testImplementation("org.apache.iceberg:iceberg-core:${libs.versions.iceberg.get()}:tests")

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/TestServices.java

Lines changed: 0 additions & 163 deletions
This file was deleted.

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/admin/ManagementServiceTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@
3232
import org.apache.polaris.core.admin.model.PolarisCatalog;
3333
import org.apache.polaris.core.admin.model.StorageConfigInfo;
3434
import org.apache.polaris.core.admin.model.UpdateCatalogRequest;
35-
import org.apache.polaris.service.quarkus.TestServices;
36-
import org.apache.polaris.service.quarkus.catalog.io.TestFileIOFactory;
35+
import org.apache.polaris.service.TestServices;
3736
import org.junit.jupiter.api.Test;
3837

3938
public class ManagementServiceTest {
4039
static TestServices services =
41-
TestServices.inMemory(
42-
new TestFileIOFactory(),
43-
Map.of("SUPPORTED_CATALOG_STORAGE_TYPES", List.of("S3", "GCS", "AZURE")));
40+
TestServices.builder()
41+
.config(Map.of("SUPPORTED_CATALOG_STORAGE_TYPES", List.of("S3", "GCS", "AZURE")))
42+
.build();
4443

4544
@Test
4645
public void testCreateCatalogWithDisallowedStorageConfig() {

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisAuthzTestBase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@
6767
import org.apache.polaris.core.persistence.PolarisMetaStoreSession;
6868
import org.apache.polaris.service.admin.PolarisAdminService;
6969
import org.apache.polaris.service.catalog.BasePolarisCatalog;
70+
import org.apache.polaris.service.catalog.PolarisPassthroughResolutionView;
7071
import org.apache.polaris.service.catalog.io.DefaultFileIOFactory;
72+
import org.apache.polaris.service.catalog.io.FileIOFactory;
7173
import org.apache.polaris.service.config.DefaultConfigurationStore;
7274
import org.apache.polaris.service.config.RealmEntityManagerFactory;
73-
import org.apache.polaris.service.quarkus.catalog.PolarisPassthroughResolutionView;
7475
import org.apache.polaris.service.storage.PolarisStorageIntegrationProviderImpl;
7576
import org.assertj.core.api.Assertions;
7677
import org.junit.jupiter.api.AfterEach;
@@ -160,6 +161,7 @@ public Map<String, String> getConfigOverrides() {
160161
protected PolarisEntityManager entityManager;
161162
protected PolarisMetaStoreManager metaStoreManager;
162163
protected PolarisMetaStoreSession metaStoreSession;
164+
protected FileIOFactory fileIOFactory;
163165
protected PolarisBaseEntity catalogEntity;
164166
protected PrincipalEntity principalEntity;
165167
protected RealmId realmId;
@@ -385,6 +387,8 @@ private void initBaseCatalog() {
385387
PolarisPassthroughResolutionView passthroughView =
386388
new PolarisPassthroughResolutionView(
387389
entityManager, metaStoreSession, securityContext, CATALOG_NAME);
390+
this.fileIOFactory =
391+
new DefaultFileIOFactory(realmEntityManagerFactory, managerFactory, configurationStore);
388392
this.baseCatalog =
389393
new BasePolarisCatalog(
390394
realmId,
@@ -396,7 +400,7 @@ private void initBaseCatalog() {
396400
passthroughView,
397401
securityContext,
398402
Mockito.mock(),
399-
new DefaultFileIOFactory());
403+
fileIOFactory);
400404
this.baseCatalog.initialize(
401405
CATALOG_NAME,
402406
ImmutableMap.of(

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisOverlappingCatalogTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@
3333
import org.apache.polaris.core.admin.model.CatalogProperties;
3434
import org.apache.polaris.core.admin.model.CreateCatalogRequest;
3535
import org.apache.polaris.core.admin.model.StorageConfigInfo;
36-
import org.apache.polaris.service.quarkus.TestServices;
37-
import org.apache.polaris.service.quarkus.catalog.io.TestFileIOFactory;
36+
import org.apache.polaris.service.TestServices;
3837
import org.junit.jupiter.params.ParameterizedTest;
3938
import org.junit.jupiter.params.provider.CsvSource;
4039

4140
public class PolarisOverlappingCatalogTest {
4241

4342
static TestServices services =
44-
TestServices.inMemory(
45-
new TestFileIOFactory(), Map.of("ALLOW_OVERLAPPING_CATALOG_URLS", "false"));
43+
TestServices.builder().config(Map.of("ALLOW_OVERLAPPING_CATALOG_URLS", "false")).build();
4644

4745
private Response createCatalog(String prefix, String defaultBaseLocation, boolean isExternal) {
4846
return createCatalog(prefix, defaultBaseLocation, isExternal, new ArrayList<String>());

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisOverlappingTableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.apache.polaris.core.admin.model.CreateCatalogRequest;
3737
import org.apache.polaris.core.admin.model.FileStorageConfigInfo;
3838
import org.apache.polaris.core.admin.model.StorageConfigInfo;
39-
import org.apache.polaris.service.quarkus.TestServices;
39+
import org.apache.polaris.service.TestServices;
4040
import org.junit.jupiter.api.DisplayName;
4141
import org.junit.jupiter.params.ParameterizedTest;
4242
import org.junit.jupiter.params.provider.Arguments;
@@ -105,7 +105,7 @@ void testTableLocationRestrictions(
105105
Map<String, Object> serverConfig,
106106
Map<String, String> catalogConfig,
107107
int expectedStatusForOverlaps) {
108-
TestServices services = TestServices.inMemory(serverConfig);
108+
TestServices services = TestServices.builder().config(serverConfig).build();
109109

110110
CatalogProperties.Builder propertiesBuilder =
111111
CatalogProperties.builder()

0 commit comments

Comments
 (0)