Skip to content

Commit

Permalink
Make supervisord wait a single command (#1866)
Browse files Browse the repository at this point in the history
The integration tests wait for supervisord to be up before attempting
to start the brokers and proxies. Previously we were doing this by
checking for the existence of the supervisord socket
repeatedly. However, this spams the log.

This patch replaces the loop with a single bash command (a bash loop),
with the timeout built into the command.

Failure of the socket to appear also throws a exception (timeout
exits with 124), rather than returning a boolean which we were not
checking previously anyhow.
  • Loading branch information
ivankelly authored and merlimat committed Jun 1, 2018
1 parent 588ea6a commit 075e872
Showing 1 changed file with 3 additions and 18 deletions.
Expand Up @@ -200,24 +200,9 @@ public static boolean waitAllBrokersDown(DockerClient docker, String cluster) {
.reduce(true, (accum, res) -> accum && res); .reduce(true, (accum, res) -> accum && res);
} }


public static boolean waitSupervisord(DockerClient docker, String containerId) { public static void waitSupervisord(DockerClient docker, String containerId) {
int i = 50; DockerUtils.runCommand(docker, containerId, "timeout", "60", "bash", "-c",
while (i > 0) { "until test -S /var/run/supervisor/supervisor.sock; do sleep 0.1; done");
try {
DockerUtils.runCommand(docker, containerId, "test", "-S", "/var/run/supervisor/supervisor.sock");
return true;
} catch (Exception e) {
// supervisord not running
}
try {
Thread.sleep(100);
i++;
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
break;
}
}
return false;
} }


public static boolean startAllBrokers(DockerClient docker, String cluster) { public static boolean startAllBrokers(DockerClient docker, String cluster) {
Expand Down

0 comments on commit 075e872

Please sign in to comment.