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

Update oracle wait strategy for Healthcheck #2931

Closed
Closed
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
@@ -1,9 +1,8 @@
package org.testcontainers.containers;

import com.google.common.collect.Sets;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

import java.time.Duration;
Expand All @@ -25,6 +24,7 @@ public class OracleContainer extends JdbcDatabaseContainer<OracleContainer> {

private static final int ORACLE_PORT = 1521;
private static final int APEX_HTTP_PORT = 8080;
private static final int OEM_EXPRESS_PORT = 5500;

private static final int DEFAULT_STARTUP_TIMEOUT_SECONDS = 240;
private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 120;
Expand All @@ -34,7 +34,7 @@ public class OracleContainer extends JdbcDatabaseContainer<OracleContainer> {
static final String DEFAULT_SID = "xe";
static final String DEFAULT_SYSTEM_USER = "system";
static final String DEFAULT_SYS_USER = "sys";

// Test container defaults
static final String APP_USER = "test";
static final String APP_USER_PASSWORD = "test";
Expand Down Expand Up @@ -71,13 +71,10 @@ public OracleContainer(Future<String> dockerImageName) {
}

private void preconfigure() {
this.waitStrategy = new LogMessageWaitStrategy()
.withRegEx(".*DATABASE IS READY TO USE!.*\\s")
.withTimes(1)
.withStartupTimeout(Duration.of(DEFAULT_STARTUP_TIMEOUT_SECONDS, SECONDS));

this.waitStrategy = Wait.forHealthcheck()
.withStartupTimeout(Duration.of(DEFAULT_STARTUP_TIMEOUT_SECONDS, SECONDS));
withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS);
addExposedPorts(ORACLE_PORT, APEX_HTTP_PORT);
addExposedPorts(ORACLE_PORT, APEX_HTTP_PORT, OEM_EXPRESS_PORT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding OEM_EXPRESS_PORT is not really necessary for this PR, isn't it?

}

@Override
Expand All @@ -98,7 +95,7 @@ public String getDriverClassName() {

@Override
public String getJdbcUrl() {
return isUsingSid() ?
return isUsingSid() ?
"jdbc:oracle:thin:" + "@" + getHost() + ":" + getOraclePort() + ":" + getSid() :
"jdbc:oracle:thin:" + "@" + getHost() + ":" + getOraclePort() + "/" + getDatabaseName();
}
Expand Down Expand Up @@ -195,7 +192,7 @@ protected void configure() {
if(databaseName != DEFAULT_DATABASE_NAME) {
withEnv("ORACLE_DATABASE", databaseName);
}

withEnv("APP_USER", username);
withEnv("APP_USER_PASSWORD", password);
}
Expand Down