From 8e00e77a972c503fdea6ab4d43f4a5556b1ffae3 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Wed, 18 May 2022 16:11:27 +0300 Subject: [PATCH 1/2] Ignore span oder for http client connectionErrorUnopenedPortWithCallback test on jdk8 --- .../junit/http/AbstractHttpClientTest.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java index 4ff798e14c3c..f4bcad487cd2 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java @@ -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; @@ -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> 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 odering of `CONNECT` and `callback` span isn't + // guranteed when running on jdk8 + trace.hasSpansSatisfyingExactlyInAnyOrder(spanAsserts); + } else { + trace.hasSpansSatisfyingExactly(spanAsserts); + } }); } From e90f2ff0a3b0828798b363deb58c483c58589bd8 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Wed, 18 May 2022 17:43:11 +0300 Subject: [PATCH 2/2] fix spelling --- .../testing/junit/http/AbstractHttpClientTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java index f4bcad487cd2..301d05a0aa18 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java @@ -568,8 +568,8 @@ void connectionErrorUnopenedPortWithCallback() throws Exception { .hasParent(trace.getSpan(0))); boolean jdk8 = "1.8".equals(System.getProperty("java.specification.version")); if (jdk8) { - // on some netty based http clients odering of `CONNECT` and `callback` span isn't - // guranteed when running on 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);