Commit 914b3588 authored by Andy Wilkinson's avatar Andy Wilkinson

Update test as response may be received before server has deleted file

Previously, the heap dump endpoint test asserted that the temporary
heap dump file had been deleted as soon as the client received a
response. This led to intermittent test failures as the input
stream is closed after its contents have been sent to the client,
creating a race condition between the client receiving the response
and then asserting that the file had been deleted and the server
close the input stream and deleting the temporary file.

This commit updates the test so that, after receiving the response, it
will wait for up to 5 seconds for the server to have deleted the
temporary heap dump file.
parent 41e6b2ad
......@@ -69,6 +69,14 @@ public class HeapDumpWebEndpointWebIntegrationTests {
client.get().uri("/application/heapdump").exchange().expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_OCTET_STREAM)
.expectBody(String.class).isEqualTo("HEAPDUMP");
assertHeapDumpFileIsDeleted();
}
private void assertHeapDumpFileIsDeleted() throws InterruptedException {
long end = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < end && this.endpoint.file.exists()) {
Thread.sleep(100);
}
assertThat(this.endpoint.file.exists()).isFalse();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment