Skip to content

Commit

Permalink
minor cleanups a potential flaky fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gregw committed Sep 1, 2024
1 parent ebc5e55 commit 3d5a58a
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class LargeHeaderTest
{
Expand Down Expand Up @@ -79,7 +80,7 @@ public void setup() throws Exception
}

@Override
public boolean handle(Request request, Response response, Callback callback) throws Exception
public boolean handle(Request request, Response response, Callback callback)
{
String idCount = request.getHeaders().get("X-Count");
LOG.debug("X-Count: {} [handle]", idCount);
Expand Down Expand Up @@ -245,8 +246,11 @@ else if (response.getStatus() == 500)
throw issues;
}

for (Future<Void> future : futures)
future.get(2, TimeUnit.SECONDS);

executorService.shutdown();
executorService.awaitTermination(timeout * 2, TimeUnit.SECONDS);
assertTrue(executorService.awaitTermination(timeout * 2, TimeUnit.SECONDS));
assertEquals(iterations, count500.get(), () ->
{
return """
Expand Down Expand Up @@ -297,12 +301,7 @@ public void testLargeHeaderNewConnectionsSequential() throws Throwable
}
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
int status = response.getStatus();
if (response == null)
{
LOG.warn("X-Count: {} - Empty Parsed Response", count);
countEmpty.incrementAndGet();
}
else if (status == 500)
if (status == 500)
{
long contentLength = response.getLongField(HttpHeader.CONTENT_LENGTH);
String responseBody = response.getContent();
Expand All @@ -326,15 +325,13 @@ else if (status == 500)
}

assertEquals(iterations, count500.get(), () ->
{
return """
"""
All tasks did not fail as expected.
Iterations: %d
Count (500 response status) [expected]: %d
Count (empty responses): %d
Count (throwables): %d
Count (other status codes): %d
""".formatted(iterations, count500.get(), countEmpty.get(), countFailure.get(), countOther.get());
});
""".formatted(iterations, count500.get(), countEmpty.get(), countFailure.get(), countOther.get()));
}
}

0 comments on commit 3d5a58a

Please sign in to comment.