Skip to content

Commit

Permalink
Cleanup test profile and make it converge with prod profile
Browse files Browse the repository at this point in the history
This PR cleans up the test profile and makes it converge with the prod profile, which is better as by default, tests are testing the real-life application.

If tests need to customize the configuration, this is now done on a per-test basis.
  • Loading branch information
adutra committed Jan 15, 2025
1 parent 6712662 commit 11792d5
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* @implSpec This test expects the server to be configured with the following features enabled:
* <ul>
* <li>{@link org.apache.polaris.core.PolarisConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
* {@code true}
* <li>{@link
* org.apache.polaris.core.PolarisConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION}:
* {@code true}
* </ul>
* The server must also be configured to reject request body sizes larger than 1MB (1000000
* bytes).
*/
@ExtendWith(PolarisIntegrationTestExtension.class)
public class PolarisApplicationIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.shaded.org.awaitility.Awaitility;

/**
* @implSpec @implSpec This test expects the server to be configured with the following features
* enabled:
* <ul>
* <li>{@link org.apache.polaris.core.PolarisConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
* {@code true}
* <li>{@link
* org.apache.polaris.core.PolarisConfiguration#ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING}:
* {@code true}
* </ul>
*/
@ExtendWith(PolarisIntegrationTestExtension.class)
public class PolarisManagementServiceIntegrationTest {
private static final int MAX_IDENTIFIER_LENGTH = 256;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
/**
* Import the full core Iceberg catalog tests by hitting the REST service via the RESTCatalog
* client.
*
* @implSpec @implSpec This test expects the server to be configured with the following features
* enabled:
* <ul>
* <li>{@link PolarisConfiguration#ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING}: {@code false}
* </ul>
*/
@ExtendWith(PolarisIntegrationTestExtension.class)
public class PolarisRestCatalogIntegrationTest extends CatalogTests<RESTCatalog> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
/**
* Import the full core Iceberg catalog tests by hitting the REST service via the RESTCatalog
* client.
*
* @implSpec This test expects the server to be configured with {@link
* org.apache.polaris.core.PolarisConfiguration#SUPPORTED_CATALOG_STORAGE_TYPES} set to the
* appropriate storage type.
*/
@ExtendWith(PolarisIntegrationTestExtension.class)
public abstract class PolarisRestCatalogViewIntegrationBase extends ViewCatalogTests<RESTCatalog> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.LoggerFactory;

/**
* @implSpec This test expects the server to be configured with the following features enabled:
* <ul>
* <li>{@link
* org.apache.polaris.core.PolarisConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION}:
* {@code true}
* <li>{@link org.apache.polaris.core.PolarisConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
* {@code true}
* </ul>
*/
@ExtendWith(PolarisIntegrationTestExtension.class)
public class PolarisSparkIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
package org.apache.polaris.service.quarkus.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.util.Map;
import org.apache.polaris.service.it.test.PolarisSparkIntegrationTest;

@QuarkusIntegrationTest
Expand Down
42 changes: 15 additions & 27 deletions quarkus/service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ quarkus.otel.sdk.disabled=false
# quarkus.otel.traces.sampler=parentbased_always_on
# quarkus.otel.traces.sampler.arg=1.0d

quarkus.test.integration-test-profile=test
quarkus.test.integration-test-profile=it

polaris.realm-context.type=default
polaris.realm-context.realms=realm1,realm2,realm3
polaris.realm-context.realms=POLARIS
polaris.realm-context.header-name=Polaris-Realm

polaris.features.defaults."ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING"=false
Expand Down Expand Up @@ -120,30 +120,18 @@ polaris.authentication.token-broker.max-token-generation=PT1H
# polaris.storage.gcp.token=token
# polaris.storage.gcp.lifespan=PT1H

# Profile for unit tests
%test.quarkus.log.file.enable=false
%test.quarkus.log.category."org.apache.polaris".level=INFO
%test.quarkus.log.category."org.apache.iceberg.rest".level=INFO
%test.quarkus.log.category."org.apache.iceberg.rest.RESTSessionCatalog".level=ERROR
%test.quarkus.log.category."org.apache.polaris.core.persistence.PolarisMetaStoreManagerImpl".level=ERROR
%test.quarkus.log.category."org.apache.polaris.service.context.DefaultRealmContextResolver".level=ERROR
%test.quarkus.log.category."org.apache.polaris.service.catalog.PolarisCatalogHandlerWrapper".level=ERROR
%test.quarkus.log.category."org.apache.polaris.service.storage.PolarisStorageIntegrationProviderImpl".level=ERROR
%test.quarkus.http.limits.max-body-size=1000000
%test.quarkus.otel.sdk.disabled=true
%test.polaris.authentication.token-broker.type=symmetric-key
%test.polaris.authentication.token-broker.symmetric-key.secret=polaris
%test.polaris.features.defaults."ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING"=false
%test.polaris.features.defaults."ALLOW_EXTERNAL_METADATA_FILE_LOCATION"=false
%test.polaris.features.defaults."ALLOW_OVERLAPPING_CATALOG_URLS"=true
%test.polaris.features.defaults."ALLOW_SPECIFYING_FILE_IO_IMPL"=true
%test.polaris.features.defaults."ALLOW_WILDCARD_LOCATION"=true
%test.polaris.features.defaults."ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING"=true
%test.polaris.features.defaults."INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST"=true
%test.polaris.features.defaults."SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION"=true
%test.polaris.features.defaults."SUPPORTED_CATALOG_STORAGE_TYPES"=["FILE","S3","GCS","AZURE"]
%test.polaris.realm-context.realms=POLARIS
%test.polaris.realm-context.type=test
%test.polaris.storage.aws.access-key=accessKey
%test.polaris.storage.aws.secret-key=secretKey
%test.polaris.storage.gcp.token=token
%test.polaris.storage.gcp.lifespan=PT1H

# Profile for integration tests
%it.quarkus.http.limits.max-body-size=1000000
%it.polaris.features.defaults."ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING"=false
%it.polaris.features.defaults."ALLOW_EXTERNAL_METADATA_FILE_LOCATION"=false
%it.polaris.features.defaults."ALLOW_OVERLAPPING_CATALOG_URLS"=true
%it.polaris.features.defaults."ALLOW_SPECIFYING_FILE_IO_IMPL"=true
%it.polaris.features.defaults."ALLOW_WILDCARD_LOCATION"=true
%it.polaris.features.defaults."ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING"=true
%it.polaris.features.defaults."INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_it"=true
%it.polaris.features.defaults."SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION"=true
%it.polaris.features.defaults."SUPPORTED_CATALOG_STORAGE_TYPES"=["FILE","S3","GCS","AZURE"]
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of("polaris.metrics.tags.environment", "prod");
return Map.of(
"polaris.metrics.tags.environment", "prod", "polaris.realm-context.type", "test");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public static class Profile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"polaris.config.defaults.ALLOW_SPECIFYING_FILE_IO_IMPL",
"polaris.features.defaults.\"ALLOW_SPECIFYING_FILE_IO_IMPL\"",
"true",
"polaris.config.defaults.ALLOW_EXTERNAL_METADATA_FILE_LOCATION",
"polaris.features.defaults.\"ALLOW_EXTERNAL_METADATA_FILE_LOCATION\"",
"true");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.google.common.collect.Iterators;
import io.quarkus.test.junit.QuarkusMock;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.SecurityContext;
import java.io.IOException;
Expand Down Expand Up @@ -120,7 +122,23 @@
import software.amazon.awssdk.services.sts.model.Credentials;

@QuarkusTest
@TestProfile(BasePolarisCatalogTest.Profile.class)
public class BasePolarisCatalogTest extends CatalogTests<BasePolarisCatalog> {

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"polaris.features.defaults.\"ALLOW_SPECIFYING_FILE_IO_IMPL\"",
"true",
"polaris.features.defaults.\"INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST\"",
"true",
"polaris.features.defaults.\"SUPPORTED_CATALOG_STORAGE_TYPES\"",
"[\"FILE\"]");
}
}

protected static final Namespace NS = Namespace.of("newdb");
protected static final TableIdentifier TABLE = TableIdentifier.of(NS, "table");
protected static final Schema SCHEMA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import com.google.common.collect.ImmutableMap;
import io.quarkus.test.junit.QuarkusMock;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.SecurityContext;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.catalog.Catalog;
Expand Down Expand Up @@ -64,7 +67,27 @@
import org.mockito.Mockito;

@QuarkusTest
@TestProfile(BasePolarisCatalogViewTest.Profile.class)
public class BasePolarisCatalogViewTest extends ViewCatalogTests<BasePolarisCatalog> {

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"polaris.features.defaults.\"ALLOW_WILDCARD_LOCATION\"",
"true",
"polaris.features.defaults.\"SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION\"",
"true",
"polaris.features.defaults.\"ALLOW_SPECIFYING_FILE_IO_IMPL\"",
"true",
"polaris.features.defaults.\"INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST\"",
"true",
"polaris.features.defaults.\"SUPPORTED_CATALOG_STORAGE_TYPES\"",
"[\"FILE\"]");
}
}

public static final String CATALOG_NAME = "polaris-catalog";

@Inject MetaStoreManagerFactory managerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public static class Profile extends PolarisAuthzTestBase.Profile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of("polaris.features.defaults.\"ALLOW_EXTERNAL_METADATA_FILE_LOCATION\"", "true");
return Map.of(
"polaris.features.defaults.\"ALLOW_SPECIFYING_FILE_IO_IMPL\"",
"true",
"polaris.features.defaults.\"ALLOW_EXTERNAL_METADATA_FILE_LOCATION\"",
"true");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,23 @@
package org.apache.polaris.service.quarkus.it;

import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.util.Map;
import org.apache.polaris.service.it.test.PolarisApplicationIntegrationTest;

@QuarkusTest
public class QuarkusApplicationIntegrationTest extends PolarisApplicationIntegrationTest {}
@TestProfile(QuarkusApplicationIntegrationTest.Profile.class)
public class QuarkusApplicationIntegrationTest extends PolarisApplicationIntegrationTest {

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"quarkus.http.limits.max-body-size", "1000000",
"polaris.features.defaults.\"ALLOW_OVERLAPPING_CATALOG_URLS\"", "true",
"polaris.features.defaults.\"SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION\"", "true");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,25 @@
package org.apache.polaris.service.quarkus.it;

import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.util.Map;
import org.apache.polaris.service.it.test.PolarisManagementServiceIntegrationTest;

@QuarkusTest
@TestProfile(QuarkusManagementServiceIntegrationTest.Profile.class)
public class QuarkusManagementServiceIntegrationTest
extends PolarisManagementServiceIntegrationTest {}
extends PolarisManagementServiceIntegrationTest {

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"polaris.features.defaults.\"ALLOW_OVERLAPPING_CATALOG_URLS\"",
"true",
"polaris.features.defaults.\"ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING\"",
"true");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@
package org.apache.polaris.service.quarkus.it;

import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.util.Map;
import org.apache.polaris.service.it.test.PolarisRestCatalogIntegrationTest;

@QuarkusTest
public class QuarkusRestCatalogIntegrationTest extends PolarisRestCatalogIntegrationTest {}
@TestProfile(QuarkusRestCatalogIntegrationTest.Profile.class)
public class QuarkusRestCatalogIntegrationTest extends PolarisRestCatalogIntegrationTest {

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of(
"polaris.features.defaults.\"ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING\"", "false");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,29 @@
package org.apache.polaris.service.quarkus.it;

import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.Map;
import org.apache.iceberg.view.ViewCatalogTests;
import org.apache.polaris.service.it.test.PolarisRestCatalogViewAwsIntegrationTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;

@QuarkusTest
@TestProfile(QuarkusRestCatalogViewAwsIntegrationTest.Profile.class)
public class QuarkusRestCatalogViewAwsIntegrationTest
extends PolarisRestCatalogViewAwsIntegrationTest {

public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of("polaris.features.defaults.\"SUPPORTED_CATALOG_STORAGE_TYPES\"", "[\"S3\"]");
}
}

@BeforeEach
public void setUpTempDir(@TempDir Path tempDir) throws Exception {
// see https://github.com/quarkusio/quarkus/issues/13261
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,27 @@
package org.apache.polaris.service.quarkus.it;

import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.Map;
import org.apache.iceberg.view.ViewCatalogTests;
import org.apache.polaris.service.it.test.PolarisRestCatalogViewAzureIntegrationTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;

@QuarkusTest
@TestProfile(QuarkusRestCatalogViewAzureIntegrationTest.Profile.class)
public class QuarkusRestCatalogViewAzureIntegrationTest
extends PolarisRestCatalogViewAzureIntegrationTest {
public static class Profile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of("polaris.features.defaults.\"SUPPORTED_CATALOG_STORAGE_TYPES\"", "[\"AZURE\"]");
}
}

@BeforeEach
public void setUpTempDir(@TempDir Path tempDir) throws Exception {
Expand Down
Loading

0 comments on commit 11792d5

Please sign in to comment.