Skip to content

Commit

Permalink
Improve Http2Test#testCloseMulti reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jul 10, 2024
1 parent e689c36 commit b2f2eb3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions vertx-core/src/test/java/io/vertx/tests/http/HttpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,36 @@ public void testCloseMulti() throws Exception {
.onComplete(onSuccess(connections::add));
}
waitUntil(() -> connections.size() == 4);
Set<String> actual = new HashSet<>();
Set<String> expected = new HashSet<>();
for (int i = 0;i < num;i++) {
Buffer body = awaitFuture(connections.get(i)
.request(requestOptions)
.compose(req -> req.send()
.compose(HttpClientResponse::body)
));
assertEquals("Server " + i, body.toString());
expected.add("Server " + i);
actual.add(body.toString());
}
assertEquals(expected, actual);
awaitFuture(servers[3].close());
int successes = 0;
int failures = 0;
for (int i = 0;i < num;i++) {
Future<Buffer> fut = connections.get(i)
.request(requestOptions)
.compose(req -> req.send()
.compose(HttpClientResponse::body)
);
if (i < num - 1) {
fut.onComplete(onSuccess(body -> complete()));
} else {
fut.onComplete(onFailure(err -> complete()));
try {
awaitFuture(fut);
successes++;
} catch (Exception e) {
failures++;
}
}
await();
assertEquals(3, successes);
assertEquals(1, failures);
}

@Rule
Expand Down

0 comments on commit b2f2eb3

Please sign in to comment.