Skip to content

Commit 400f3f5

Browse files
committed
add parameter test
1 parent 40bc16f commit 400f3f5

File tree

2 files changed

+4
-35
lines changed

2 files changed

+4
-35
lines changed

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.junit.jupiter.api.TestInstance;
5656
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
5757
import org.junit.jupiter.params.ParameterizedTest;
58+
import org.junit.jupiter.params.provider.CsvSource;
5859
import org.junit.jupiter.params.provider.ValueSource;
5960

6061
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@@ -437,8 +438,9 @@ void redirectToSecuredCopiesAuthHeader() throws Exception {
437438

438439
// TODO: add basic auth scenario
439440

440-
@Test
441-
void errorSpan() {
441+
@ParameterizedTest
442+
@CsvSource({"/error,500", "/client-error,400"})
443+
void errorSpan(String path, int resposeCode) {
442444
String method = "GET";
443445
URI uri = resolveAddress("/error");
444446

@@ -1029,34 +1031,6 @@ void spanEndsAfterHeadersReceived() throws Exception {
10291031
});
10301032
}
10311033

1032-
@Test
1033-
void requestClientError() throws Exception {
1034-
assumeTrue(options.getTestClientError());
1035-
1036-
URI uri = resolveAddress("/client-error");
1037-
String method = "GET";
1038-
1039-
testing.runWithSpan(
1040-
"parent",
1041-
() -> {
1042-
try {
1043-
doRequest(method, uri);
1044-
} catch (Throwable ignored) {
1045-
// ignored
1046-
}
1047-
});
1048-
1049-
testing.waitAndAssertTraces(
1050-
trace ->
1051-
trace.hasSpansSatisfyingExactly(
1052-
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
1053-
span ->
1054-
assertClientSpan(span, uri, method, 400, null)
1055-
.hasParent(trace.getSpan(0))
1056-
.hasStatus(StatusData.error()),
1057-
span -> assertServerSpan(span).hasParent(trace.getSpan(1))));
1058-
}
1059-
10601034
// Visible for spock bridge.
10611035
SpanDataAssert assertClientSpan(
10621036
SpanDataAssert span,

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/HttpClientTestOptions.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ public boolean isLowLevelInstrumentation() {
8989

9090
public abstract boolean getTestNonStandardHttpMethod();
9191

92-
public abstract boolean getTestClientError();
93-
9492
public abstract Function<URI, String> getHttpProtocolVersion();
9593

9694
@Nullable
@@ -133,7 +131,6 @@ default Builder withDefaults() {
133131
.setTestCallbackWithParent(true)
134132
.setTestErrorWithCallback(true)
135133
.setTestNonStandardHttpMethod(true)
136-
.setTestClientError(true)
137134
.setHttpProtocolVersion(uri -> "1.1");
138135
}
139136

@@ -177,8 +174,6 @@ default Builder withDefaults() {
177174

178175
Builder setTestNonStandardHttpMethod(boolean value);
179176

180-
Builder setTestClientError(boolean value);
181-
182177
Builder setHttpProtocolVersion(Function<URI, String> value);
183178

184179
@CanIgnoreReturnValue

0 commit comments

Comments
 (0)