Skip to content

Commit

Permalink
Ignore span oder in flaky test (#6060)
Browse files Browse the repository at this point in the history
* Ignore span oder for http client connectionErrorUnopenedPortWithCallback test on jdk8

* fix spelling
  • Loading branch information
laurit authored May 18, 2022
1 parent 4d79013 commit beb00cd
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -554,14 +555,25 @@ void connectionErrorUnopenedPortWithCallback() throws Exception {

testing.waitAndAssertTraces(
trace -> {
trace.hasSpansSatisfyingExactly(
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
span ->
assertClientSpan(span, uri, method, null)
.hasParent(trace.getSpan(0))
.hasException(clientError),
span ->
span.hasName("callback").hasKind(SpanKind.INTERNAL).hasParent(trace.getSpan(0)));
List<Consumer<SpanDataAssert>> spanAsserts =
Arrays.asList(
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
span ->
assertClientSpan(span, uri, method, null)
.hasParent(trace.getSpan(0))
.hasException(clientError),
span ->
span.hasName("callback")
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(0)));
boolean jdk8 = "1.8".equals(System.getProperty("java.specification.version"));
if (jdk8) {
// on some netty based http clients order of `CONNECT` and `callback` spans isn't
// guaranteed when running on jdk8
trace.hasSpansSatisfyingExactlyInAnyOrder(spanAsserts);
} else {
trace.hasSpansSatisfyingExactly(spanAsserts);
}
});
}

Expand Down

0 comments on commit beb00cd

Please sign in to comment.