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
6 changes: 2 additions & 4 deletions integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ dependencies {

implementation(libs.auth0.jwt)

implementation(platform(libs.testcontainers.bom))
implementation("org.testcontainers:testcontainers")
implementation(libs.s3mock.testcontainers)

implementation("org.apache.iceberg:iceberg-spark-3.5_2.12")
implementation("org.apache.iceberg:iceberg-spark-extensions-3.5_2.12")
implementation("org.apache.spark:spark-sql_2.12:3.5.6") {
Expand All @@ -69,6 +65,8 @@ dependencies {
implementation(libs.assertj.core)
implementation(libs.mockito.core)
implementation(libs.awaitility)
implementation(libs.s3mock.testcontainers)
implementation(project(":polaris-runtime-test-common"))
}

copiedCodeChecks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@

import static org.apache.polaris.service.it.env.PolarisClient.polarisClient;

import com.adobe.testing.s3mock.testcontainers.S3MockContainer;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
import org.apache.polaris.core.admin.model.Catalog;
import org.apache.polaris.core.admin.model.CatalogProperties;
Expand All @@ -38,6 +36,7 @@
import org.apache.polaris.service.it.env.ManagementApi;
import org.apache.polaris.service.it.env.PolarisApiEndpoints;
import org.apache.polaris.service.it.env.PolarisClient;
import org.apache.polaris.test.commons.s3mock.S3Mock;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
Expand All @@ -52,8 +51,7 @@

@ExtendWith(PolarisIntegrationTestExtension.class)
public abstract class PolarisSparkIntegrationTestBase {
protected static final S3MockContainer s3Container =
new S3MockContainer("3.11.0").withInitialBuckets("my-bucket,my-old-bucket");
protected static final S3Mock s3Container = new S3Mock();
protected static SparkSession spark;
protected PolarisApiEndpoints endpoints;
protected PolarisClient client;
Expand Down Expand Up @@ -98,26 +96,8 @@ public void before(
.setAllowedLocations(List.of("s3://my-old-bucket/path/to/data"))
.build();
CatalogProperties props = new CatalogProperties("s3://my-bucket/path/to/data");
props.putAll(
Map.of(
"table-default.s3.endpoint",
s3Container.getHttpEndpoint(),
"table-default.s3.path-style-access",
"true",
"table-default.s3.access-key-id",
"foo",
"table-default.s3.secret-access-key",
"bar",
"s3.endpoint",
s3Container.getHttpEndpoint(),
"s3.path-style-access",
"true",
"s3.access-key-id",
"foo",
"s3.secret-access-key",
"bar",
"polaris.config.drop-with-purge.enabled",
"true"));
props.putAll(s3Container.getS3ConfigProperties());
props.put("polaris.config.drop-with-purge.enabled", "true");
Catalog catalog =
PolarisCatalog.builder()
.setType(Catalog.TypeEnum.INTERNAL)
Expand All @@ -129,26 +109,8 @@ public void before(
managementApi.createCatalog(catalog);

CatalogProperties externalProps = new CatalogProperties("s3://my-bucket/path/to/data");
externalProps.putAll(
Map.of(
"table-default.s3.endpoint",
s3Container.getHttpEndpoint(),
"table-default.s3.path-style-access",
"true",
"table-default.s3.access-key-id",
"foo",
"table-default.s3.secret-access-key",
"bar",
"s3.endpoint",
s3Container.getHttpEndpoint(),
"s3.path-style-access",
"true",
"s3.access-key-id",
"foo",
"s3.secret-access-key",
"bar",
"polaris.config.drop-with-purge.enabled",
"true"));
externalProps.putAll(s3Container.getS3ConfigProperties());
externalProps.put("polaris.config.drop-with-purge.enabled", "true");
Catalog externalCatalog =
ExternalCatalog.builder()
.setType(Catalog.TypeEnum.EXTERNAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
*/
package org.apache.polaris.spark.quarkus.it;

import com.adobe.testing.s3mock.testcontainers.S3MockContainer;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.FormatMethod;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand All @@ -44,6 +42,7 @@
import org.apache.polaris.service.it.env.PolarisApiEndpoints;
import org.apache.polaris.service.it.ext.PolarisIntegrationTestExtension;
import org.apache.polaris.service.it.ext.SparkSessionBuilder;
import org.apache.polaris.test.commons.s3mock.S3Mock;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
Expand All @@ -58,8 +57,7 @@

@ExtendWith(PolarisIntegrationTestExtension.class)
public abstract class SparkIntegrationBase {
protected static final S3MockContainer s3Container =
new S3MockContainer("3.11.0").withInitialBuckets("my-bucket,my-old-bucket");
protected static final S3Mock s3Container = new S3Mock();
protected static SparkSession spark;
protected PolarisApiEndpoints endpoints;
protected PolarisManagementClient client;
Expand Down Expand Up @@ -100,26 +98,8 @@ public void before(
.setAllowedLocations(List.of("s3://my-old-bucket/path/to/data"))
.build();
CatalogProperties props = new CatalogProperties("s3://my-bucket/path/to/data");
props.putAll(
Map.of(
"table-default.s3.endpoint",
s3Container.getHttpEndpoint(),
"table-default.s3.path-style-access",
"true",
"table-default.s3.access-key-id",
"foo",
"table-default.s3.secret-access-key",
"bar",
"s3.endpoint",
s3Container.getHttpEndpoint(),
"s3.path-style-access",
"true",
"s3.access-key-id",
"foo",
"s3.secret-access-key",
"bar",
"polaris.config.drop-with-purge.enabled",
"true"));
props.putAll(s3Container.getS3ConfigProperties());
props.put("polaris.config.drop-with-purge.enabled", "true");
Catalog catalog =
PolarisCatalog.builder()
.setType(Catalog.TypeEnum.INTERNAL)
Expand Down
1 change: 1 addition & 0 deletions runtime/test-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ configurations.all {
}

dependencies {
implementation(libs.s3mock.testcontainers)
implementation(project(":polaris-core"))
implementation(libs.jakarta.ws.rs.api)
implementation(enforcedPlatform(libs.quarkus.bom))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.test.commons.s3mock;

import com.adobe.testing.s3mock.testcontainers.S3MockContainer;
import java.util.Map;
import org.apache.polaris.containerspec.ContainerSpecHelper;

public class S3Mock extends S3MockContainer {

private static final String DEFAULT_BUCKETS = "my-bucket,my-old-bucket";
private static final String DEFAULT_ACCESS_KEY = "ap1";
private static final String DEFAULT_SECRET_KEY = "s3cr3t";

public S3Mock() {
this(DEFAULT_BUCKETS);
}

public S3Mock(String initialBuckets) {
super(
ContainerSpecHelper.containerSpecHelper("s3mock", S3Mock.class)
.dockerImageName(null)
.asCompatibleSubstituteFor("adobe/s3mock"));
this.withInitialBuckets(initialBuckets);
}

public Map<String, String> getS3ConfigProperties() {
String endpoint = this.getHttpEndpoint();
return Map.of(
"table-default.s3.endpoint", endpoint,
"table-default.s3.path-style-access", "true",
"table-default.s3.access-key-id", DEFAULT_ACCESS_KEY,
"table-default.s3.secret-access-key", DEFAULT_SECRET_KEY,
"s3.endpoint", endpoint,
"s3.path-style-access", "true",
Copy link
Contributor

Choose a reason for hiding this comment

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

side note: why not use MinIO now that it is supported? It looks like from the Polaris POV using S3Mock is mostly the same as using any S3-compatible storage. The advantage of MinIO is that it is real (meaning not a mock).

This is just a tangential comment for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, thanks for the comment! This is a good observation, looks like an idea for the next PR! The current PR was aimed at fixing the environment to unblock further steps in studying the project.

"s3.access-key-id", DEFAULT_ACCESS_KEY,
"s3.secret-access-key", DEFAULT_SECRET_KEY);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# 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.
#

# Dockerfile to provide the image name and tag to a test.
# Version is managed by Renovate - do not edit.
FROM docker.io/adobe/s3mock:4.7.0