Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.apache.iceberg.exceptions.ForbiddenException;
import org.apache.iceberg.exceptions.RESTException;
import org.apache.iceberg.expressions.Expressions;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.io.ResolvingFileIO;
import org.apache.iceberg.rest.RESTCatalog;
import org.apache.iceberg.rest.RESTUtil;
Expand Down Expand Up @@ -168,7 +169,7 @@ public abstract class PolarisRestCatalogIntegrationBase extends CatalogTests<RES
};

@Retention(RetentionPolicy.RUNTIME)
private @interface CatalogConfig {
public @interface CatalogConfig {
Catalog.TypeEnum value() default Catalog.TypeEnum.INTERNAL;

String[] properties() default {
Expand All @@ -189,6 +190,14 @@ String[] properties() default {
*/
protected abstract StorageConfigInfo getStorageConfigInfo();

/**
* A hook for test sub-classes to initialize {@link FileIO} objects used by test cases thenselves
* for accessing test storage.
*/
protected void initializeClientFileIO(FileIO fileIO) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this PR uses both Io and IO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to MinIO

fileIO.initialize(Map.of());
}

/**
* Determine whether the test should be skipped based on the environment or configuration.
*
Expand Down Expand Up @@ -614,7 +623,7 @@ public void testLoadTableWithAccessDelegationForExternalCatalogWithConfigDisable
externalCatalogBase + "/ns1/my_table",
Map.of());
try (ResolvingFileIO resolvingFileIO = new ResolvingFileIO()) {
resolvingFileIO.initialize(Map.of());
initializeClientFileIO(resolvingFileIO);
resolvingFileIO.setConf(new Configuration());
String fileLocation = externalCatalogBase + "/ns1/my_table/metadata/v1.metadata.json";
TableMetadataParser.write(tableMetadata, resolvingFileIO.newOutputFile(fileLocation));
Expand Down Expand Up @@ -649,7 +658,7 @@ public void testLoadTableWithoutAccessDelegationForExternalCatalogWithConfigDisa
externalCatalogBase + "/ns1/my_table",
Map.of());
try (ResolvingFileIO resolvingFileIO = new ResolvingFileIO()) {
resolvingFileIO.initialize(Map.of());
initializeClientFileIO(resolvingFileIO);
resolvingFileIO.setConf(new Configuration());
String fileLocation = externalCatalogBase + "/ns1/my_table/metadata/v1.metadata.json";
TableMetadataParser.write(tableMetadata, resolvingFileIO.newOutputFile(fileLocation));
Expand Down Expand Up @@ -683,7 +692,7 @@ public void testLoadTableWithAccessDelegationForExternalCatalogWithConfigEnabled
externalCatalogBase + "/ns1/my_table",
Map.of());
try (ResolvingFileIO resolvingFileIO = new ResolvingFileIO()) {
resolvingFileIO.initialize(Map.of());
initializeClientFileIO(resolvingFileIO);
resolvingFileIO.setConf(new Configuration());
String fileLocation = externalCatalogBase + "/ns1/my_table/metadata/v1.metadata.json";
TableMetadataParser.write(tableMetadata, resolvingFileIO.newOutputFile(fileLocation));
Expand Down Expand Up @@ -711,7 +720,7 @@ public void testLoadTableTwiceWithETag() {
externalCatalogBase + "/ns1/my_table",
Map.of());
try (ResolvingFileIO resolvingFileIO = new ResolvingFileIO()) {
resolvingFileIO.initialize(Map.of());
initializeClientFileIO(resolvingFileIO);
resolvingFileIO.setConf(new Configuration());
String fileLocation = externalCatalogBase + "/ns1/my_table/metadata/v1.metadata.json";
TableMetadataParser.write(tableMetadata, resolvingFileIO.newOutputFile(fileLocation));
Expand Down Expand Up @@ -755,7 +764,7 @@ public void testRegisterAndLoadTableWithReturnedETag() {
externalCatalogBase + "/ns1/my_table",
Map.of());
try (ResolvingFileIO resolvingFileIO = new ResolvingFileIO()) {
resolvingFileIO.initialize(Map.of());
initializeClientFileIO(resolvingFileIO);
resolvingFileIO.setConf(new Configuration());
String fileLocation = externalCatalogBase + "/ns1/my_table/metadata/v1.metadata.json";
TableMetadataParser.write(tableMetadata, resolvingFileIO.newOutputFile(fileLocation));
Expand Down Expand Up @@ -798,7 +807,7 @@ public void testCreateAndLoadTableWithReturnedEtag() {
externalCatalogBase + "/ns1/my_table",
Map.of());
try (ResolvingFileIO resolvingFileIO = new ResolvingFileIO()) {
resolvingFileIO.initialize(Map.of());
initializeClientFileIO(resolvingFileIO);
resolvingFileIO.setConf(new Configuration());
String fileLocation = externalCatalogBase + "/ns1/my_table/metadata/v1.metadata.json";
TableMetadataParser.write(tableMetadata, resolvingFileIO.newOutputFile(fileLocation));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.service.quarkus.it;

import com.google.common.collect.ImmutableMap;
import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.net.URI;
import java.util.List;
import java.util.Map;
import org.apache.iceberg.io.FileIO;
import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.core.storage.StorageAccessProperty;
import org.apache.polaris.service.it.ext.PolarisIntegrationTestExtension;
import org.apache.polaris.service.it.test.PolarisRestCatalogIntegrationBase;
import org.apache.polaris.test.minio.Minio;
import org.apache.polaris.test.minio.MinioAccess;
import org.apache.polaris.test.minio.MinioExtension;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;

@QuarkusIntegrationTest
@TestProfile(QuarkusPolarisRestCatalogMinIOIT.Profile.class)
@ExtendWith(MinioExtension.class)
@ExtendWith(PolarisIntegrationTestExtension.class)
public class QuarkusPolarisRestCatalogMinIOIT extends PolarisRestCatalogIntegrationBase {

private static final String BUCKET_URI_PREFIX = "/minio-test-polaris";
private static final String MINIO_ACCESS_KEY = "test-ak-123-polaris";
private static final String MINIO_SECRET_KEY = "test-sk-123-polaris";

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return ImmutableMap.<String, String>builder()
.put("polaris.storage.aws.access-key", MINIO_ACCESS_KEY)
.put("polaris.storage.aws.secret-key", MINIO_SECRET_KEY)
.put("polaris.features.\"SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION\"", "false")
.build();
}
}

private static URI storageBase;
private static String endpoint;

@BeforeAll
static void setup(
@Minio(accessKey = MINIO_ACCESS_KEY, secretKey = MINIO_SECRET_KEY) MinioAccess minioAccess) {
storageBase = minioAccess.s3BucketUri(BUCKET_URI_PREFIX);
endpoint = minioAccess.s3endpoint();
}

@Override
protected boolean shouldSkip() {
return false;
}

@Override
protected void initializeClientFileIO(FileIO fileIO) {
fileIO.initialize(
ImmutableMap.<String, String>builder()
.put(StorageAccessProperty.AWS_ENDPOINT.getPropertyName(), endpoint)
.put(StorageAccessProperty.AWS_PATH_STYLE_ACCESS.getPropertyName(), "true")
.put(StorageAccessProperty.AWS_KEY_ID.getPropertyName(), MINIO_ACCESS_KEY)
.put(StorageAccessProperty.AWS_SECRET_KEY.getPropertyName(), MINIO_SECRET_KEY)
.build());
}

@Override
protected StorageConfigInfo getStorageConfigInfo() {
AwsStorageConfigInfo.Builder storageConfig =
AwsStorageConfigInfo.builder()
.setRoleArn("arn:aws:iam::123456789012:role/polaris-test")
.setExternalId("externalId123")
.setUserArn("arn:aws:iam::123456789012:user/polaris-test")
.setStorageType(StorageConfigInfo.StorageTypeEnum.S3)
.setPathStyleAccess(true)
.setEndpoint(endpoint)
.setAllowedLocations(List.of(storageBase.toString()));

return storageConfig.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;

/**
* These tests complement {@link QuarkusPolarisRestCatalogMinIOIT} to validate client-side access to
* MinIO storage via {@code FileIO} instances configured from catalog's {@code loadTable} responses
* with some S3-specific options.
*/
@QuarkusIntegrationTest
@TestProfile(QuarkusRestCatalogMinIoIT.Profile.class)
@TestProfile(QuarkusRestCatalogMinIOSpecialIT.Profile.class)
@ExtendWith(MinioExtension.class)
@ExtendWith(PolarisIntegrationTestExtension.class)
public class QuarkusRestCatalogMinIoIT {
public class QuarkusRestCatalogMinIOSpecialIT {

private static final String BUCKET_URI_PREFIX = "/minio-test";
private static final String MINIO_ACCESS_KEY = "test-ak-123";
Expand Down