From 2f24c69820183185339c4b0fa1bf6133dfb8b60b Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 19 Dec 2022 11:30:40 +0200 Subject: [PATCH] Support QUARKUS_TEST_PROFILE environment variable The config [entry](https://quarkus.io/guides/continuous-testing#quarkus-test-dev-testing-test-config_quarkus.test.profile) mentions the environment variable, so let's support it Fixes: #29944 --- .../io/quarkus/runtime/configuration/ProfileManager.java | 5 +++++ .../main/java/io/quarkus/bootstrap/app/BootstrapProfile.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ProfileManager.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ProfileManager.java index c1a58d7963778..6b768229d43af 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ProfileManager.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ProfileManager.java @@ -22,6 +22,7 @@ public class ProfileManager { public static final String QUARKUS_PROFILE_ENV = "QUARKUS_PROFILE"; public static final String QUARKUS_PROFILE_PROP = "quarkus.profile"; public static final String QUARKUS_TEST_PROFILE_PROP = "quarkus.test.profile"; + public static final String QUARKUS_TEST_PROFILE_ENV = "QUARKUS_TEST_PROFILE"; private static final String BACKWARD_COMPATIBLE_QUARKUS_PROFILE_PROP = "quarkus-profile"; private static volatile LaunchMode launchMode = LaunchMode.NORMAL; @@ -52,6 +53,10 @@ public static String getActiveProfile() { if (profile != null) { return profile; } + profile = System.getenv(QUARKUS_TEST_PROFILE_ENV); + if (profile != null) { + return profile; + } return launchMode.getDefaultProfile(); } diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/BootstrapProfile.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/BootstrapProfile.java index 3642f42b0954f..d8ecfa1c68e86 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/BootstrapProfile.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/BootstrapProfile.java @@ -10,6 +10,7 @@ public class BootstrapProfile { public static final String QUARKUS_PROFILE_ENV = "QUARKUS_PROFILE"; public static final String QUARKUS_PROFILE_PROP = "quarkus.profile"; public static final String QUARKUS_TEST_PROFILE_PROP = "quarkus.test.profile"; + public static final String QUARKUS_TEST_PROFILE_ENV = "QUARKUS_TEST_PROFILE"; private static final String BACKWARD_COMPATIBLE_QUARKUS_PROFILE_PROP = "quarkus-profile"; public static final String DEV = "dev"; public static final String PROD = "prod"; @@ -27,6 +28,10 @@ public static String getActiveProfile(QuarkusBootstrap.Mode mode) { if (profile != null) { return profile; } + profile = System.getenv(QUARKUS_TEST_PROFILE_ENV); + if (profile != null) { + return profile; + } return "test"; }