These two links:
- https://quarkus.io/guides/config-reference#custom-profiles and
- https://quarkus.io/guides/config-reference#profile-aware-files
specify how to use different profiles in Quarkus applications. I tried both variants for my testing environment and I basically failed at both of them.
1st variant (custom profiles)
I have the main configuration file src/main/resources/application.properties
which contains all main config variables but each of them has an env variable assigned as a value.
I have my test config variables also in src/main/resources/application.properties
. Their names are the same as for the base config variables just prefixed with %test.
.
When I do not have any environment variable set related to any config variable, then mvn -Dquarkus.test.profile=test clean verify
works as expected - the values from the config variables prefixed with %test.
are used during the tests.
However, as soon as I specify any env variable which is used as a value for some config property, the test value for this config property is not used anymore but the value from the variable. This breaks the expected behavior also in my CI/CD pipelines.
2nd variant (profile aware files)
I have a main configuration file src/main/resources/application.properties
and also I have a test profile file src/main/resources/application-test.properties
. I have the same scenario with variables as in the 1st variant. Meaning that in the main config file I have for example my.property=${MY_PROPERTY}
and in the test profile config I have my.property=dummyValue
.
If I do not set env variable MY_PROPERTY
, then the dummyValue
value is used for my.property
during runtime. But when I set the env variable MY_PROPERTY
, then the dummyValue
is completely ignored when I run mvn -Dquarkus.test.profile=test clean verify
. Therefore this breaks my testing environment again.