Wait for request to return result in http client async concurrency test
@@ -754,18 +754,24 @@ public abstract class AbstractHttpClientTest<REQUEST> {
throw new AssertionError(e);
}
try {
+ RequestResult result =
testing.runWithSpan(
"Parent span " + index,
() -> {
Span.current().setAttribute("test.request.id", index);
- doRequestWithCallback(
+ return doRequestWithCallback(
method,
uri,
- Collections.singletonMap("test-request-id", String.valueOf(index)),
+ Collections.singletonMap(
+ "test-request-id", String.valueOf(index)),
() -> testing.runWithSpan("child", () -> {}));
});
- } catch (Exception e) {
- throw new AssertionError(e);
+ assertThat(result.get()).isEqualTo(200);
+ } catch (Throwable throwable) {
+ if (throwable instanceof AssertionError) {
+ throw (AssertionError) throwable;
+ }
+ throw new AssertionError(throwable);
}
};
pool.submit(job);
