Skip to content

Commit

Permalink
Make docker packaging test more resilient (elastic#111205)
Browse files Browse the repository at this point in the history
Wrap check for container shutdown log message in an `assertBusy()` to
deal with race conditions.

Closes elastic#111132
# Conflicts:
#	muted-tests.yml
  • Loading branch information
mark-vieira committed Jul 23, 2024
1 parent c9af95c commit 9da3ed1
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ public void test500Readiness() throws Exception {
assertBusy(() -> assertTrue(readinessProbe(9399)));
}

public void test600Interrupt() {
public void test600Interrupt() throws Exception {
waitForElasticsearch(installation, "elastic", PASSWORD);
final Result containerLogs = getContainerLogs();

Expand All @@ -1241,10 +1241,12 @@ public void test600Interrupt() {
final int maxPid = infos.stream().map(i -> i.pid()).max(Integer::compareTo).get();

sh.run("bash -c 'kill -int " + maxPid + "'"); // send ctrl+c to all java processes
final Result containerLogsAfter = getContainerLogs();

assertThat("Container logs should contain stopping ...", containerLogsAfter.stdout(), containsString("stopping ..."));
assertThat("No errors stdout", containerLogsAfter.stdout(), not(containsString("java.security.AccessControlException:")));
assertThat("No errors stderr", containerLogsAfter.stderr(), not(containsString("java.security.AccessControlException:")));
assertBusy(() -> {
final Result containerLogsAfter = getContainerLogs();
assertThat("Container logs should contain stopping ...", containerLogsAfter.stdout(), containsString("stopping ..."));
assertThat("No errors stdout", containerLogsAfter.stdout(), not(containsString("java.security.AccessControlException:")));
assertThat("No errors stderr", containerLogsAfter.stderr(), not(containsString("java.security.AccessControlException:")));
});
}
}

0 comments on commit 9da3ed1

Please sign in to comment.