You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2022/04/12 10:06:59 UTC
[camel-quarkus-examples] 04/22: Remove references to health configuration options that no longer exist in Camel 3.16
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git
commit ab40c09f8b2d51efae20ae93675e4a3bc42c0ee6
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Feb 9 15:43:31 2022 +0000
Remove references to health configuration options that no longer exist in Camel 3.16
---
health/src/main/resources/application.properties | 14 -----
.../src/test/java/org/acme/health/HealthTest.java | 41 +++----------
.../org/acme/observability/ObservabilityTest.java | 70 +++++-----------------
3 files changed, 24 insertions(+), 101 deletions(-)
diff --git a/health/src/main/resources/application.properties b/health/src/main/resources/application.properties
index 0e06a96..afe6384 100644
--- a/health/src/main/resources/application.properties
+++ b/health/src/main/resources/application.properties
@@ -58,23 +58,9 @@ camel.health.registry-enabled = true
#camel.health.config[netty].parent = routes
#camel.health.config[netty].enabled = false
-# and configure each individually
-camel.health.config[timer].parent = routes
-camel.health.config[timer].interval = 5s
-camel.health.config[netty].parent = routes
-camel.health.config[netty].interval = 20s
-camel.health.config[netty].failure-threshold = 10
-
# find grained routes configuration per route (support wildcards)
# (enabled is default true for discovered health-checks)
#camel.health.config[*].enabled = true
-# allow 5 failures with 10s apart as slack to handle routes being flaky
-# however if after 5 failures then the state will be regarded as DOWN onwards
-# (the route can recover and the state will then be UP)
-#camel.health.config[*].parent = routes
-#camel.health.config[*].interval = 10s
-#camel.health.config[*].failure-threshold = 5
-
# properties used in the route
myPeriod = 10s
diff --git a/health/src/test/java/org/acme/health/HealthTest.java b/health/src/test/java/org/acme/health/HealthTest.java
index 7984a70..417a3f2 100644
--- a/health/src/test/java/org/acme/health/HealthTest.java
+++ b/health/src/test/java/org/acme/health/HealthTest.java
@@ -18,48 +18,23 @@ package org.acme.health;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
-import org.apache.camel.CamelContext;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.containsInAnyOrder;
@QuarkusTest
public class HealthTest {
@Test
public void testHealth() throws InterruptedException {
- if (isAggregatedHealthResponse()) {
- RestAssured.get("/q/health")
- .then()
- .statusCode(503)
- .body("status", is("DOWN"),
- "checks.status", containsInAnyOrder("DOWN", "UP"),
- "checks.name",
- containsInAnyOrder("camel-readiness-checks", "camel-liveness-checks"),
- "checks.data.context", containsInAnyOrder(null, "UP"));
- } else {
- RestAssured.get("/q/health")
- .then()
- .statusCode(503)
- .body("status", is("DOWN"),
- "checks.findAll { it.name == 'toolong' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'context' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'camel-routes' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'camel-consumers' }.status", Matchers.contains("DOWN"));
- }
- }
-
- /**
- * The JSON structure produced by camel-microprofile-health in Camel >= 3.15 is different to that
- * produced in previous versions. This check allows the tests to handle both formats.
- *
- * TODO: Remove when examples upgraded to >= Camel 3.15
- */
- private boolean isAggregatedHealthResponse() {
- String version = CamelContext.class.getPackage().getImplementationVersion();
- String[] versionParts = version.split("\\.");
- return Integer.parseInt(versionParts[1]) < 15;
+ RestAssured.get("/q/health")
+ .then()
+ .statusCode(503)
+ .body("status", is("DOWN"),
+ "checks.findAll { it.name == 'toolong' }.status", Matchers.contains("UP"),
+ "checks.findAll { it.name == 'context' }.status", Matchers.contains("UP"),
+ "checks.findAll { it.name == 'camel-routes' }.status", Matchers.contains("DOWN"),
+ "checks.findAll { it.name == 'camel-consumers' }.status", Matchers.contains("DOWN"));
}
}
diff --git a/observability/src/test/java/org/acme/observability/ObservabilityTest.java b/observability/src/test/java/org/acme/observability/ObservabilityTest.java
index 6d4b979..e87b19a 100644
--- a/observability/src/test/java/org/acme/observability/ObservabilityTest.java
+++ b/observability/src/test/java/org/acme/observability/ObservabilityTest.java
@@ -20,14 +20,11 @@ import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
-import org.apache.camel.CamelContext;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
-import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.jupiter.api.Assertions.assertTrue;
@QuarkusTest
@@ -56,57 +53,22 @@ public class ObservabilityTest {
@Test
public void health() {
- if (isAggregatedHealthResponse()) {
- // Verify liveness
- given()
- .when().accept(ContentType.JSON)
- .get("/q/health/live")
- .then()
- .statusCode(200)
- .body("status", Matchers.is("UP"),
- "checks.name", containsInAnyOrder("camel-liveness-checks"),
- "checks.data.custom-liveness-check", containsInAnyOrder("UP"));
-
- // Verify readiness
- given()
- .when().accept(ContentType.JSON)
- .get("/q/health/ready")
- .then()
- .statusCode(200)
- .body("status", Matchers.is("UP"),
- "checks.name",
- hasItems("camel-readiness-checks", "Uptime readiness check"),
- "checks.data.custom-readiness-check", containsInAnyOrder("UP"));
- } else {
- // Verify liveness
- RestAssured.get("/q/health/live")
- .then()
- .statusCode(200)
- .body("status", is("UP"),
- "checks.findAll { it.name == 'custom-liveness-check' }.status", Matchers.contains("UP"));
-
- // Verify readiness
- RestAssured.get("/q/health/ready")
- .then()
- .statusCode(200)
- .body("status", is("UP"),
- "checks.findAll { it.name == 'custom-readiness-check' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'Uptime readiness check' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'context' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'camel-routes' }.status", Matchers.contains("UP"),
- "checks.findAll { it.name == 'camel-consumers' }.status", Matchers.contains("UP"));
- }
- }
+ // Verify liveness
+ RestAssured.get("/q/health/live")
+ .then()
+ .statusCode(200)
+ .body("status", is("UP"),
+ "checks.findAll { it.name == 'custom-liveness-check' }.status", Matchers.contains("UP"));
- /**
- * The JSON structure produced by camel-microprofile-health in Camel >= 3.15 is different to that
- * produced in previous versions. This check allows the tests to handle both formats.
- *
- * TODO: Remove when examples upgraded to >= Camel 3.15
- */
- private boolean isAggregatedHealthResponse() {
- String version = CamelContext.class.getPackage().getImplementationVersion();
- String[] versionParts = version.split("\\.");
- return Integer.parseInt(versionParts[1]) < 15;
+ // Verify readiness
+ RestAssured.get("/q/health/ready")
+ .then()
+ .statusCode(200)
+ .body("status", is("UP"),
+ "checks.findAll { it.name == 'custom-readiness-check' }.status", Matchers.contains("UP"),
+ "checks.findAll { it.name == 'Uptime readiness check' }.status", Matchers.contains("UP"),
+ "checks.findAll { it.name == 'context' }.status", Matchers.contains("UP"),
+ "checks.findAll { it.name == 'camel-routes' }.status", Matchers.contains("UP"),
+ "checks.findAll { it.name == 'camel-consumers' }.status", Matchers.contains("UP"));
}
}