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

Move static config in modules to constructor #2473

Merged
merged 1 commit into from Apr 11, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -26,10 +26,7 @@ public ClickHouseContainer() {

public ClickHouseContainer(String dockerImageName) {
super(dockerImageName);
}

@Override
protected void configure() {
withExposedPorts(HTTP_PORT, NATIVE_PORT);
waitingFor(
new HttpWaitStrategy()
Expand Down
Expand Up @@ -37,6 +37,8 @@ public Db2Container(String imageName) {
this.waitStrategy = new LogMessageWaitStrategy()
.withRegEx(".*Setup has completed\\..*")
.withStartupTimeout(Duration.of(10, ChronoUnit.MINUTES));

addExposedPort(DB2_PORT);
}

@Override
Expand All @@ -52,8 +54,6 @@ protected void configure() {
acceptLicense();
}

addExposedPort(DB2_PORT);

addEnv("DBNAME", databaseName);
addEnv("DB2INSTANCE", username);
addEnv("DB2INST1_PASSWORD", password);
Expand Down
Expand Up @@ -36,12 +36,12 @@ public InfluxDBContainer(final String version) {
waitStrategy = new WaitAllStrategy()
.withStrategy(Wait.forHttp("/ping").withBasicCredentials(username, password).forStatusCode(204))
.withStrategy(Wait.forListeningPort());

addExposedPort(INFLUXDB_PORT);
}

@Override
protected void configure() {
addExposedPort(INFLUXDB_PORT);

addEnv("INFLUXDB_ADMIN_USER", admin);
addEnv("INFLUXDB_ADMIN_PASSWORD", adminPassword);

Expand Down
Expand Up @@ -24,6 +24,7 @@ public MariaDBContainer() {

public MariaDBContainer(String dockerImageName) {
super(dockerImageName);
addExposedPort(MARIADB_PORT);
}

@Override
Expand All @@ -35,7 +36,6 @@ protected Integer getLivenessCheckPort() {
protected void configure() {
optionallyMapResourceParameterAsVolume(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, "/etc/mysql/conf.d", "mariadb-default-conf");

addExposedPort(MARIADB_PORT);
addEnv("MYSQL_DATABASE", databaseName);
addEnv("MYSQL_USER", username);
if (password != null && !password.isEmpty()) {
Expand Down Expand Up @@ -83,7 +83,7 @@ public SELF withConfigurationOverride(String s) {
parameters.put(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, s);
return self();
}

@Override
public SELF withDatabaseName(final String databaseName) {
this.databaseName = databaseName;
Expand Down
Expand Up @@ -36,6 +36,7 @@ public MSSQLServerContainer(final String dockerImageName) {
super(dockerImageName);
withStartupTimeoutSeconds(DEFAULT_STARTUP_TIMEOUT_SECONDS);
withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS);
addExposedPort(MS_SQL_SERVER_PORT);
}

@Override
Expand All @@ -45,11 +46,8 @@ protected Integer getLivenessCheckPort() {

@Override
protected void configure() {
addExposedPort(MS_SQL_SERVER_PORT);

LicenseAcceptance.assertLicenseAccepted(this.getDockerImageName());
addEnv("ACCEPT_EULA", "Y");

addEnv("SA_PASSWORD", password);
}

Expand Down
Expand Up @@ -27,6 +27,7 @@ public MySQLContainer() {

public MySQLContainer(String dockerImageName) {
super(dockerImageName);
addExposedPort(MYSQL_PORT);
}

@NotNull
Expand All @@ -40,7 +41,6 @@ protected void configure() {
optionallyMapResourceParameterAsVolume(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, "/etc/mysql/conf.d",
"mysql-default-conf");

addExposedPort(MYSQL_PORT);
addEnv("MYSQL_DATABASE", databaseName);
addEnv("MYSQL_USER", username);
if (password != null && !password.isEmpty()) {
Expand Down
Expand Up @@ -87,6 +87,8 @@ public Neo4jContainer(String dockerImageName) {
.withStrategy(waitForBolt)
.withStrategy(waitForHttp)
.withStartupTimeout(Duration.ofMinutes(2));

addExposedPorts(DEFAULT_BOLT_PORT, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT);
}

@Override
Expand All @@ -100,8 +102,6 @@ public Set<Integer> getLivenessCheckPortNumbers() {
@Override
protected void configure() {

addExposedPorts(DEFAULT_BOLT_PORT, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT);

boolean emptyAdminPassword = this.adminPassword == null || this.adminPassword.isEmpty();
String neo4jAuth = emptyAdminPassword ? "none" : String.format(AUTH_FORMAT, this.adminPassword);
addEnv("NEO4J_AUTH", neo4jAuth);
Expand Down
Expand Up @@ -16,7 +16,14 @@ public class NginxContainer<SELF extends NginxContainer<SELF>> extends GenericCo
private static final int NGINX_DEFAULT_PORT = 80;

public NginxContainer() {
super("nginx:1.9.4");
this("nginx:1.9.4");
}

public NginxContainer(String dockerImageName) {
super(dockerImageName);

addExposedPort(NGINX_DEFAULT_PORT);
setCommand("nginx", "-g", "daemon off;");
}

@NotNull
Expand All @@ -25,12 +32,6 @@ protected Set<Integer> getLivenessCheckPorts() {
return Collections.singleton(getMappedPort(80));
}

@Override
protected void configure() {
addExposedPort(NGINX_DEFAULT_PORT);
setCommand("nginx", "-g", "daemon off;");
}

public URL getBaseUrl(String scheme, int port) throws MalformedURLException {
return new URL(scheme + "://" + getContainerIpAddress() + ":" + getMappedPort(port));
}
Expand Down
Expand Up @@ -46,18 +46,14 @@ public OracleContainer(Future<String> dockerImageName) {
super(dockerImageName);
withStartupTimeoutSeconds(DEFAULT_STARTUP_TIMEOUT_SECONDS);
withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS);
addExposedPorts(ORACLE_PORT, APEX_HTTP_PORT);
}

@Override
protected Integer getLivenessCheckPort() {
return getMappedPort(ORACLE_PORT);
}

@Override
protected void configure() {
addExposedPorts(ORACLE_PORT, APEX_HTTP_PORT);
}

@Override
public String getDriverClassName() {
return "oracle.jdbc.OracleDriver";
Expand Down
Expand Up @@ -66,11 +66,12 @@ public OrientDBContainer(@NonNull String dockerImageName) {
.withStrategy(Wait.forListeningPort())
.withStrategy(waitForHttp)
.withStartupTimeout(Duration.ofMinutes(2));

addExposedPorts(DEFAULT_BINARY_PORT, DEFAULT_HTTP_PORT);
}

@Override
protected void configure() {
addExposedPorts(DEFAULT_BINARY_PORT, DEFAULT_HTTP_PORT);
addEnv("ORIENTDB_ROOT_PASSWORD", serverPassword);
}

Expand Down
Expand Up @@ -38,6 +38,8 @@ public PostgreSQLContainer(final String dockerImageName) {
.withTimes(2)
.withStartupTimeout(Duration.of(60, SECONDS));
this.setCommand("postgres", "-c", FSYNC_OFF_OPTION);

addExposedPort(POSTGRESQL_PORT);
}

@NotNull
Expand All @@ -48,7 +50,6 @@ protected Set<Integer> getLivenessCheckPorts() {

@Override
protected void configure() {
addExposedPort(POSTGRESQL_PORT);
addEnv("POSTGRES_DB", databaseName);
addEnv("POSTGRES_USER", username);
addEnv("POSTGRES_PASSWORD", password);
Expand Down
Expand Up @@ -32,6 +32,8 @@ public PrestoContainer(final String dockerImageName) {
this.waitStrategy = new LogMessageWaitStrategy()
.withRegEx(".*io.prestosql.server.PrestoServer\\s+======== SERVER STARTED ========.*")
.withStartupTimeout(Duration.of(60, SECONDS));

addExposedPort(PRESTO_PORT);
}

@NotNull
Expand All @@ -40,11 +42,6 @@ protected Set<Integer> getLivenessCheckPorts() {
return new HashSet<>(getMappedPort(PRESTO_PORT));
}

@Override
protected void configure() {
addExposedPort(PRESTO_PORT);
}

@Override
public String getDriverClassName() {
return "io.prestosql.jdbc.PrestoDriver";
Expand Down