From 07fee83f9a4c69cbc70c25323c4db4303403ecdf Mon Sep 17 00:00:00 2001 From: xstefank Date: Fri, 9 Sep 2022 11:07:19 +0200 Subject: [PATCH] Upgrade SmallRye Health to 3.3.0 --- bom/application/pom.xml | 2 +- .../deployment/SmallRyeHealthConfig.java | 8 ++++ .../deployment/SmallRyeHealthProcessor.java | 18 ++++---- .../health/test/MaxHealthGroupTest.java | 42 +++++++++++++++++++ jakarta/rewrite.yml | 2 +- 5 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/MaxHealthGroupTest.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 5c60d85458a32..b7e699c571f71 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -41,7 +41,7 @@ 1.0 1.13.1 2.12.0 - 3.2.1 + 3.3.0 3.0.5 2.2.1 1.7.1 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 8241dc9c1e0ce..08a1066afeea5 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,7 @@ package io.quarkus.smallrye.health.deployment; +import java.util.OptionalInt; + import io.quarkus.runtime.annotations.ConfigDocSection; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigRoot; @@ -55,6 +57,12 @@ public class SmallRyeHealthConfig { @ConfigItem(defaultValue = "false") boolean contextPropagation; + /** + * The number of the maximum health groups that can be created. + */ + @ConfigItem + OptionalInt maxGroupRegistriesCount; + /** * 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 539db291a350c..13b3b9bb9272b 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 @@ -242,14 +242,12 @@ public void defineHealthRoutes(BuildProducer routes, .build()); SmallRyeIndividualHealthGroupHandler handler = new SmallRyeIndividualHealthGroupHandler(); - for (String healthGroup : healthGroups) { - routes.produce(nonApplicationRootPathBuildItem.routeBuilder() - .nestedRoute(healthConfig.rootPath, healthConfig.groupPath + "/" + healthGroup) - .handler(handler) - .displayOnNotFoundPage() - .blockingRoute() - .build()); - } + routes.produce(nonApplicationRootPathBuildItem.routeBuilder() + .nestedRoute(healthConfig.rootPath, healthConfig.groupPath + "/*") + .handler(handler) + .displayOnNotFoundPage() + .blockingRoute() + .build()); // Register the wellness handler routes.produce(nonApplicationRootPathBuildItem.routeBuilder() @@ -275,6 +273,10 @@ public void processSmallRyeHealthConfigValues(SmallRyeHealthConfig healthConfig, if (healthConfig.contextPropagation) { config.produce(new RunTimeConfigurationDefaultBuildItem("io.smallrye.health.context.propagation", "true")); } + if (healthConfig.maxGroupRegistriesCount.isPresent()) { + config.produce(new RunTimeConfigurationDefaultBuildItem("io.smallrye.health.maxGroupRegistriesCount", + String.valueOf(healthConfig.maxGroupRegistriesCount.getAsInt()))); + } config.produce(new RunTimeConfigurationDefaultBuildItem("io.smallrye.health.delayChecksInitializations", "true")); } diff --git a/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/MaxHealthGroupTest.java b/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/MaxHealthGroupTest.java new file mode 100644 index 0000000000000..7074da671b85d --- /dev/null +++ b/extensions/smallrye-health/deployment/src/test/java/io/quarkus/smallrye/health/test/MaxHealthGroupTest.java @@ -0,0 +1,42 @@ +package io.quarkus.smallrye.health.test; + +import static org.hamcrest.Matchers.is; + +import org.hamcrest.Matchers; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.restassured.RestAssured; +import io.restassured.parsing.Parser; + +public class MaxHealthGroupTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addClasses(BasicHealthCheck.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")) + .overrideConfigKey("quarkus.smallrye-health.max-group-registries-count", "3"); + + @Test + public void testMaxGroupRegistriesCreations() { + try { + RestAssured.defaultParser = Parser.JSON; + + for (int i = 0; i < 3; i++) { + RestAssured.get("/q/health/group/" + i).then() + .statusCode(200) + .body("status", is("UP"), + "checks.size()", is(0)); + } + RestAssured.when().get("/q/health/group/not-allowed").then() + .statusCode(500) + .body("details", Matchers.endsWith("3")); + } finally { + RestAssured.reset(); + } + } + +} diff --git a/jakarta/rewrite.yml b/jakarta/rewrite.yml index 6784f8459c14b..48862d42bee1a 100644 --- a/jakarta/rewrite.yml +++ b/jakarta/rewrite.yml @@ -547,7 +547,7 @@ recipeList: newValue: 2.0.0.RC8 - org.openrewrite.maven.ChangePropertyValue: key: smallrye-health.version - newValue: 4.0.0-RC2 + newValue: 4.0.0 - org.openrewrite.maven.ChangePropertyValue: key: microprofile-jwt.version newValue: 2.0