From bead0b3bbd93aeb5b53e1187ba8037b005400d21 Mon Sep 17 00:00:00 2001 From: Richard North Date: Sun, 29 Apr 2018 13:36:29 +0100 Subject: [PATCH] Pin tags (#671) * Pin tags where it makes sense to do so * Update changelog and docs * Use fixed tag names for JDBC URLs when none specified (equivalent to current 'latest') --- CHANGELOG.md | 1 + .../strategy/AbstractWaitStrategyTest.java | 2 +- .../strategy/HostPortWaitStrategyTest.java | 2 +- docs/usage/database_containers.md | 23 ++++++------------- .../jdbc/DatabaseDriverShutdownTest.java | 4 ++-- .../testcontainers/jdbc/JDBCDriverTest.java | 22 +++++++++--------- .../junit/CustomizablePostgreSQLTest.java | 2 +- .../container-license-acceptance.txt | 2 +- .../JdbcDatabaseContainerProvider.java | 10 ++++++++ .../jdbc/ContainerDatabaseDriver.java | 10 ++++---- .../containers/MariaDBContainer.java | 8 ++++--- .../containers/MariaDBContainerProvider.java | 5 ++++ .../containers/MSSQLServerContainer.java | 8 ++++--- .../MSSQLServerContainerProvider.java | 5 ++++ .../containers/MySQLContainer.java | 4 +++- .../containers/MySQLContainerProvider.java | 5 ++++ .../containers/OracleContainerProvider.java | 8 +++++-- .../containers/PostgreSQLContainer.java | 8 ++++--- .../PostgreSQLContainerProvider.java | 5 ++++ 19 files changed, 85 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa17a04ad6..a0c2cb9ba12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. - Retry any exceptions (not just `DockerClientException`) on image pull ([\#662](https://github.com/testcontainers/testcontainers-java/issues/662)) ### Changed +- Database container images are now pinned to a specific version rather than using `latest`. The tags selected are the most recent as of the time of this change. If a JDBC URL is used with no tag specified, a WARN level log message is output, pending a future change to make tags mandatory in the JDBC URL. ([\#671](https://github.com/testcontainers/testcontainers-java/issues/671)) ## [1.7.1] - 2018-04-20 diff --git a/core/src/test/java/org/testcontainers/junit/wait/strategy/AbstractWaitStrategyTest.java b/core/src/test/java/org/testcontainers/junit/wait/strategy/AbstractWaitStrategyTest.java index c6216f0b184..574cef5e2df 100644 --- a/core/src/test/java/org/testcontainers/junit/wait/strategy/AbstractWaitStrategyTest.java +++ b/core/src/test/java/org/testcontainers/junit/wait/strategy/AbstractWaitStrategyTest.java @@ -20,7 +20,7 @@ */ public abstract class AbstractWaitStrategyTest { static final long WAIT_TIMEOUT_MILLIS = 3000; - static final String IMAGE_NAME = "alpine:latest"; + static final String IMAGE_NAME = "alpine:3.7"; /** * Indicates that the WaitStrategy has completed waiting successfully. diff --git a/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java b/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java index 840d8864a9b..d715b25aaf6 100644 --- a/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java +++ b/core/src/test/java/org/testcontainers/junit/wait/strategy/HostPortWaitStrategyTest.java @@ -15,7 +15,7 @@ */ public class HostPortWaitStrategyTest { - private static final String IMAGE_NAME = "alpine:latest"; + private static final String IMAGE_NAME = "alpine:3.7"; @ClassRule public static GenericContainer container = new GenericContainer(IMAGE_NAME).withExposedPorts() diff --git a/docs/usage/database_containers.md b/docs/usage/database_containers.md index e67c97cc7e8..95e85bad3de 100644 --- a/docs/usage/database_containers.md +++ b/docs/usage/database_containers.md @@ -53,17 +53,17 @@ _N.B:_ * _TC needs to be on your application's classpath at runtime for this to work_ * _For Spring Boot you need to specify the driver manually `spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver`_ -**Original URL**: `jdbc:mysql://somehostname:someport/databasename` +**Original URL**: `jdbc:mysql:5.7.22://somehostname:someport/databasename` Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database name will be ignored; you can leave these as-is or set them to any value. ### JDBC URL examples -#### Simple Testcontainers JDBC driver usage +#### DEPRECATED: Simple Testcontainers JDBC driver usage `jdbc:tc:mysql://somehostname:someport/databasename` -*(Note: this will use the latest version of MySQL)* +*(Note: this will use a fixed version of the database. You should typically specify the version you desire via a tag parameter, as below).* #### Using Testcontainers with a fixed version @@ -71,14 +71,14 @@ Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database #### Using PostgreSQL -`jdbc:tc:postgresql://hostname/databasename` +`jdbc:tc:postgresql:9.6.8://hostname/databasename` ## Using an init script Testcontainers can run an initscript after the database container is started, but before your code is given a connection to it. The script must be on the classpath, and is referenced as follows: -`jdbc:tc:mysql://hostname/databasename?TC_INITSCRIPT=somepath/init_mysql.sql` +`jdbc:tc:mysql:5.7.22://hostname/databasename?TC_INITSCRIPT=somepath/init_mysql.sql` This is useful if you have a fixed script for setting up database schema, etc. @@ -86,7 +86,7 @@ This is useful if you have a fixed script for setting up database schema, etc. Instead of running a fixed script for DB setup, it may be useful to call a Java function that you define. This is intended to allow you to trigger database schema migration tools. To do this, add TC_INITFUNCTION to the URL as follows, passing a full path to the class name and method: - `jdbc:tc:mysql://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction` + `jdbc:tc:mysql:5.7.22://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction` The init function must be a public static method which takes a `java.sql.Connection` as its only parameter, e.g. ```java @@ -101,7 +101,7 @@ public class JDBCDriverTest { By default database container is being stopped as soon as last connection is closed. There are cases when you might need to start container and keep it running till you stop it explicitly or JVM is shutdown. To do this, add `TC_DAEMON` parameter to the URL as follows: - `jdbc:tc:mysql://hostname/databasename?TC_DAEMON=true` + `jdbc:tc:mysql:5.7.22://hostname/databasename?TC_DAEMON=true` With this parameter database container will keep running even when there're no open connections. @@ -114,12 +114,3 @@ is a directory on the classpath containing .cnf files, the following URL can be Any .cnf files in this classpath directory will be mapped into the database container's /etc/mysql/conf.d directory, and will be able to override server settings when the container starts. - -### Additional Non-standard Methods - -#### Virtuoso SPARQL Service URL - -VirtuosoContainer provides access to the SPARQL service URL -```java -String sparqlServiceUrl = ((VirtuosoContainer)container).getSparqlUrl(); -``` diff --git a/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java b/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java index a6bfe756d10..855658ada56 100644 --- a/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java +++ b/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java @@ -23,7 +23,7 @@ public static void testCleanup() { @Test public void shouldStopContainerWhenAllConnectionsClosed() throws SQLException { - final String jdbcUrl = "jdbc:tc:postgresql://hostname/databasename"; + final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename"; getConnectionAndClose(jdbcUrl); @@ -33,7 +33,7 @@ public void shouldStopContainerWhenAllConnectionsClosed() throws SQLException { @Test public void shouldNotStopDaemonContainerWhenAllConnectionsClosed() throws SQLException { - final String jdbcUrl = "jdbc:tc:postgresql://hostname/databasename?TC_DAEMON=true"; + final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_DAEMON=true"; getConnectionAndClose(jdbcUrl); diff --git a/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/JDBCDriverTest.java b/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/JDBCDriverTest.java index eee537a4821..4ef75c2c516 100644 --- a/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/JDBCDriverTest.java +++ b/modules/jdbc-test/src/test/java/org/testcontainers/jdbc/JDBCDriverTest.java @@ -37,20 +37,20 @@ public class JDBCDriverTest { public static Iterable data() { return asList( new Object[][]{ - {"jdbc:tc:mysql:5.5.43://hostname/databasename", false, false, false}, - {"jdbc:tc:mysql://hostname/databasename?TC_INITSCRIPT=somepath/init_mysql.sql", true, false, false}, - {"jdbc:tc:mysql://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction", true, false, false}, - {"jdbc:tc:mysql://hostname/databasename?useUnicode=yes&characterEncoding=utf8", false, true, false}, {"jdbc:tc:mysql://hostname/databasename", false, false, false}, - {"jdbc:tc:mysql://hostname/databasename?useSSL=false", false, false, false}, - {"jdbc:tc:postgresql://hostname/databasename", false, false, false}, + {"jdbc:tc:mysql:5.5.43://hostname/databasename?TC_INITSCRIPT=somepath/init_mysql.sql", true, false, false}, + {"jdbc:tc:mysql:5.5.43://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction", true, false, false}, + {"jdbc:tc:mysql:5.5.43://hostname/databasename?useUnicode=yes&characterEncoding=utf8", false, true, false}, + {"jdbc:tc:mysql:5.5.43://hostname/databasename", false, false, false}, + {"jdbc:tc:mysql:5.5.43://hostname/databasename?useSSL=false", false, false, false}, + {"jdbc:tc:postgresql:9.6.8://hostname/databasename", false, false, false}, {"jdbc:tc:mysql:5.6://hostname/databasename?TC_MY_CNF=somepath/mysql_conf_override", false, false, true}, - {"jdbc:tc:mariadb:10.1.16://hostname/databasename", false, false, false}, {"jdbc:tc:mariadb://hostname/databasename", false, false, false}, - {"jdbc:tc:mariadb://hostname/databasename?useUnicode=yes&characterEncoding=utf8", false, true, false}, - {"jdbc:tc:mariadb://hostname/databasename?TC_INITSCRIPT=somepath/init_mariadb.sql", true, false, false}, - {"jdbc:tc:mariadb://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction", true, false, false}, - {"jdbc:tc:mariadb:10.1.16://hostname/databasename?TC_MY_CNF=somepath/mariadb_conf_override", false, false, true} + {"jdbc:tc:mariadb:10.2.14://hostname/databasename", false, false, false}, + {"jdbc:tc:mariadb:10.2.14://hostname/databasename?useUnicode=yes&characterEncoding=utf8", false, true, false}, + {"jdbc:tc:mariadb:10.2.14://hostname/databasename?TC_INITSCRIPT=somepath/init_mariadb.sql", true, false, false}, + {"jdbc:tc:mariadb:10.2.14://hostname/databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction", true, false, false}, + {"jdbc:tc:mariadb:10.2.14://hostname/databasename?TC_MY_CNF=somepath/mariadb_conf_override", false, false, true} }); } diff --git a/modules/jdbc-test/src/test/java/org/testcontainers/junit/CustomizablePostgreSQLTest.java b/modules/jdbc-test/src/test/java/org/testcontainers/junit/CustomizablePostgreSQLTest.java index 8180ae2a872..ef1c7b212db 100644 --- a/modules/jdbc-test/src/test/java/org/testcontainers/junit/CustomizablePostgreSQLTest.java +++ b/modules/jdbc-test/src/test/java/org/testcontainers/junit/CustomizablePostgreSQLTest.java @@ -21,7 +21,7 @@ public class CustomizablePostgreSQLTest { private static final String PWD = "baz"; @Rule - public PostgreSQLContainer postgres = new PostgreSQLContainer("postgres:latest") + public PostgreSQLContainer postgres = new PostgreSQLContainer("postgres:9.6.8") .withDatabaseName(DB_NAME) .withUsername(USER) .withPassword(PWD); diff --git a/modules/jdbc-test/src/test/resources/container-license-acceptance.txt b/modules/jdbc-test/src/test/resources/container-license-acceptance.txt index b0c43ef2bff..d706237de16 100644 --- a/modules/jdbc-test/src/test/resources/container-license-acceptance.txt +++ b/modules/jdbc-test/src/test/resources/container-license-acceptance.txt @@ -1 +1 @@ -microsoft/mssql-server-linux:latest +microsoft/mssql-server-linux:2017-CU6 diff --git a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainerProvider.java b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainerProvider.java index dda947b9dd4..aadc266f6f9 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainerProvider.java +++ b/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainerProvider.java @@ -1,11 +1,21 @@ package org.testcontainers.containers; +import lombok.extern.slf4j.Slf4j; + /** * Base class for classes that can provide a JDBC container. */ +@Slf4j public abstract class JdbcDatabaseContainerProvider { public abstract boolean supports(String databaseType); + public JdbcDatabaseContainer newInstance() { + log.warn("No explicit version tag was provided in JDBC URL and this class ({}) does not " + + "override newInstance() to set a default tag. `latest` will be used but results may " + + "be unreliable!", this.getClass().getCanonicalName()); + return this.newInstance("latest"); + } + public abstract JdbcDatabaseContainer newInstance(String tag); } diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java index b7bd9fb4925..569dc794213 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java +++ b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java @@ -102,9 +102,6 @@ public synchronized Connection connect(String url, final Properties info) throws } String databaseType = urlMatcher.group(1); String tag = urlMatcher.group(3); - if (tag == null) { - tag = "latest"; - } queryString = urlMatcher.group(4); if (queryString == null) { @@ -119,7 +116,12 @@ public synchronized Connection connect(String url, final Properties info) throws ServiceLoader databaseContainers = ServiceLoader.load(JdbcDatabaseContainerProvider.class); for (JdbcDatabaseContainerProvider candidateContainerType : databaseContainers) { if (candidateContainerType.supports(databaseType)) { - container = candidateContainerType.newInstance(tag); + + if (tag != null) { + container = candidateContainerType.newInstance(tag); + } else { + container = candidateContainerType.newInstance(); + } delegate = container.getJdbcDriverInstance(); } } diff --git a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java index c3717bb579e..e5acd9e0ddb 100644 --- a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java +++ b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java @@ -2,13 +2,15 @@ /** * Container implementation for the MariaDB project. - * + * * @author Miguel Gonzalez Sanchez */ public class MariaDBContainer> extends JdbcDatabaseContainer { public static final String NAME = "mariadb"; public static final String IMAGE = "mariadb"; + public static final String DEFAULT_TAG = "10.3.6"; + private static final Integer MARIADB_PORT = 3306; private static final String MARIADB_USER = "test"; private static final String MARIADB_PASSWORD = "test"; @@ -16,7 +18,7 @@ public class MariaDBContainer> extends JdbcD private static final String MY_CNF_CONFIG_OVERRIDE_PARAM_NAME = "TC_MY_CNF"; public MariaDBContainer() { - super(IMAGE + ":latest"); + super(IMAGE + ":" + DEFAULT_TAG); } public MariaDBContainer(String dockerImageName) { @@ -31,7 +33,7 @@ protected Integer getLivenessCheckPort() { @Override protected void configure() { optionallyMapResourceParameterAsVolume(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME, "/etc/mysql/conf.d", "mariadb-default-conf"); - + addExposedPort(MARIADB_PORT); addEnv("MYSQL_DATABASE", MARIADB_DATABASE); addEnv("MYSQL_USER", MARIADB_USER); diff --git a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java index fbe9d807af4..31504b95953 100644 --- a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java +++ b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java @@ -9,6 +9,11 @@ public boolean supports(String databaseType) { return databaseType.equals(MariaDBContainer.NAME); } + @Override + public JdbcDatabaseContainer newInstance() { + return newInstance(MariaDBContainer.DEFAULT_TAG); + } + @Override public JdbcDatabaseContainer newInstance(String tag) { return new MariaDBContainer(MariaDBContainer.IMAGE + ":" + tag); 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 a44662a7f36..a308560aeb3 100644 --- a/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java +++ b/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java @@ -6,14 +6,16 @@ * @author Stefan Hufschmidt */ public class MSSQLServerContainer> extends JdbcDatabaseContainer { - static final String NAME = "mssqlserver"; - static final String IMAGE = "microsoft/mssql-server-linux"; + public static final String NAME = "mssqlserver"; + public static final String IMAGE = "microsoft/mssql-server-linux"; + public static final String DEFAULT_TAG = "2017-CU6"; + public static final Integer MS_SQL_SERVER_PORT = 1433; private String username = "SA"; private String password = "A_Str0ng_Required_Password"; public MSSQLServerContainer() { - this(IMAGE + ":latest"); + this(IMAGE + ":" + DEFAULT_TAG); } public MSSQLServerContainer(final String dockerImageName) { diff --git a/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainerProvider.java b/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainerProvider.java index f7768482a45..daaa82ee771 100644 --- a/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainerProvider.java +++ b/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainerProvider.java @@ -9,6 +9,11 @@ public boolean supports(String databaseType) { return databaseType.equals(MSSQLServerContainer.NAME); } + @Override + public JdbcDatabaseContainer newInstance() { + return newInstance(MSSQLServerContainer.DEFAULT_TAG); + } + @Override public JdbcDatabaseContainer newInstance(String tag) { return new MSSQLServerContainer(MSSQLServerContainer.IMAGE + ":" + tag); diff --git a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java index 74ac5c7e8b5..8c675e4e930 100644 --- a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java +++ b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java @@ -12,6 +12,8 @@ public class MySQLContainer> extends JdbcDatab public static final String NAME = "mysql"; public static final String IMAGE = "mysql"; + public static final String DEFAULT_TAG = "5.7.22"; + private static final String MY_CNF_CONFIG_OVERRIDE_PARAM_NAME = "TC_MY_CNF"; public static final Integer MYSQL_PORT = 3306; private String databaseName = "test"; @@ -19,7 +21,7 @@ public class MySQLContainer> extends JdbcDatab private String password = "test"; public MySQLContainer() { - super(IMAGE + ":latest"); + super(IMAGE + ":" + DEFAULT_TAG); } public MySQLContainer(String dockerImageName) { diff --git a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java index f3e45673f05..f503330d0e5 100644 --- a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java +++ b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java @@ -9,6 +9,11 @@ public boolean supports(String databaseType) { return databaseType.equals(MySQLContainer.NAME); } + @Override + public JdbcDatabaseContainer newInstance() { + return newInstance(MySQLContainer.DEFAULT_TAG); + } + @Override public JdbcDatabaseContainer newInstance(String tag) { return new MySQLContainer(MySQLContainer.IMAGE + ":" + tag); diff --git a/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainerProvider.java b/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainerProvider.java index 4ce0fb2cdfb..853ffdaf17a 100644 --- a/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainerProvider.java +++ b/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainerProvider.java @@ -10,9 +10,13 @@ public boolean supports(String databaseType) { } @Override - public JdbcDatabaseContainer newInstance(String tag) { + public JdbcDatabaseContainer newInstance() { + return new OracleContainer(); + } - if (!tag.equalsIgnoreCase("latest")) { + @Override + public JdbcDatabaseContainer newInstance(String tag) { + if (tag != null) { throw new UnsupportedOperationException("Oracle database tag should be set in the configured image name"); } diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java index 23107764644..232daa89284 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java @@ -13,15 +13,17 @@ * @author richardnorth */ public class PostgreSQLContainer> extends JdbcDatabaseContainer { - static final String NAME = "postgresql"; - static final String IMAGE = "postgres"; + public static final String NAME = "postgresql"; + public static final String IMAGE = "postgres"; + public static final String DEFAULT_TAG = "9.6.8"; + public static final Integer POSTGRESQL_PORT = 5432; private String databaseName = "test"; private String username = "test"; private String password = "test"; public PostgreSQLContainer() { - this(IMAGE + ":latest"); + this(IMAGE + ":" + DEFAULT_TAG); } public PostgreSQLContainer(final String dockerImageName) { diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java index fae051b6d97..394fd5d49b8 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java @@ -9,6 +9,11 @@ public boolean supports(String databaseType) { return databaseType.equals(PostgreSQLContainer.NAME); } + @Override + public JdbcDatabaseContainer newInstance() { + return newInstance(PostgreSQLContainer.DEFAULT_TAG); + } + @Override public JdbcDatabaseContainer newInstance(String tag) { return new PostgreSQLContainer(PostgreSQLContainer.IMAGE + ":" + tag);