Skip to content

Commit

Permalink
Fix flaky test OverrideBuildTimeConfigTest
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Nov 18, 2024
1 parent 6e4206e commit 8e04549
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface ConfigConfig {
* If this is set to {@code fail} the application will fail at start up.
* <p>
* Native tests leveraging<code>@io.quarkus.test.junit.TestProfile</code> are always run with
* {@code quarkus.configuration.build-time-mismatch-at-runtime = fail}.
* {@code quarkus.config.build-time-mismatch-at-runtime = fail}.
*/
@WithName("config.build-time-mismatch-at-runtime")
@WithDefault("warn")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.runtime.configuration;

import static io.quarkus.runtime.ConfigConfig.BuildTimeMismatchAtRuntime;
import static io.quarkus.runtime.ConfigConfig.BuildTimeMismatchAtRuntime.fail;
import static io.quarkus.runtime.ConfigConfig.BuildTimeMismatchAtRuntime.warn;

Expand All @@ -14,7 +15,6 @@
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.jboss.logging.Logger;

import io.quarkus.runtime.ConfigConfig;
import io.quarkus.runtime.ShutdownContext;
import io.quarkus.runtime.annotations.Recorder;
import io.smallrye.config.SmallRyeConfig;
Expand Down Expand Up @@ -60,14 +60,12 @@ public void handleConfigChange(Map<String, ConfigValue> buildTimeRuntimeValues)

if (!mismatches.isEmpty()) {
String msg = "Build time property cannot be changed at runtime:\n" + String.join("\n", mismatches);
SmallRyeConfig quarkusConfig = new QuarkusConfigFactory().getConfigFor(null, null);
if (!config.equals(quarkusConfig)) {
throw new IllegalStateException("SmallRyeConfig Classloaders mismatch!");
}
ConfigConfig configConfig = quarkusConfig.getConfigMapping(ConfigConfig.class);
if (fail.equals(configConfig.buildTimeMismatchAtRuntime())) {
// TODO - This should use ConfigConfig, but for some reason, the test fails sometimes with mapping not found when looking ConfigConfig
BuildTimeMismatchAtRuntime buildTimeMismatchAtRuntime = config
.getValue("quarkus.config.build-time-mismatch-at-runtime", BuildTimeMismatchAtRuntime.class);
if (fail.equals(buildTimeMismatchAtRuntime)) {
throw new IllegalStateException(msg);
} else if (warn.equals(configConfig.buildTimeMismatchAtRuntime())) {
} else if (warn.equals(buildTimeMismatchAtRuntime)) {
log.warn(msg);
}
}
Expand Down

0 comments on commit 8e04549

Please sign in to comment.