From 99c745d26379f7992ddb40ec3b0883680184b546 Mon Sep 17 00:00:00 2001 From: xstefank Date: Mon, 28 Nov 2022 17:09:05 +0100 Subject: [PATCH] Upgrade SmallRye Health to 3.3.1 (4.0.1) --- bom/application/pom.xml | 2 +- .../deployment/SmallRyeHealthConfig.java | 7 +++ .../deployment/SmallRyeHealthProcessor.java | 4 ++ .../health/test/DefaultHealthGroupTest.java | 51 +++++++++++++++++++ .../health/test/ui/HealthGroupCheck.java | 14 +++++ jakarta/rewrite.yml | 2 +- 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/DefaultHealthGroupTest.java create mode 100644 extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/ui/HealthGroupCheck.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index b6a8988dc065e..fca96a69a41cd 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -41,7 +41,7 @@ 1.0 1.13.2 2.13.0 - 3.3.0 + 3.3.1 3.0.5 2.3.1 1.9.0 diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthConfig.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthConfig.java index 08a1066afeea5..f1c88cdea58c7 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthConfig.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthConfig.java @@ -1,5 +1,6 @@ package io.quarkus.smallrye.health.deployment; +import java.util.Optional; import java.util.OptionalInt; import io.quarkus.runtime.annotations.ConfigDocSection; @@ -63,6 +64,12 @@ public class SmallRyeHealthConfig { @ConfigItem OptionalInt maxGroupRegistriesCount; + /** + * The name of the default health group used when no other health group is defined on the health check. + */ + @ConfigItem + Optional defaultHealthGroup; + /** * SmallRye Health UI configuration */ diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java index 13b3b9bb9272b..76c5effc51549 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java @@ -278,6 +278,10 @@ public void processSmallRyeHealthConfigValues(SmallRyeHealthConfig healthConfig, String.valueOf(healthConfig.maxGroupRegistriesCount.getAsInt()))); } config.produce(new RunTimeConfigurationDefaultBuildItem("io.smallrye.health.delayChecksInitializations", "true")); + if (healthConfig.defaultHealthGroup.isPresent()) { + config.produce(new RunTimeConfigurationDefaultBuildItem("io.smallrye.health.defaultHealthGroup", + healthConfig.defaultHealthGroup.get())); + } } @BuildStep(onlyIf = OpenAPIIncluded.class) diff --git a/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/DefaultHealthGroupTest.java b/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/DefaultHealthGroupTest.java new file mode 100644 index 0000000000000..a750c84e234b4 --- /dev/null +++ b/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/DefaultHealthGroupTest.java @@ -0,0 +1,51 @@ +package io.quarkus.smallrye.health.test; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.is; + +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.smallrye.health.test.ui.HealthGroupCheck; +import io.quarkus.test.QuarkusUnitTest; +import io.restassured.RestAssured; +import io.restassured.parsing.Parser; + +public class DefaultHealthGroupTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addClasses(BasicHealthCheck.class, HealthGroupCheck.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")) + .overrideConfigKey("quarkus.smallrye-health.default-health-group", "my-default-health-group"); + + @Test + public void testDefaultHealthGroup() { + try { + RestAssured.defaultParser = Parser.JSON; + RestAssured.when().get("/q/health/group/my-default-health-group").then() + .body("status", is("UP"), + "checks.size()", is(1), + "checks.status", contains("UP"), + "checks.name", contains("basic")); + + RestAssured.when().get("/q/health/group/test-group").then() + .body("status", is("UP"), + "checks.size()", is(1), + "checks.status", contains("UP"), + "checks.name", contains(HealthGroupCheck.class.getName())); + + RestAssured.when().get("/q/health/group").then() + .body("status", is("UP"), + "checks.size()", is(2), + "checks.status", hasItems("UP", "UP"), + "checks.name", hasItems("basic", HealthGroupCheck.class.getName())); + } finally { + RestAssured.reset(); + } + } + +} diff --git a/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/ui/HealthGroupCheck.java b/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/ui/HealthGroupCheck.java new file mode 100644 index 0000000000000..3308675645192 --- /dev/null +++ b/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/ui/HealthGroupCheck.java @@ -0,0 +1,14 @@ +package io.quarkus.smallrye.health.test.ui; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; + +import io.smallrye.health.api.HealthGroup; + +@HealthGroup("test-group") +public class HealthGroupCheck implements HealthCheck { + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.up(HealthGroupCheck.class.getName()); + } +} diff --git a/jakarta/rewrite.yml b/jakarta/rewrite.yml index c5a79f69067c3..7b4f564497be7 100644 --- a/jakarta/rewrite.yml +++ b/jakarta/rewrite.yml @@ -576,7 +576,7 @@ recipeList: newValue: '2.0.0' - org.openrewrite.maven.ChangePropertyValue: key: smallrye-health.version - newValue: '4.0.0' + newValue: '4.0.1' - org.openrewrite.maven.ChangePropertyValue: key: microprofile-jwt.version newValue: '2.0'