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

Bump testcontainers to 1.16 #19648

Merged
merged 3 commits into from
Aug 26, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@
<avro.version>1.10.2</avro.version>
<apicurio-registry.version>2.0.1.Final</apicurio-registry.version>
<jacoco.version>0.8.7</jacoco.version>
<testcontainers.version>1.15.3</testcontainers.version>
<docker-java.version>3.2.8</docker-java.version> <!-- must be the version Testcontainers use -->
<testcontainers.version>1.16.0</testcontainers.version>
<docker-java.version>3.2.11</docker-java.version> <!-- must be the version Testcontainers use -->
Copy link

Choose a reason for hiding this comment

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

If you want it to be the version testcontainers uses, consider not specifying it directly.

<aesh-readline.version>2.1</aesh-readline.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public static String configureSharedNetwork(GenericContainer<?> container, Strin
String hostName = hostNamePrefix + "-" + Base58.randomString(5);
container.setNetworkAliases(Collections.singletonList(hostName));

// we need to clear the exposed ports as they don't make sense when the application is going to
// to be communicating with the DB over the same network
container.setExposedPorts(Collections.emptyList());
return hostName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ DevServicesDatasourceProviderBuildItem setupDB2(
public RunningDevServicesDatasource startDatabase(Optional<String> username, Optional<String> password,
Optional<String> datasourceName, Optional<String> imageName, Map<String, String> additionalProperties,
OptionalInt fixedExposedPort, LaunchMode launchMode) {
Db2Container container = new QuarkusDb2Container(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent())
.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
QuarkusDb2Container container = new QuarkusDb2Container(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent());
container.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
additionalProperties.forEach(container::withUrlParam);
container.start();

LOG.info("Dev Services for IBM Db2 started.");

return new RunningDevServicesDatasource(container.getJdbcUrl(), container.getUsername(),
return new RunningDevServicesDatasource(container.getEffectiveJdbcUrl(), container.getUsername(),
container.getPassword(),
new Closeable() {
@Override
Expand Down Expand Up @@ -86,8 +86,11 @@ protected void configure() {
}
}

@Override
public String getJdbcUrl() {
// this is meant to be called by Quarkus code and is not strictly needed
// in the DB2 case as testcontainers does not try to establish
// a connection to determine if the container is ready, but we do it anyway to be consistent across
// DB containers
public String getEffectiveJdbcUrl() {
if (useSharedNetwork) {
// in this case we expose the URL using the network alias we created in 'configure'
// and the container port since the application communicating with this container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ DevServicesDatasourceProviderBuildItem setupMariaDB(
public RunningDevServicesDatasource startDatabase(Optional<String> username, Optional<String> password,
Optional<String> datasourceName, Optional<String> imageName, Map<String, String> additionalProperties,
OptionalInt fixedExposedPort, LaunchMode launchMode) {
MariaDBContainer container = new QuarkusMariaDBContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent())
.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
QuarkusMariaDBContainer container = new QuarkusMariaDBContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent());
container.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
additionalProperties.forEach(container::withUrlParam);
container.start();

LOG.info("Dev Services for MariaDB started.");

return new RunningDevServicesDatasource(container.getJdbcUrl(), container.getUsername(),
return new RunningDevServicesDatasource(container.getEffectiveJdbcUrl(), container.getUsername(),
container.getPassword(),
new Closeable() {
@Override
Expand Down Expand Up @@ -84,8 +84,9 @@ protected void configure() {
}
}

@Override
public String getJdbcUrl() {
// this is meant to be called by Quarkus code and is needed in order to not disrupt testcontainers
// from being able to determine the status of the container (which it does by trying to acquire a connection)
public String getEffectiveJdbcUrl() {
if (useSharedNetwork) {
String additionalUrlParams = constructUrlParameters("?", "&");
return "jdbc:mariadb://" + hostName + ":" + PORT + "/" + getDatabaseName() + additionalUrlParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.OptionalInt;

import org.jboss.logging.Logger;
import org.testcontainers.containers.JdbcDatabaseContainer;
import org.testcontainers.containers.MSSQLServerContainer;
import org.testcontainers.utility.DockerImageName;

Expand Down Expand Up @@ -36,15 +35,15 @@ DevServicesDatasourceProviderBuildItem setupMSSQL(
public RunningDevServicesDatasource startDatabase(Optional<String> username, Optional<String> password,
Optional<String> datasourceName, Optional<String> imageName, Map<String, String> additionalProperties,
OptionalInt fixedExposedPort, LaunchMode launchMode) {
JdbcDatabaseContainer container = new QuarkusMSSQLServerContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent())
.withPassword(password.orElse("Quarkuspassword1"));
QuarkusMSSQLServerContainer container = new QuarkusMSSQLServerContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent());
container.withPassword(password.orElse("Quarkuspassword1"));
additionalProperties.forEach(container::withUrlParam);
container.start();

LOG.info("Dev Services for Microsoft SQL Server started.");

return new RunningDevServicesDatasource(container.getJdbcUrl(), container.getUsername(),
return new RunningDevServicesDatasource(container.getEffectiveJdbcUrl(), container.getUsername(),
container.getPassword(),
new Closeable() {
@Override
Expand Down Expand Up @@ -86,8 +85,9 @@ protected void configure() {
}
}

@Override
public String getJdbcUrl() {
// this is meant to be called by Quarkus code and is needed in order to not disrupt testcontainers
// from being able to determine the status of the container (which it does by trying to acquire a connection)
public String getEffectiveJdbcUrl() {
if (useSharedNetwork) {
// in this case we expose the URL using the network alias we created in 'configure'
// and the container port since the application communicating with this container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ DevServicesDatasourceProviderBuildItem setupMysql(
public RunningDevServicesDatasource startDatabase(Optional<String> username, Optional<String> password,
Optional<String> datasourceName, Optional<String> imageName, Map<String, String> additionalProperties,
OptionalInt fixedExposedPort, LaunchMode launchMode) {
MySQLContainer container = new QuarkusMySQLContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent())
.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
QuarkusMySQLContainer container = new QuarkusMySQLContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent());
container.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
additionalProperties.forEach(container::withUrlParam);
container.start();

LOG.info("Dev Services for MySQL started.");

return new RunningDevServicesDatasource(container.getJdbcUrl(), container.getUsername(),
return new RunningDevServicesDatasource(container.getEffectiveJdbcUrl(), container.getUsername(),
container.getPassword(),
new Closeable() {
@Override
Expand Down Expand Up @@ -83,8 +83,9 @@ protected void configure() {
}
}

@Override
public String getJdbcUrl() {
// this is meant to be called by Quarkus code and is needed in order to not disrupt testcontainers
// from being able to determine the status of the container (which it does by trying to acquire a connection)
public String getEffectiveJdbcUrl() {
if (useSharedNetwork) {
// in this case we expose the URL using the network alias we created in 'configure'
// and the container port since the application communicating with this container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ DevServicesDatasourceProviderBuildItem setupPostgres(
public RunningDevServicesDatasource startDatabase(Optional<String> username, Optional<String> password,
Optional<String> datasourceName, Optional<String> imageName, Map<String, String> additionalProperties,
OptionalInt fixedExposedPort, LaunchMode launchMode) {
PostgreSQLContainer container = new QuarkusPostgreSQLContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent())
.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
QuarkusPostgreSQLContainer container = new QuarkusPostgreSQLContainer(imageName, fixedExposedPort,
devServicesSharedNetworkBuildItem.isPresent());
container.withPassword(password.orElse("quarkus"))
.withUsername(username.orElse("quarkus"))
.withDatabaseName(datasourceName.orElse("default"));
additionalProperties.forEach(container::withUrlParam);

container.start();

LOG.info("Dev Services for PostgreSQL started.");

return new RunningDevServicesDatasource(container.getJdbcUrl(), container.getUsername(),
return new RunningDevServicesDatasource(container.getEffectiveJdbcUrl(), container.getUsername(),
container.getPassword(),
new Closeable() {
@Override
Expand Down Expand Up @@ -84,8 +84,11 @@ protected void configure() {
}
}

@Override
public String getJdbcUrl() {
// this is meant to be called by Quarkus code and is not strictly needed
// in the PostgreSQL case as testcontainers does not try to establish
// a connection to determine if the container is ready, but we do it anyway to be consistent across
// DB containers
public String getEffectiveJdbcUrl() {
if (useSharedNetwork) {
// in this case we expose the URL using the network alias we created in 'configure'
// and the container port since the application communicating with this container
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/container-image/maven-invoker-way/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
</goals>
</execution>
</executions>
<configuration>
<skip>${skipTests}</skip>
</configuration>
</plugin>
</plugins>
</build>
Expand Down