Skip to content

Commit

Permalink
Fixed flaky test EventsHandlerTest by increasing the time checks, as …
Browse files Browse the repository at this point in the history
…Jenkins can be really slow.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Nov 18, 2024
1 parent 6baadeb commit 0b851fc
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ private void sleep(Fields query, String fieldName)
startServer(transport, eventsHandler);
startClient(transport);

URI uri = URI.create(newURI(transport).toASCIIString() + "?handling=500&succeeding=500");
long delayMs = 500;
URI uri = URI.create(newURI(transport).toASCIIString() + "?handling=%d&succeeding=%d".formatted(delayMs, delayMs));

ContentResponse response = client.GET(uri);
assertThat(response.getStatus(), is(200));
Expand All @@ -307,9 +308,10 @@ private void sleep(Fields query, String fieldName)
assertThat(eventsHandler.getEvents().get(0).name, equalTo("onBeforeHandling"));
assertThat(eventsHandler.getEvents().get(0).delayInNs, greaterThan(0L));
assertThat(eventsHandler.getEvents().get(1).name, equalTo("onAfterHandling"));
assertThat(eventsHandler.getEvents().get(1).delayInNs - eventsHandler.getEvents().get(0).delayInNs, both(greaterThan(500_000_000L)).and(lessThan(600_000_000L)));
long delayNs = TimeUnit.MILLISECONDS.toNanos(delayMs);
assertThat(eventsHandler.getEvents().get(1).delayInNs - eventsHandler.getEvents().get(0).delayInNs, both(greaterThan(delayNs)).and(lessThan(2 * delayNs)));
assertThat(eventsHandler.getEvents().get(2).name, equalTo("onResponseBegin"));
assertThat(eventsHandler.getEvents().get(2).delayInNs - eventsHandler.getEvents().get(1).delayInNs, both(greaterThan(500_000_000L)).and(lessThan(600_000_000L)));
assertThat(eventsHandler.getEvents().get(2).delayInNs - eventsHandler.getEvents().get(1).delayInNs, both(greaterThan(delayNs)).and(lessThan(2 * delayNs)));
assertThat(eventsHandler.getEvents().get(3).name, equalTo("onComplete"));
assertThat(eventsHandler.getEvents().get(3).delayInNs - eventsHandler.getEvents().get(2).delayInNs, greaterThan(0L));
}
Expand Down

0 comments on commit 0b851fc

Please sign in to comment.