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

MINOR: make test setup non-static so it can be overriden #15451

Merged
merged 7 commits into from
Mar 6, 2024
Merged
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 @@ -35,6 +35,7 @@
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.sqlobject.SqlObjectPlugin;
import org.jdbi.v3.sqlobject.SqlObjects;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
Expand All @@ -61,7 +62,7 @@ public abstract class OpenMetadataApplicationTest {

public static final boolean RUN_ELASTIC_SEARCH_TESTCASES = false;

private static final Set<ConfigOverride> configOverrides = new HashSet<>();
protected static final Set<ConfigOverride> configOverrides = new HashSet<>();

private static final String JDBC_CONTAINER_CLASS_NAME =
"org.testcontainers.containers.MySQLContainer";
Expand All @@ -80,7 +81,7 @@ public abstract class OpenMetadataApplicationTest {
}

@BeforeAll
public static void createApplication() throws Exception {
public void createApplication() throws Exception {
String jdbcContainerClassName = System.getProperty("jdbcContainerClassName");
String jdbcContainerImage = System.getProperty("jdbcContainerImage");
String elasticSearchContainerImage = System.getProperty("elasticSearchContainerClassName");
Expand Down Expand Up @@ -155,9 +156,7 @@ public static void createApplication() throws Exception {
ConfigOverride.config("migrationConfiguration.nativePath", nativeMigrationScriptsLocation));

ConfigOverride[] configOverridesArray = configOverrides.toArray(new ConfigOverride[0]);
APP =
new DropwizardAppExtension<>(
OpenMetadataApplication.class, CONFIG_PATH, configOverridesArray);
APP = getApp(configOverridesArray);
// Run System Migrations
jdbi =
Jdbi.create(
Expand All @@ -176,6 +175,13 @@ public static void createApplication() throws Exception {
createClient();
}

@NotNull
protected DropwizardAppExtension<OpenMetadataApplicationConfig> getApp(
ConfigOverride[] configOverridesArray) {
return new DropwizardAppExtension<>(
OpenMetadataApplication.class, CONFIG_PATH, configOverridesArray);
}

private static void createClient() {
ClientConfig config = new ClientConfig();
config.connectorProvider(new JettyConnectorProvider());
Expand All @@ -187,7 +193,7 @@ private static void createClient() {
}

@AfterAll
public static void stopApplication() throws Exception {
public void stopApplication() throws Exception {
// If BeforeAll causes and exception AfterAll still gets called before that exception is thrown.
// If a NullPointerException is thrown during the cleanup of above it will eat the initial error
if (APP != null) {
Expand Down
Loading