Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-502] refactor test #504

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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 @@ -21,32 +21,23 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import org.apache.polaris.extension.persistence.impl.eclipselink.EclipseLinkPolarisMetaStoreManagerFactory;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory;
import org.apache.polaris.service.test.PolarisApplicationUtils;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith(DropwizardExtensionsSupport.class)
public class PolarisApplicationConfigurationTest {

public static final String CONFIG_PATH =
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml");
// Bind to random ports to support parallelism
public static final ConfigOverride RANDOM_APP_PORT =
ConfigOverride.config("server.applicationConnectors[0].port", "0");
public static final ConfigOverride RANDOM_ADMIN_PORT =
ConfigOverride.config("server.adminConnectors[0].port", "0");

@Nested
class DefaultMetastore {
private final DropwizardAppExtension<PolarisApplicationConfig> app =
new DropwizardAppExtension<>(
PolarisApplication.class, CONFIG_PATH, RANDOM_APP_PORT, RANDOM_ADMIN_PORT);
PolarisApplicationUtils.createTestPolarisApplication();

@Test
void testMetastoreType() {
Expand All @@ -58,11 +49,7 @@ void testMetastoreType() {
@Nested
class EclipseLinkMetastore {
private final DropwizardAppExtension<PolarisApplicationConfig> app =
new DropwizardAppExtension<>(
PolarisApplication.class,
CONFIG_PATH,
RANDOM_APP_PORT,
RANDOM_ADMIN_PORT,
PolarisApplicationUtils.createTestPolarisApplication(
ConfigOverride.config("metaStoreManager.type", "eclipse-link"),
ConfigOverride.config("metaStoreManager.persistence-unit", "test-unit"),
ConfigOverride.config("metaStoreManager.conf-file", "/test-conf-file"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.ProcessingException;
Expand Down Expand Up @@ -81,10 +79,7 @@
import org.apache.polaris.core.entity.PolarisEntityConstants;
import org.apache.polaris.service.auth.BasePolarisAuthenticator;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.SnowmanCredentialsExtension;
import org.apache.polaris.service.test.TestEnvironmentExtension;
import org.apache.polaris.service.test.*;
import org.apache.polaris.service.throttling.RequestThrottlingErrorResponse;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.InstanceOfAssertFactories;
Expand All @@ -110,14 +105,7 @@ public class PolarisApplicationIntegrationTest {

public static final String PRINCIPAL_ROLE_NAME = "admin";
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config(
"server.adminConnectors[0].port", "0")); // Bind to random port to support parallelism
PolarisApplicationUtils.createTestPolarisApplication();

private static String userToken;
private static SnowmanCredentialsExtension.SnowmanCredentials snowmanCredentials;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import static org.apache.polaris.service.TimedApplicationEventListener.TAG_API_NAME;
import static org.apache.polaris.service.context.DefaultContextResolver.REALM_PROPERTY_KEY;

import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import io.micrometer.core.instrument.Tag;
Expand All @@ -37,11 +35,7 @@
import org.apache.polaris.core.resource.TimedApi;
import org.apache.polaris.service.admin.api.PolarisPrincipalsApi;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.SnowmanCredentialsExtension;
import org.apache.polaris.service.test.TestEnvironmentExtension;
import org.apache.polaris.service.test.TestMetricsUtil;
import org.apache.polaris.service.test.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -56,14 +50,7 @@
})
public class TimedApplicationEventListenerTest {
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config(
"server.adminConnectors[0].port", "0")); // Bind to random port to support parallelism
PolarisApplicationUtils.createTestPolarisApplication();

private static final int ERROR_CODE = Response.Status.NOT_FOUND.getStatusCode();
private static final String ENDPOINT = "api/management/v1/principals";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.client.Entity;
Expand All @@ -41,8 +40,8 @@
import org.apache.polaris.core.admin.model.CreateCatalogRequest;
import org.apache.polaris.core.admin.model.FileStorageConfigInfo;
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.service.PolarisApplication;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisApplicationUtils;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.TestEnvironmentExtension;
Expand All @@ -59,23 +58,13 @@
})
public class PolarisOverlappingTableTest {
private static final DropwizardAppExtension<PolarisApplicationConfig> BASE_EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
// Bind to random port to support parallelism
ConfigOverride.config("server.applicationConnectors[0].port", "0"),
ConfigOverride.config("server.adminConnectors[0].port", "0"),
PolarisApplicationUtils.createTestPolarisApplication(
// Enforce table location constraints
ConfigOverride.config("featureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION", "false"),
ConfigOverride.config("featureConfiguration.ALLOW_TABLE_LOCATION_OVERLAP", "false"));

private static final DropwizardAppExtension<PolarisApplicationConfig> LAX_EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
// Bind to random port to support parallelism
ConfigOverride.config("server.applicationConnectors[0].port", "0"),
ConfigOverride.config("server.adminConnectors[0].port", "0"),
PolarisApplicationUtils.createTestPolarisApplication(
// Relax table location constraints
ConfigOverride.config("featureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION", "true"),
ConfigOverride.config("featureConfiguration.ALLOW_TABLE_LOCATION_OVERLAP", "true"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.client.Entity;
Expand Down Expand Up @@ -86,10 +85,10 @@
import org.apache.polaris.core.admin.model.UpdatePrincipalRoleRequest;
import org.apache.polaris.core.entity.PolarisEntityConstants;
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
import org.apache.polaris.service.PolarisApplication;
import org.apache.polaris.service.auth.BasePolarisAuthenticator;
import org.apache.polaris.service.auth.TokenUtils;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisApplicationUtils;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.TestEnvironmentExtension;
Expand Down Expand Up @@ -118,19 +117,13 @@ public class PolarisServiceImplIntegrationTest {
// slate on every test case; otherwise, leftover state from one test from failures will interfere
// with other test cases.
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config("server.adminConnectors[0].port", "0"),

PolarisApplicationUtils.createTestPolarisApplication(
// disallow FILE urls for the sake of tests below
ConfigOverride.config(
"featureConfiguration.SUPPORTED_CATALOG_STORAGE_TYPES", "S3,GCS,AZURE"),
ConfigOverride.config("gcp_credentials.access_token", "abc"),
ConfigOverride.config("gcp_credentials.expires_in", "12345"));

private static String userToken;
private static String realm;
private static String clientId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.google.common.collect.ImmutableMap;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.client.Entity;
Expand Down Expand Up @@ -79,15 +77,11 @@
import org.apache.polaris.core.admin.model.ViewPrivilege;
import org.apache.polaris.core.entity.CatalogEntity;
import org.apache.polaris.core.entity.PolarisEntityConstants;
import org.apache.polaris.service.PolarisApplication;
import org.apache.polaris.service.auth.TokenUtils;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.*;
import org.apache.polaris.service.test.PolarisConnectionExtension.PolarisToken;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.SnowmanCredentialsExtension;
import org.apache.polaris.service.test.SnowmanCredentialsExtension.SnowmanCredentials;
import org.apache.polaris.service.test.TestEnvironmentExtension;
import org.apache.polaris.service.types.NotificationRequest;
import org.apache.polaris.service.types.NotificationType;
import org.apache.polaris.service.types.TableUpdateNotification;
Expand Down Expand Up @@ -117,14 +111,7 @@ public class PolarisRestCatalogIntegrationTest extends CatalogTests<RESTCatalog>
Optional.ofNullable(System.getenv("INTEGRATION_TEST_S3_PATH"))
.orElse("file:///tmp/buckets/my-bucket");
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config(
"server.adminConnectors[0].port", "0")); // Bind to random port to support parallelism
PolarisApplicationUtils.createTestPolarisApplication();

protected static final String VIEW_QUERY = "select * from ns1.layer1_table";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import static org.apache.polaris.service.context.DefaultContextResolver.REALM_PROPERTY_KEY;

import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.core.Response;
Expand All @@ -34,15 +32,10 @@
import org.apache.polaris.core.admin.model.PolarisCatalog;
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.core.entity.CatalogEntity;
import org.apache.polaris.service.PolarisApplication;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.*;
import org.apache.polaris.service.test.PolarisConnectionExtension.PolarisToken;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.SnowmanCredentialsExtension;
import org.apache.polaris.service.test.SnowmanCredentialsExtension.SnowmanCredentials;
import org.apache.polaris.service.test.TestEnvironment;
import org.apache.polaris.service.test.TestEnvironmentExtension;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -61,14 +54,7 @@
})
public abstract class PolarisRestCatalogViewIntegrationTest extends ViewCatalogTests<RESTCatalog> {
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config(
"server.adminConnectors[0].port", "0")); // Bind to random port to support parallelism
PolarisApplicationUtils.createTestPolarisApplication();

private RESTCatalog restCatalog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.adobe.testing.s3mock.testcontainers.S3MockContainer;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.client.Entity;
Expand All @@ -41,8 +39,8 @@
import org.apache.polaris.core.admin.model.ExternalCatalog;
import org.apache.polaris.core.admin.model.PolarisCatalog;
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.service.PolarisApplication;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.test.PolarisApplicationUtils;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.TestEnvironmentExtension;
Expand All @@ -68,14 +66,7 @@
})
public class PolarisSparkIntegrationTest {
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config(
"server.adminConnectors[0].port", "0")); // Bind to random port to support parallelism
PolarisApplicationUtils.createTestPolarisApplication();

public static final String CATALOG_NAME = "mycatalog";
public static final String EXTERNAL_CATALOG_NAME = "external_catalog";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.cloud.storage.StorageException;
import com.google.common.collect.Iterators;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import java.util.Collection;
Expand All @@ -51,14 +50,10 @@
import org.apache.polaris.core.admin.model.FileStorageConfigInfo;
import org.apache.polaris.core.admin.model.PolarisCatalog;
import org.apache.polaris.core.admin.model.StorageConfigInfo;
import org.apache.polaris.service.PolarisApplication;
import org.apache.polaris.service.catalog.TestUtil;
import org.apache.polaris.service.config.PolarisApplicationConfig;
import org.apache.polaris.service.exception.IcebergExceptionMapper;
import org.apache.polaris.service.test.PolarisConnectionExtension;
import org.apache.polaris.service.test.PolarisRealm;
import org.apache.polaris.service.test.SnowmanCredentialsExtension;
import org.apache.polaris.service.test.TestEnvironmentExtension;
import org.apache.polaris.service.test.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -76,13 +71,7 @@
})
public class FileIOIntegrationTest {
private static final DropwizardAppExtension<PolarisApplicationConfig> EXT =
new DropwizardAppExtension<>(
PolarisApplication.class,
ResourceHelpers.resourceFilePath("polaris-server-integrationtest.yml"),
ConfigOverride.config(
"server.applicationConnectors[0].port",
"0"), // Bind to random port to support parallelism
ConfigOverride.config("server.adminConnectors[0].port", "0"),
PolarisApplicationUtils.createTestPolarisApplication(
ConfigOverride.config("io.factoryType", "test"));

private static final String catalogBaseLocation = "file:/tmp/buckets/my-bucket/path/to/data";
Expand Down
Loading
Loading