Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test OverrideBuildTimeConfigTest #44559

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading