You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ap...@apache.org on 2026/04/21 13:36:20 UTC
(camel) branch main updated: CAMEL-23223 - improve assertion failure message to help investigation on flaky test ManagedMessageHistoryAutoConfigIT
This is an automated email from the ASF dual-hosted git repository.
apupier 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 4b257f0b03d6 CAMEL-23223 - improve assertion failure message to help investigation on flaky test ManagedMessageHistoryAutoConfigIT
4b257f0b03d6 is described below
commit 4b257f0b03d6c0174c17870bdfb40bd7e5787492
Author: Aurélien Pupier <ap...@ibm.com>
AuthorDate: Tue Apr 21 09:11:34 2026 +0200
CAMEL-23223 - improve assertion failure message to help investigation on
flaky test ManagedMessageHistoryAutoConfigIT
instead of
```
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
```
there will now be a message like:
```
ManagedMessageHistoryAutoConfigIT.testMessageHistory:120->assertMetricDataHasNodeId:130
Expecting any elements of:
[ImmutableHistogramPointData{getStartEpochNanos=1776755336333536296,
getEpochNanos=1776755336415229081,
getAttributes={camelContext="camel-1", kind="CamelMessageHistory",
nodeId="foo", routeId="route1"}, getSum=1.0, getCount=5, hasMin=true,
getMin=0.0, hasMax=true, getMax=1.0, getBoundaries=[0.0, 5.0, 10.0,
25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0,
7500.0, 10000.0], getCounts=[4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0], getExemplars=[]},
ImmutableHistogramPointData{getStartEpochNanos=1776755336333480676,
getEpochNanos=1776755336415229081,
getAttributes={camelContext="camel-1", kind="CamelMessageHistory",
nodeId="bar", routeId="route2"}, getSum=1.0, getCount=5, hasMin=true,
getMin=0.0, hasMax=true, getMax=1.0, getBoundaries=[0.0, 5.0, 10.0,
25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0,
7500.0, 10000.0], getCounts=[4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0], getExemplars=[]},
ImmutableHistogramPointData{getStartEpochNanos=1776755336334308001,
getEpochNanos=1776755336415229081,
getAttributes={camelContext="camel-1", kind="CamelMessageHistory",
nodeId="baz", routeId="route2"}, getSum=0.0, getCount=5, hasMin=true,
getMin=0.0, hasMax=true, getMax=0.0, getBoundaries=[0.0, 5.0, 10.0,
25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0,
7500.0, 10000.0], getCounts=[5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0], getExemplars=[]}]
to match 'No metric data found for node invalidToCheckErrorMessageof
route route2 ' predicate but none did.
```
Signed-off-by: Aurélien Pupier <ap...@ibm.com>
---
components/camel-opentelemetry-metrics/pom.xml | 5 +++++
.../ManagedMessageHistoryAutoConfigIT.java | 17 ++++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/components/camel-opentelemetry-metrics/pom.xml b/components/camel-opentelemetry-metrics/pom.xml
index c31db34496a0..d386fe3c65c3 100644
--- a/components/camel-opentelemetry-metrics/pom.xml
+++ b/components/camel-opentelemetry-metrics/pom.xml
@@ -84,6 +84,11 @@
<artifactId>opentelemetry-exporter-logging</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
diff --git a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/messagehistory/ManagedMessageHistoryAutoConfigIT.java b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/messagehistory/ManagedMessageHistoryAutoConfigIT.java
index eecea58be6dd..9fbf9a0d7a94 100644
--- a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/messagehistory/ManagedMessageHistoryAutoConfigIT.java
+++ b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/messagehistory/ManagedMessageHistoryAutoConfigIT.java
@@ -42,6 +42,7 @@ import org.junit.jupiter.api.Test;
import static org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.DEFAULT_CAMEL_MESSAGE_HISTORY_METER_NAME;
import static org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.ROUTE_ID_ATTRIBUTE;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -113,9 +114,9 @@ public class ManagedMessageHistoryAutoConfigIT extends CamelTestSupport {
assertPointDataForRouteId(metricData, "route1");
- assertTrue(verifyMetricDataHasNodeId(metricData, "route1", "foo"));
- assertTrue(verifyMetricDataHasNodeId(metricData, "route2", "bar"));
- assertTrue(verifyMetricDataHasNodeId(metricData, "route2", "baz"));
+ assertMetricDataHasNodeId(metricData, "route1", "foo");
+ assertMetricDataHasNodeId(metricData, "route2", "bar");
+ assertMetricDataHasNodeId(metricData, "route2", "baz");
dataCount++;
}
@@ -123,10 +124,12 @@ public class ManagedMessageHistoryAutoConfigIT extends CamelTestSupport {
assertTrue(dataCount > 0, "No metric data found");
}
- private boolean verifyMetricDataHasNodeId(MetricData metricData, String routeId, String nodeId) {
- return metricData.getData().getPoints().stream()
- .filter(point -> routeId.equals(getRouteId(point)))
- .anyMatch(point -> nodeId.equals(point.getAttributes().get(AttributeKey.stringKey("nodeId"))));
+ private void assertMetricDataHasNodeId(MetricData metricData, String routeId, String nodeId) {
+ assertThat(metricData.getData().getPoints())
+ .anyMatch(point -> {
+ return routeId.equals(getRouteId(point))
+ && nodeId.equals(point.getAttributes().get(AttributeKey.stringKey("nodeId")));
+ }, "No metric data found for node " + nodeId + "of route " + routeId + " ");
}
private void assertPointDataForRouteId(MetricData metricData, String routeId) {