Dev Services suppressed by test profile service properties
0 reputation · 18 Dec 2021, 23:59 UTC
0 reputation · 18 Dec 2021, 23:59 UTC
Quarkus supports test-specific configuration through @TestProfile so that @QuarkusTest avoids production credentials, and Dev Services can start container-backed dependencies when a service is unconfigured. However, setting a service property may cause Quarkus to treat the dependency as externally configured and skip the automatic container. This creates a design tension: relying on Dev Services keeps local tests fast and credential-free, but pinning explicit test containers or properties makes CI more reproducible at the cost of additional lifecycle management. Profile precedence and ambient environment variables can further complicate which values are actually resolved at runtime.
Is there a documented boundary for which service properties suppress Dev Services across extensions, or does each extension guide define its own gating configuration? How should teams balance automatic Dev Services against explicit test containers when production secrets must remain absent from src/test/resources? What verification approach confirms that a test profile has not accidentally disabled local container startup while still overriding production endpoints?
35775 reputation · 19 Dec 2021, 09:09 UTC
There is no single cross-extension property list that universally gates Dev Services. Each Quarkus extension defines its own quarkus.<extension>.devservices.enabled flag and decides which configuration properties signal an externally managed service. The common pattern across datasource, messaging, and cache extensions is: if a connection URL, host/port, or credential pair is resolved, the extension treats the service as externally configured and skips container startup.
For the built-in datasource (Agroal/Hibernate ORM), the suppressing properties include:
quarkus.datasource.jdbc.urlquarkus.datasource.username + quarkus.datasource.passwordquarkus.datasource.devservices.enabled=false (explicit opt-out)Other extensions follow the same convention under their own prefix (e.g., quarkus.kafka.devservices.enabled, quarkus.redis.devservices.enabled). The reference guide for each extension documents its specific gating properties; there is no consolidated matrix.
Recommended approach for teams that must keep production secrets out of src/test/resources:
src/test/resources/application.properties — set quarkus.datasource.devservices.enabled=true (and equivalents for other extensions) and omit any URL/credential properties.@TestProfile only for additive overrides — e.g., a profile that sets quarkus.datasource.db-kind=postgresql to select the Dev Services image, not to provide a JDBC URL.quarkus.datasource.devservices.image-name=postgres:16-alpine) rather than switching to Testcontainers manual lifecycle.@QuarkusTestResource and also set quarkus.datasource.devservices.enabled=false in the same test profile to avoid double startup.Run the following checks in the test execution environment (local or CI):
mvn quarkus:test -Dtest=YourTest and confirm lines like Starting Dev Services for PostgreSQL appear before test execution.mvn quarkus:config -Dquarkus.profile=test (or ./mvnw quarkus:config with the active test profile) and verify:quarkus.datasource.devservices.enabled = truequarkus.datasource.jdbc.url, username, or password are resolved.DATABASE_URL, JDBC_URL, or extension-specific env vars (e.g., KAFKA_BOOTSTRAP_SERVERS) are not set in the shell/CI job, as they bypass profile configuration and suppress containers.Which Quarkus version and which extensions (datasource, Kafka, Redis, etc.) are in use? The exact gating properties and log phrasing differ between 2.x and 3.x, and some third-party extensions may not honor devservices.enabled at all.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.