This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new cd5e89c20fe CAMEL-20367: Adds observability tests (#15668)
cd5e89c20fe is described below
commit cd5e89c20fe192318f2ca0f2edc9737a6871bd00
Author: Jakub Vrubel <[email protected]>
AuthorDate: Tue Sep 24 14:15:09 2024 +0200
CAMEL-20367: Adds observability tests (#15668)
---
.../dsl/jbang/it/MetricsObservabilityITCase.java | 45 ++++++++++++++++++++++
.../dsl/jbang/it/support/JBangTestSupport.java | 3 +-
.../resources/jbang/it/CircuitBreakerRoute.java | 30 +++++++++++++++
3 files changed, 77 insertions(+), 1 deletion(-)
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java
new file mode 100644
index 00000000000..d8720080d1a
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/MetricsObservabilityITCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.it;
+
+import java.io.IOException;
+
+import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class MetricsObservabilityITCase extends JBangTestSupport {
+
+ @Test
+ public void metricsTest() throws IOException {
+ copyResourceInDataFolder(TestResources.SERVER_ROUTE);
+ executeBackground(String.format("run %s/server.yaml --metrics",
mountPoint()));
+ checkLogContains("http://0.0.0.0:8080/q/metrics");
+ Assertions.assertThat(
+ execInHost(String.format("curl http://localhost:%s/q/metrics",
containerService.getDevConsolePort())))
+ .as("server should list metrics")
+ .contains("# HELP camel_exchanges_total Total number of
processed exchanges");
+ }
+
+ @Test
+ public void circuitBreakerTest() throws IOException {
+ copyResourceInDataFolder(TestResources.CIRCUIT_BREAKER);
+ executeBackground(String.format("run %s/CircuitBreakerRoute.java
--dep=camel-resilience4j", mountPoint()));
+ checkLogContains("(CircuitBreakerRoute) started");
+ checkCommandOutputs("get circuit-breaker", "resilience4j");
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
index 8beda53be59..b6d96afe9af 100644
---
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
@@ -99,7 +99,8 @@ public abstract class JBangTestSupport {
MQQT_CONSUMER("mqttConsumer.yaml", "/jbang/it/mqttConsumer.yaml"),
BUILD_GRADLE("build.gradle", "/jbang/it/maven-gradle/build.gradle"),
DIR_ROUTE("FromDirectoryRoute.java",
"/jbang/it/from-source-dir/FromDirectoryRoute.java"),
- SERVER_ROUTE("server.yaml", "/jbang/it/server.yaml");
+ SERVER_ROUTE("server.yaml", "/jbang/it/server.yaml"),
+ CIRCUIT_BREAKER("CircuitBreakerRoute.java",
"/jbang/it/CircuitBreakerRoute.java");
private String name;
private String resPath;
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/resources/jbang/it/CircuitBreakerRoute.java
b/dsl/camel-jbang/camel-jbang-it/src/test/resources/jbang/it/CircuitBreakerRoute.java
new file mode 100644
index 00000000000..61c73526fa5
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/resources/jbang/it/CircuitBreakerRoute.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.camel.builder.RouteBuilder;
+
+public class CircuitBreakerRoute extends RouteBuilder {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .circuitBreaker()
+ .to("http://localhost:8080/faulty")
+ .onFallback()
+ .transform().constant("Fallback message")
+ .end()
+ .to("mock:result");
+ }
+}