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 with `QuarkusTestProfile`.
  • Loading branch information
adutra committed Jan 22, 2025
1 parent 4eee4fe commit 3491e5f
Show file tree
Hide file tree
Showing 25 changed files with 275 additions and 41 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ tasks.named<RatTask>("rat").configure {
excludes.add("logs/**")
excludes.add("service/common/src/**/banner.txt")
excludes.add("quarkus/service/logs")
excludes.add("quarkus/server/logs")
excludes.add("quarkus/admin/logs")

excludes.add("site/node_modules/**")
excludes.add("site/layouts/robots.txt")
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Polaris Integration Tests

## Overview

This module contains integration tests for Polaris. These tests are designed as black box tests
that can be run against a local or remote Polaris instance.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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 configured:
* <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
* configured:
* <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
* configured:
* <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
42 changes: 42 additions & 0 deletions quarkus/defaults/src/main/resources/application-it.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# 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.
#

# Configuration common to ALL integration tests (executed with "it" profile).
# Note: Quarkus integration tests cannot use QuarkusTestProfile

quarkus.http.limits.max-body-size=1000000
quarkus.http.port=0

quarkus.management.port=0

polaris.persistence.type=in-memory

polaris.features.defaults."ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING"=false
polaris.features.defaults."ALLOW_EXTERNAL_METADATA_FILE_LOCATION"=false
polaris.features.defaults."ALLOW_OVERLAPPING_CATALOG_URLS"=true
polaris.features.defaults."ALLOW_SPECIFYING_FILE_IO_IMPL"=true
polaris.features.defaults."ALLOW_WILDCARD_LOCATION"=true
polaris.features.defaults."ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING"=true
polaris.features.defaults."INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_it"=true
polaris.features.defaults."SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION"=true
polaris.features.defaults."SUPPORTED_CATALOG_STORAGE_TYPES"=["FILE","S3","GCS","AZURE"]

polaris.storage.gcp.token=token
polaris.storage.gcp.lifespan=PT1H

24 changes: 24 additions & 0 deletions quarkus/defaults/src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# 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.
#

# Configuration common to ALL unit tests (executed with "test" profile).
# Per-test specific configuration should use QuarkusTestProfile

quarkus.log.file.enable=false
quarkus.otel.sdk.disabled=true
35 changes: 2 additions & 33 deletions quarkus/defaults/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 @@ -119,34 +119,3 @@ polaris.authentication.token-broker.max-token-generation=PT1H
# polaris.storage.aws.secret-key=secretKey
# polaris.storage.gcp.token=token
# polaris.storage.gcp.lifespan=PT1H

%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
# Need to allow a java security manager after Java 21, for Subject.getSubject to work
# "getSubject is supported only if a security manager is allowed".
%test.quarkus.test.argLine=-Djava.security.manager=allow
7 changes: 6 additions & 1 deletion quarkus/service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ tasks.withType(Test::class.java).configureEach {

tasks.named<Test>("test").configure { maxParallelForks = 4 }

tasks.named<Test>("intTest").configure { maxParallelForks = 1 }
tasks.named<Test>("intTest").configure {
maxParallelForks = 1
// Same issue as above: allow a java security manager after Java 21
// (this setting is for the application under test, while the setting above is for test code).
systemProperty("quarkus.test.arg-line", "-Djava.security.manager=allow")
}

/**
* Adds the JPMS options required for Spark to run on Java 17, taken from the
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
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 @@ -24,6 +24,8 @@
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
Expand All @@ -37,8 +39,20 @@
import org.junit.jupiter.api.Test;

@QuarkusTest
@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");
}
}

@Test
public void testIcebergRestApiRefreshToken(
PolarisApiEndpoints endpoints, ClientCredentials clientCredentials) throws IOException {
Expand Down
Loading

0 comments on commit 3491e5f

Please sign in to comment.