diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java index 69a0fe31bdb98..55cf064b852f4 100644 --- a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java @@ -13,8 +13,7 @@ public interface DevServicesDatasourceProvider { RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt port, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork); + OptionalInt port, LaunchMode launchMode, Optional startupTimeout); default boolean isDockerRequired() { return true; diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesUseTestContainersSharedNetworkBuildItem.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesUseTestContainersSharedNetworkBuildItem.java new file mode 100644 index 0000000000000..ac74237bbb0f8 --- /dev/null +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesUseTestContainersSharedNetworkBuildItem.java @@ -0,0 +1,11 @@ +package io.quarkus.datasource.deployment.spi; + +import io.quarkus.builder.item.MultiBuildItem; +import io.quarkus.deployment.annotations.BuildStep; + +/** + * Marker used by {@link BuildStep}'s that launch TestContainers' containers to ensure that they join TestContainers shared network. + */ +public final class DevServicesUseTestContainersSharedNetworkBuildItem extends MultiBuildItem { + +} diff --git a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java index d39a388c54781..606f4b0e36dc7 100644 --- a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java +++ b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java @@ -267,8 +267,7 @@ private DevServicesDatasourceResultBuildItem.DbResult startDevDb(String dbName, ConfigProvider.getConfig().getOptionalValue(prefix + "password", String.class), Optional.ofNullable(dbName), dataSourceBuildTimeConfig.devservices.imageName, dataSourceBuildTimeConfig.devservices.properties, - dataSourceBuildTimeConfig.devservices.port, launchMode, globalDevServicesConfig.timeout, - dataSourceBuildTimeConfig.devservices.useTestContainersSharedNetwork); + dataSourceBuildTimeConfig.devservices.port, launchMode, globalDevServicesConfig.timeout); closeableList.add(datasource.getCloseTask()); propertiesMap.put(prefix + "db-kind", dataSourceBuildTimeConfig.dbKind.orElse(null)); diff --git a/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java b/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java index 09aef269b15e0..62e422722c29c 100644 --- a/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java +++ b/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java @@ -55,12 +55,4 @@ public class DevServicesBuildTimeConfig { @ConfigItem public OptionalInt port; - /** - * Whether this particular data source's container should join TestContainers Shared Network. - *

- * By default, the data source container will join Docker's default network. - */ - @ConfigItem(defaultValue = "false") - public boolean useTestContainersSharedNetwork; - } diff --git a/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java b/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java index eecec7bb41b96..389c904a24df7 100644 --- a/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java +++ b/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.datasource.common.runtime.DatabaseKind; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesUseTestContainersSharedNetworkBuildItem; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem; import io.quarkus.devservices.common.ConfigureUtil; @@ -31,15 +32,16 @@ public class DB2DevServicesProcessor { @BuildStep DevServicesDatasourceProviderBuildItem setupDB2( - Optional devServicesSharedNetworkBuildItem) { + Optional devServicesSharedNetworkBuildItem, + Optional devServicesUseTestContainersSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.DB2, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { QuarkusDb2Container container = new QuarkusDb2Container(imageName, fixedExposedPort, - devServicesSharedNetworkBuildItem.isPresent(), useTestContainersSharedNetwork); + devServicesSharedNetworkBuildItem.isPresent(), + devServicesUseTestContainersSharedNetworkBuildItem.isPresent()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) .withUsername(username.orElse("quarkus")) diff --git a/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java b/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java index fe56b8b715b15..6e54a2f66072e 100644 --- a/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java +++ b/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java @@ -31,8 +31,7 @@ DevServicesDatasourceProviderBuildItem setupDerby() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { try { int port = fixedExposedPort.isPresent() ? fixedExposedPort.getAsInt() : 1527 + (launchMode == LaunchMode.TEST ? 0 : 1); diff --git a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java index 690816cfdc986..b5b40af18706c 100644 --- a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java +++ b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java @@ -30,8 +30,7 @@ DevServicesDatasourceProviderBuildItem setupH2() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt port, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt port, LaunchMode launchMode, Optional startupTimeout) { try { final Server tcpServer = Server.createTcpServer("-tcpPort", port.isPresent() ? String.valueOf(port.getAsInt()) : "0"); diff --git a/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java b/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java index 201172d171a11..16be181d04c60 100644 --- a/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java +++ b/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.datasource.common.runtime.DatabaseKind; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesUseTestContainersSharedNetworkBuildItem; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem; import io.quarkus.devservices.common.ConfigureUtil; @@ -29,15 +30,16 @@ public class MariaDBDevServicesProcessor { @BuildStep DevServicesDatasourceProviderBuildItem setupMariaDB( - Optional devServicesSharedNetworkBuildItem) { + Optional devServicesSharedNetworkBuildItem, + Optional devServicesUseTestContainersSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MARIADB, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { QuarkusMariaDBContainer container = new QuarkusMariaDBContainer(imageName, fixedExposedPort, - devServicesSharedNetworkBuildItem.isPresent(), useTestContainersSharedNetwork); + devServicesSharedNetworkBuildItem.isPresent(), + devServicesUseTestContainersSharedNetworkBuildItem.isPresent()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) .withUsername(username.orElse("quarkus")) diff --git a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java index a3dc2eccfbb4d..cbaf41bf71ef7 100644 --- a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java +++ b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.datasource.common.runtime.DatabaseKind; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesUseTestContainersSharedNetworkBuildItem; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem; import io.quarkus.devservices.common.ConfigureUtil; @@ -31,15 +32,16 @@ public class MSSQLDevServicesProcessor { @BuildStep DevServicesDatasourceProviderBuildItem setupMSSQL( - Optional devServicesSharedNetworkBuildItem) { + Optional devServicesSharedNetworkBuildItem, + Optional devServicesUseTestContainersSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MSSQL, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { QuarkusMSSQLServerContainer container = new QuarkusMSSQLServerContainer(imageName, fixedExposedPort, - devServicesSharedNetworkBuildItem.isPresent(), useTestContainersSharedNetwork); + devServicesSharedNetworkBuildItem.isPresent(), + devServicesUseTestContainersSharedNetworkBuildItem.isPresent()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("Quarkuspassword1")); additionalProperties.forEach(container::withUrlParam); diff --git a/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java b/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java index e00700a9029bd..c8af377502913 100644 --- a/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java +++ b/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.datasource.common.runtime.DatabaseKind; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesUseTestContainersSharedNetworkBuildItem; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem; import io.quarkus.devservices.common.ConfigureUtil; @@ -28,15 +29,16 @@ public class MySQLDevServicesProcessor { @BuildStep DevServicesDatasourceProviderBuildItem setupMysql( - Optional devServicesSharedNetworkBuildItem) { + Optional devServicesSharedNetworkBuildItem, + Optional devServicesUseTestContainersSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MYSQL, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { QuarkusMySQLContainer container = new QuarkusMySQLContainer(imageName, fixedExposedPort, - devServicesSharedNetworkBuildItem.isPresent(), useTestContainersSharedNetwork); + devServicesSharedNetworkBuildItem.isPresent(), + devServicesUseTestContainersSharedNetworkBuildItem.isPresent()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) .withUsername(username.orElse("quarkus")) diff --git a/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java b/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java index dffa2f8b0e031..6f1720c3a8e5d 100644 --- a/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java +++ b/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.datasource.common.runtime.DatabaseKind; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesUseTestContainersSharedNetworkBuildItem; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem; import io.quarkus.devservices.common.ConfigureUtil; @@ -33,15 +34,16 @@ public class OracleDevServicesProcessor { @BuildStep DevServicesDatasourceProviderBuildItem setupOracle( - Optional devServicesSharedNetworkBuildItem) { + Optional devServicesSharedNetworkBuildItem, + Optional devServicesUseTestContainersSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.ORACLE, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { QuarkusOracleServerContainer container = new QuarkusOracleServerContainer(imageName, fixedExposedPort, - devServicesSharedNetworkBuildItem.isPresent(), useTestContainersSharedNetwork); + devServicesSharedNetworkBuildItem.isPresent(), + devServicesUseTestContainersSharedNetworkBuildItem.isPresent()); startupTimeout.ifPresent(container::withStartupTimeout); container.withUsername(username.orElse(DEFAULT_DATABASE_USER)) .withPassword(password.orElse(DEFAULT_DATABASE_PASSWORD)) @@ -110,4 +112,4 @@ public String getEffectiveJdbcUrl() { } } } -} \ No newline at end of file +} diff --git a/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java b/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java index f1965445fc05f..89c9af03064e5 100644 --- a/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java +++ b/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java @@ -15,6 +15,7 @@ import io.quarkus.datasource.common.runtime.DatabaseKind; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesUseTestContainersSharedNetworkBuildItem; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.DevServicesSharedNetworkBuildItem; import io.quarkus.devservices.common.ConfigureUtil; @@ -28,15 +29,16 @@ public class PostgresqlDevServicesProcessor { @BuildStep DevServicesDatasourceProviderBuildItem setupPostgres( - Optional devServicesSharedNetworkBuildItem) { + Optional devServicesSharedNetworkBuildItem, + Optional devServicesUseTestContainersSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.POSTGRESQL, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, Optional imageName, Map additionalProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout, - boolean useTestContainersSharedNetwork) { + OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { QuarkusPostgreSQLContainer container = new QuarkusPostgreSQLContainer(imageName, fixedExposedPort, - devServicesSharedNetworkBuildItem.isPresent(), useTestContainersSharedNetwork); + devServicesSharedNetworkBuildItem.isPresent(), + devServicesUseTestContainersSharedNetworkBuildItem.isPresent()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) .withUsername(username.orElse("quarkus"))