This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 440137a58e8 Improve tracing test diagnostics for flaky test
investigation (#2999)
440137a58e8 is described below
commit 440137a58e82769ada0a4fc8b431f288ff78dc53
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri May 8 01:32:13 2026 +0200
Improve tracing test diagnostics for flaky test investigation (#2999)
* Improve tracing test diagnostics: use untilAsserted with span list output
Replace await().until(() -> spans.size() == N) with
await().untilAsserted(() -> assertThat(message, size, equalTo(N)))
across all tracing system tests. When the Awaitility wait times out,
the error message now includes the actual span count and the full
list of collected spans, making it much easier to diagnose whether
the failure is caused by missing spans, extra spans from cross-test
contamination, or a timing issue.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* Extract HasSize matcher to reduce assertion duplication in tracing tests
Address review feedback: replace verbose untilAsserted assertions with
a custom HasSize matcher that includes span list contents on mismatch.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../test/java/org/apache/cxf/systest/HasSize.java | 52 ++++++++++++++++++++++
.../brave/jaxrs/AbstractBraveTracingTest.java | 13 +++---
.../brave/jaxws/AbstractBraveTracingTest.java | 4 +-
.../JaxrsOpenTelemetryTracingTest.java | 22 ++++-----
.../opentracing/JaxrsOpenTracingTracingTest.java | 22 ++++-----
.../JaxwsOpenTelemetryTracingTest.java | 6 +--
.../opentracing/JaxwsOpenTracingTracingTest.java | 6 +--
7 files changed, 84 insertions(+), 41 deletions(-)
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/HasSize.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/HasSize.java
new file mode 100644
index 00000000000..af74e6cb784
--- /dev/null
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/HasSize.java
@@ -0,0 +1,52 @@
+/**
+ * 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.cxf.systest;
+
+import java.util.Collection;
+
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+public class HasSize extends TypeSafeMatcher<Collection<?>> {
+ private final int expectedSize;
+
+ public HasSize(int expectedSize) {
+ this.expectedSize = expectedSize;
+ }
+
+ @Override
+ protected boolean matchesSafely(Collection<?> collection) {
+ return collection.size() == expectedSize;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("a collection with size
").appendValue(expectedSize);
+ }
+
+ @Override
+ protected void describeMismatchSafely(Collection<?> collection,
Description description) {
+ description.appendText("size was ").appendValue(collection.size())
+ .appendText(", contents: ").appendValue(collection);
+ }
+
+ public static HasSize hasSize(int size) {
+ return new HasSize(size);
+ }
+}
diff --git
a/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxrs/AbstractBraveTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxrs/AbstractBraveTracingTest.java
index a7db3b275a7..c7839595cf3 100644
---
a/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxrs/AbstractBraveTracingTest.java
+++
b/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxrs/AbstractBraveTracingTest.java
@@ -49,6 +49,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import static org.apache.cxf.systest.HasSize.hasSize;
import static
org.apache.cxf.systest.brave.BraveTestSupport.PARENT_SPAN_ID_NAME;
import static org.apache.cxf.systest.brave.BraveTestSupport.SAMPLED_NAME;
import static org.apache.cxf.systest.brave.BraveTestSupport.SPAN_ID_NAME;
@@ -265,9 +266,9 @@ public abstract class AbstractBraveTracingTest extends
AbstractClientServerTestB
}
// Await till flush happens, usually a second is enough
- await().atMost(Duration.ofSeconds(5L)).until(()->
TestSpanHandler.getAllSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
+ assertThat(TestSpanHandler.getAllSpans(), hasSize(4)));
- assertThat(TestSpanHandler.getAllSpans().size(), equalTo(4));
assertThat(TestSpanHandler.getAllSpans().get(3).name(), equalTo("test
span"));
}
@@ -292,9 +293,9 @@ public abstract class AbstractBraveTracingTest extends
AbstractClientServerTestB
}
// Await till flush happens, usually a second is enough
- await().atMost(Duration.ofSeconds(5L)).until(()->
TestSpanHandler.getAllSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
+ assertThat(TestSpanHandler.getAllSpans(), hasSize(4)));
- assertThat(TestSpanHandler.getAllSpans().size(), equalTo(4));
assertThat(TestSpanHandler.getAllSpans().get(3).name(), equalTo("test
span"));
}
@@ -340,8 +341,8 @@ public abstract class AbstractBraveTracingTest extends
AbstractClientServerTestB
try {
client.get();
} finally {
- await().atMost(Duration.ofSeconds(5L)).until(()->
TestSpanHandler.getAllSpans().size() == 2);
- assertThat(TestSpanHandler.getAllSpans().size(), equalTo(2));
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
+ assertThat(TestSpanHandler.getAllSpans(), hasSize(2)));
assertThat(TestSpanHandler.getAllSpans().get(0).name(),
equalTo("GET " + client.getCurrentURI()));
assertThat(TestSpanHandler.getAllSpans().get(0).tags(),
hasKey("error"));
assertThat(TestSpanHandler.getAllSpans().get(1).name(),
equalTo("GET /bookstore/books/long"));
diff --git
a/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxws/AbstractBraveTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxws/AbstractBraveTracingTest.java
index 64f6ebbaba1..ddce0e50ebf 100644
---
a/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxws/AbstractBraveTracingTest.java
+++
b/systests/tracing/src/test/java/org/apache/cxf/systest/brave/jaxws/AbstractBraveTracingTest.java
@@ -45,6 +45,7 @@ import
org.apache.cxf.testutil.common.AbstractClientServerTestBase;
import org.junit.Test;
+import static org.apache.cxf.systest.HasSize.hasSize;
import static
org.apache.cxf.systest.brave.BraveTestSupport.PARENT_SPAN_ID_NAME;
import static org.apache.cxf.systest.brave.BraveTestSupport.SAMPLED_NAME;
import static org.apache.cxf.systest.brave.BraveTestSupport.SPAN_ID_NAME;
@@ -204,7 +205,8 @@ public abstract class AbstractBraveTracingTest extends
AbstractClientServerTestB
service.orderBooks();
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(() ->
TestSpanHandler.getAllSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
+ assertThat(TestSpanHandler.getAllSpans(), hasSize(2)));
assertThat(TestSpanHandler.getAllSpans().get(0).name(),
equalTo("POST /BookStore"));
assertThat(TestSpanHandler.getAllSpans().get(1).name(),
diff --git
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/JaxrsOpenTelemetryTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/JaxrsOpenTelemetryTracingTest.java
index f49a46e068a..5da7c704b9d 100644
---
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/JaxrsOpenTelemetryTracingTest.java
+++
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentelemetry/JaxrsOpenTelemetryTracingTest.java
@@ -79,6 +79,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import static org.apache.cxf.systest.HasSize.hasSize;
import static
org.apache.cxf.systest.jaxrs.tracing.opentelemetry.HasAttribute.hasAttribute;
import static
org.apache.cxf.systest.jaxrs.tracing.opentelemetry.HasSpan.hasSpan;
import static
org.apache.cxf.systest.jaxrs.tracing.opentelemetry.IsLogContaining.hasItem;
@@ -257,10 +258,9 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
final Response r =
withTrace(createWebClient("/bookstore/books/async")).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(2)));
final List<SpanData> spans = getSpansSorted();
- assertThat(spans.size(), equalTo(2));
assertEquals("Processing books", spans.get(0).getName());
assertEquals("GET /bookstore/books/async", spans.get(1).getName());
@@ -287,10 +287,9 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
final Response r = createWebClient("/bookstore/books/async").get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(2)));
final List<SpanData> spans = getSpansSorted();
- assertThat(spans.size(), equalTo(2));
assertThat(spans.get(0).getName(), equalTo("Processing books"));
assertThat(spans.get(1).getName(), equalTo("GET
/bookstore/books/async"));
}
@@ -303,9 +302,8 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
final Response r = client.async().get().get(1L, TimeUnit.SECONDS);
assertEquals(Status.OK.getStatusCode(), r.getStatus());
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 3);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(3)));
- assertThat(otelRule.getSpans().size(), equalTo(3));
assertThat(otelRule.getSpans().get(0).getName(), equalTo("Get Books"));
assertThat(otelRule.getSpans().get(1).getName(), equalTo("GET
/bookstore/books"));
assertThat(otelRule.getSpans().get(1).getKind(),
equalTo(SpanKind.SERVER));
@@ -373,9 +371,8 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
}
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(4)));
- assertThat(otelRule.getSpans().size(), equalTo(4));
assertThat(otelRule.getSpans().get(3).getName(), equalTo("test span"));
assertThat(otelRule.getSpans().get(3).getParentSpanContext().isValid(),
equalTo(false));
}
@@ -392,9 +389,8 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
assertThat(Span.current().getSpanContext().getSpanId(),
equalTo(span.getSpanContext().getSpanId()));
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 3);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(3)));
- assertThat(otelRule.getSpans().size(), equalTo(3));
assertThat(otelRule.getSpans().get(0).getName(), equalTo("Get
Books"));
assertThat(otelRule.getSpans().get(0).getParentSpanContext(),
notNullValue());
assertThat(otelRule.getSpans().get(1).getName(), equalTo("GET
/bookstore/books"));
@@ -406,9 +402,8 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
}
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(4)));
- assertThat(otelRule.getSpans().size(), equalTo(4));
assertThat(otelRule.getSpans().get(3).getName(), equalTo("test span"));
assertThat(otelRule.getSpans().get(3).getParentSpanContext().isValid(),
equalTo(false));
}
@@ -443,8 +438,7 @@ public class JaxrsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
try {
client.get();
} finally {
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 2);
- assertThat(otelRule.getSpans().toString(),
otelRule.getSpans().size(), equalTo(2));
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(2)));
assertThat(otelRule.getSpans().get(0).getName(), equalTo("GET " +
client.getCurrentURI()));
assertThat(otelRule.getSpans().get(0).getStatus().getStatusCode(),
equalTo(StatusCode.ERROR));
assertThat(otelRule.getSpans().get(1).getName(), equalTo("GET
/bookstore/books/long"));
diff --git
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentracing/JaxrsOpenTracingTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentracing/JaxrsOpenTracingTracingTest.java
index da278ba6f20..5207ff5ed48 100644
---
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentracing/JaxrsOpenTracingTracingTest.java
+++
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/opentracing/JaxrsOpenTracingTracingTest.java
@@ -70,6 +70,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import static org.apache.cxf.systest.HasSize.hasSize;
import static org.apache.cxf.systest.jaxrs.tracing.opentracing.HasSpan.hasSpan;
import static
org.apache.cxf.systest.jaxrs.tracing.opentracing.IsLogContaining.hasItem;
import static
org.apache.cxf.systest.jaxrs.tracing.opentracing.IsTagContaining.hasItem;
@@ -199,10 +200,9 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
final Response r =
withTrace(createWebClient("/bookstore/books/async"), spanId).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(2)));
final List<JaegerSpan> spans = getSpansSorted();
- assertThat(spans.size(), equalTo(2));
assertEquals("Processing books", spans.get(0).getOperationName());
assertEquals("GET /bookstore/books/async",
spans.get(1).getOperationName());
assertThat(spans.get(1).getReferences(), not(empty()));
@@ -226,10 +226,9 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
final Response r = createWebClient("/bookstore/books/async").get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(2)));
final List<JaegerSpan> spans = getSpansSorted();
- assertThat(spans.size(), equalTo(2));
assertThat(spans.get(0).getOperationName(), equalTo("Processing
books"));
assertThat(spans.get(1).getOperationName(), equalTo("GET
/bookstore/books/async"));
}
@@ -241,9 +240,8 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
final Response r = client.async().get().get(1L, TimeUnit.SECONDS);
assertEquals(Status.OK.getStatusCode(), r.getStatus());
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 3);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(3)));
- assertThat(REPORTER.getSpans().size(), equalTo(3));
assertThat(REPORTER.getSpans().get(0).getOperationName(), equalTo("Get
Books"));
assertThat(REPORTER.getSpans().get(1).getOperationName(), equalTo("GET
/bookstore/books"));
assertThat(REPORTER.getSpans().get(1).getTags(),
hasItem(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER));
@@ -325,9 +323,8 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
}
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(4)));
- assertThat(REPORTER.getSpans().size(), equalTo(4));
assertThat(REPORTER.getSpans().get(3).getOperationName(),
equalTo("test span"));
assertThat(REPORTER.getSpans().get(3).getReferences(), empty());
}
@@ -342,9 +339,8 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
assertEquals(Status.OK.getStatusCode(), r.getStatus());
assertThat(tracer.activeSpan().context(), equalTo(span.context()));
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 3);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(3)));
- assertThat(REPORTER.getSpans().size(), equalTo(3));
assertThat(REPORTER.getSpans().get(0).getOperationName(),
equalTo("Get Books"));
assertThat(REPORTER.getSpans().get(0).getReferences(),
not(empty()));
assertThat(REPORTER.getSpans().get(1).getOperationName(),
equalTo("GET /bookstore/books"));
@@ -356,9 +352,8 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
}
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(4)));
- assertThat(REPORTER.getSpans().size(), equalTo(4));
assertThat(REPORTER.getSpans().get(3).getOperationName(),
equalTo("test span"));
assertThat(REPORTER.getSpans().get(3).getReferences(), empty());
}
@@ -391,8 +386,7 @@ public class JaxrsOpenTracingTracingTest extends
AbstractClientServerTestBase {
try {
client.get();
} finally {
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 2);
- assertThat(REPORTER.getSpans().toString(),
REPORTER.getSpans().size(), equalTo(2));
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(2)));
assertThat(REPORTER.getSpans().get(0).getOperationName(),
equalTo("GET " + client.getCurrentURI()));
assertThat(REPORTER.getSpans().get(0).getTags(),
hasItem(Tags.ERROR.getKey(), Boolean.TRUE));
assertThat(REPORTER.getSpans().get(1).getOperationName(),
equalTo("GET /bookstore/books/long"));
diff --git
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/JaxwsOpenTelemetryTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/JaxwsOpenTelemetryTracingTest.java
index 821b57e943e..333893e9da0 100644
---
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/JaxwsOpenTelemetryTracingTest.java
+++
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentelemetry/JaxwsOpenTelemetryTracingTest.java
@@ -66,6 +66,7 @@ import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
+import static org.apache.cxf.systest.HasSize.hasSize;
import static
org.apache.cxf.systest.jaxrs.tracing.opentelemetry.HasAttribute.hasAttribute;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.containsString;
@@ -247,9 +248,8 @@ public class JaxwsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
}
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(4)));
- assertThat(otelRule.getSpans().size(), equalTo(4));
assertThat(otelRule.getSpans().get(3).getName(), equalTo("test
span"));
assertThat(otelRule.getSpans().get(3).getParentSpanContext().isValid(),
equalTo(false));
}
@@ -331,7 +331,7 @@ public class JaxwsOpenTelemetryTracingTest extends
AbstractClientServerTestBase
service.orderBooks();
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(() ->
otelRule.getSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(otelRule.getSpans(), hasSize(2)));
assertThat(otelRule.getSpans().get(0).getName(), equalTo("POST
/BookStore"));
assertThat(otelRule.getSpans().get(1).getName(),
diff --git
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/JaxwsOpenTracingTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/JaxwsOpenTracingTracingTest.java
index d3f9f5e4384..88d84de2996 100644
---
a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/JaxwsOpenTracingTracingTest.java
+++
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxws/tracing/opentracing/JaxwsOpenTracingTracingTest.java
@@ -57,6 +57,7 @@ import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.apache.cxf.systest.HasSize.hasSize;
import static
org.apache.cxf.systest.jaxrs.tracing.opentracing.IsTagContaining.hasItem;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -178,9 +179,8 @@ public class JaxwsOpenTracingTracingTest extends
AbstractClientServerTestBase {
}
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(()->
REPORTER.getSpans().size() == 4);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(4)));
- assertThat(REPORTER.getSpans().size(), equalTo(4));
assertThat(REPORTER.getSpans().get(3).getOperationName(),
equalTo("test span"));
assertThat(REPORTER.getSpans().get(3).getReferences(), empty());
}
@@ -234,7 +234,7 @@ public class JaxwsOpenTracingTracingTest extends
AbstractClientServerTestBase {
service.orderBooks();
// Await till flush happens, usually every second
- await().atMost(Duration.ofSeconds(5L)).until(() ->
REPORTER.getSpans().size() == 2);
+ await().atMost(Duration.ofSeconds(5L)).untilAsserted(() ->
assertThat(REPORTER.getSpans(), hasSize(2)));
assertThat(REPORTER.getSpans().get(0).getOperationName(),
equalTo("POST /BookStore"));
assertThat(REPORTER.getSpans().get(1).getOperationName(),