From eab9385952d1a831f78a8f1e2bc8208eeef1d4c3 Mon Sep 17 00:00:00 2001 From: "Hufschmidt, Stefan" Date: Wed, 13 Jun 2018 09:47:06 +0200 Subject: [PATCH 1/2] Added builder for timeouts in JdbcDatabaseContainer (#715) --- .../containers/JdbcDatabaseContainer.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java index 140aaa7dde3..49879017baa 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java +++ b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java @@ -33,6 +33,9 @@ public abstract class JdbcDatabaseContainer Date: Wed, 13 Jun 2018 11:27:15 +0200 Subject: [PATCH 2/2] Adjusted Oracle and SQL Server to use other default timeouts (#715) --- .../containers/JdbcDatabaseContainer.java | 4 ++++ .../containers/MSSQLServerContainer.java | 5 +++++ .../containers/OracleContainer.java | 15 ++++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java index 49879017baa..77589395c19 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java +++ b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java @@ -213,14 +213,18 @@ public void addParameter(String paramName, String value) { /** * @return startup time to allow, including image pull time, in seconds + * @deprecated should not be overridden anymore, use {@link #withStartupTimeoutSeconds(int)} in constructor instead */ + @Deprecated protected int getStartupTimeoutSeconds() { return startupTimeoutSeconds; } /** * @return time to allow for the database to start and establish an initial connection, in seconds + * @deprecated should not be overridden anymore, use {@link #withConnectTimeoutSeconds(int)} in constructor instead */ + @Deprecated protected int getConnectTimeoutSeconds() { return connectTimeoutSeconds; } diff --git a/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java b/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java index a308560aeb3..2ab5181bc9e 100644 --- a/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java +++ b/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java @@ -14,12 +14,17 @@ public class MSSQLServerContainer> exten private String username = "SA"; private String password = "A_Str0ng_Required_Password"; + private static final int DEFAULT_STARTUP_TIMEOUT_SECONDS = 240; + private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 240; + public MSSQLServerContainer() { this(IMAGE + ":" + DEFAULT_TAG); } public MSSQLServerContainer(final String dockerImageName) { super(dockerImageName); + withStartupTimeoutSeconds(DEFAULT_STARTUP_TIMEOUT_SECONDS); + withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS); } @Override diff --git a/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainer.java b/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainer.java index 375efa27176..c28c2ba82af 100644 --- a/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainer.java +++ b/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainer.java @@ -14,6 +14,9 @@ public class OracleContainer extends JdbcDatabaseContainer { private static final int ORACLE_PORT = 1521; private static final int APEX_HTTP_PORT = 8080; + private static final int DEFAULT_STARTUP_TIMEOUT_SECONDS = 240; + private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 120; + private static String resolveImageName() { String image = TestcontainersConfiguration.getInstance() .getProperties().getProperty("oracle.container.image"); @@ -27,15 +30,19 @@ private static String resolveImageName() { } public OracleContainer() { - super(resolveImageName()); + this(resolveImageName()); } public OracleContainer(String dockerImageName) { super(dockerImageName); + withStartupTimeoutSeconds(DEFAULT_STARTUP_TIMEOUT_SECONDS); + withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS); } public OracleContainer(Future dockerImageName) { super(dockerImageName); + withStartupTimeoutSeconds(DEFAULT_STARTUP_TIMEOUT_SECONDS); + withConnectTimeoutSeconds(DEFAULT_CONNECT_TIMEOUT_SECONDS); } @Override @@ -45,7 +52,6 @@ protected Integer getLivenessCheckPort() { @Override protected void configure() { - addExposedPorts(ORACLE_PORT, APEX_HTTP_PORT); } @@ -87,9 +93,4 @@ public Integer getWebPort() { public String getTestQueryString() { return "SELECT 1 FROM DUAL"; } - - @Override - protected int getStartupTimeoutSeconds() { - return 240; - } }