Skip to content

Commit fc1cc72

Browse files
committed
Add body to http server concurrency test response
1 parent 71a7f8b commit fc1cc72

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ void highConcurrency() throws InterruptedException {
403403
TextMapPropagator propagator = GlobalOpenTelemetry.getPropagators().getTextMapPropagator();
404404
TextMapSetter<HttpRequestBuilder> setter = HttpRequestBuilder::header;
405405

406+
List<String> responses = new ArrayList<>();
406407
for (int i = 0; i < count; i++) {
407408
int index = i;
408409
HttpRequestBuilder request =
@@ -419,10 +420,22 @@ void highConcurrency() throws InterruptedException {
419420
client
420421
.execute(request.build())
421422
.aggregate()
422-
.whenComplete((result, throwable) -> latch.countDown());
423+
.whenComplete(
424+
(result, throwable) -> {
425+
latch.countDown();
426+
if (throwable != null) {
427+
responses.add(throwable.toString());
428+
} else {
429+
responses.add(result.status().code() + " " + result.contentUtf8());
430+
}
431+
});
423432
});
424433
}
425434
latch.await();
435+
assertThat(responses)
436+
.allSatisfy(
437+
response ->
438+
assertThat(response).isEqualTo(endpoint.getStatus() + " " + endpoint.getBody()));
426439

427440
assertHighConcurrency(count);
428441
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ServerEndpoint {
4747
public static final ServerEndpoint AUTH_ERROR =
4848
new ServerEndpoint("AUTH_ERROR", "basicsecured/endpoint", 401, null);
4949
public static final ServerEndpoint INDEXED_CHILD =
50-
new ServerEndpoint("INDEXED_CHILD", "child", 200, "");
50+
new ServerEndpoint("INDEXED_CHILD", "child", 200, "success");
5151

5252
public static final String ID_ATTRIBUTE_NAME = "test.request.id";
5353
public static final String ID_PARAMETER_NAME = "id";

0 commit comments

Comments
 (0)