This is an automated email from the ASF dual-hosted git repository.
gnodet 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 7ced2516f80a CAMEL-23429: Fix flaky TimerRouteAutoConfigIT in
camel-opentelemetry-metrics
7ced2516f80a is described below
commit 7ced2516f80a0b1d462328d3b87b7e762ddd088a
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed May 6 06:54:55 2026 +0200
CAMEL-23429: Fix flaky TimerRouteAutoConfigIT in camel-opentelemetry-metrics
Move metric assertion inside await().untilAsserted() so the test polls
until metric "A" actually appears, instead of asserting on the first
export batch which may not yet contain it.
---
.../integration/TimerRouteAutoConfigIT.java | 49 +++++++++++-----------
1 file changed, 24 insertions(+), 25 deletions(-)
diff --git
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/TimerRouteAutoConfigIT.java
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/TimerRouteAutoConfigIT.java
index 44fb9d61d376..89ebd49569fd 100644
---
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/TimerRouteAutoConfigIT.java
+++
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/TimerRouteAutoConfigIT.java
@@ -91,32 +91,31 @@ public class TimerRouteAutoConfigIT extends
CamelTestSupport {
mockEndpoint.expectedBodiesReceived(body);
template.sendBody("direct:in1", body);
- // capture logs from the LoggingMetricExporter
- await().atMost(Duration.ofMillis(1000L)).until(handler::hasLogs);
+ await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> {
+ List<LogRecord> logs = new ArrayList<>(handler.getLogs());
+ assertFalse(logs.isEmpty(), "No metrics were exported");
- List<LogRecord> logs = new ArrayList<>(handler.getLogs());
- assertFalse(logs.isEmpty(), "No metrics were exported");
-
- long dataCount = logs.stream()
- .map(LogRecord::getParameters)
- .filter(Objects::nonNull)
- .flatMap(Arrays::stream)
- .filter(MetricData.class::isInstance)
- .map(MetricData.class::cast)
- .filter(md -> "A".equals(md.getName()))
- .peek(md -> {
- PointData pd = md.getData()
- .getPoints()
- .stream()
- .findFirst()
- .orElseThrow();
- assertInstanceOf(HistogramPointData.class, pd, "Expected
HistogramPointData");
- HistogramPointData hpd = (HistogramPointData) pd;
- assertEquals(1L, hpd.getCount());
- assertTrue(hpd.getMin() >= DELAY);
- })
- .count();
- assertTrue(dataCount > 0, "No metric data found with name A");
+ long dataCount = logs.stream()
+ .map(LogRecord::getParameters)
+ .filter(Objects::nonNull)
+ .flatMap(Arrays::stream)
+ .filter(MetricData.class::isInstance)
+ .map(MetricData.class::cast)
+ .filter(md -> "A".equals(md.getName()))
+ .peek(md -> {
+ PointData pd = md.getData()
+ .getPoints()
+ .stream()
+ .findFirst()
+ .orElseThrow();
+ assertInstanceOf(HistogramPointData.class, pd,
"Expected HistogramPointData");
+ HistogramPointData hpd = (HistogramPointData) pd;
+ assertEquals(1L, hpd.getCount());
+ assertTrue(hpd.getMin() >= DELAY);
+ })
+ .count();
+ assertTrue(dataCount > 0, "No metric data found with name A");
+ });
MockEndpoint.assertIsSatisfied(context);
}