Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public int sendRequest(
response = proxy.put_success(param, isTestServer, requestId);
} else if (proxyMethodName.equals("get_error")) {
response = proxy.get_error(param, isTestServer, requestId);
} else if (proxyMethodName.equals("get_client_error")) {
response = proxy.get_client_error(param, isTestServer, requestId);
} else {
throw new IllegalArgumentException("Unknown method: " + proxyMethodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ Response get_error(
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);

@GET
@Path("client-error")
Response get_client_error(
@QueryParam("with") String param,
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);

@GET
@Path("success")
Response get_success(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,14 @@ abstract class HttpClientTest<REQUEST> extends InstrumentationSpecification {
junitTest.redirectToSecuredCopiesAuthHeader()
}

def "error span"() {
def "error span for #path"() {
expect:
junitTest.errorSpan()
junitTest.errorSpan(path, statusCode)

where:
path | statusCode
"/client-error" | 400
"/error" | 500
}

def "reuse request"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down Expand Up @@ -437,10 +438,11 @@ void redirectToSecuredCopiesAuthHeader() throws Exception {

// TODO: add basic auth scenario

@Test
void errorSpan() {
@ParameterizedTest
@CsvSource({"/error,500", "/client-error,400"})
void errorSpan(String path, int responseCode) {
String method = "GET";
URI uri = resolveAddress("/error");
URI uri = resolveAddress(path);

testing.runWithSpan(
"parent",
Expand All @@ -456,7 +458,9 @@ void errorSpan() {
trace -> {
trace.hasSpansSatisfyingExactly(
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
span -> assertClientSpan(span, uri, method, 500, null).hasParent(trace.getSpan(0)),
span ->
assertClientSpan(span, uri, method, responseCode, null)
.hasParent(trace.getSpan(0)),
span -> assertServerSpan(span).hasParent(trace.getSpan(1)));
});
}
Expand Down
Loading