Fix flaky DefaultDockerClientTest.testListTaskWithCriteria()
This test was failing a lot on Travis CI because of a race condition.
Example of a test failure.
Often times the task isn't present at the time `DockerClient.inspectTask()`
is called. Catch the exception and return "not found" if so.
@@ -137,6 +137,7 @@ import com.spotify.docker.client.exceptions.ImageNotFoundException;
import com.spotify.docker.client.exceptions.ImagePushFailedException;
import com.spotify.docker.client.exceptions.NetworkNotFoundException;
import com.spotify.docker.client.exceptions.NotFoundException;
+import com.spotify.docker.client.exceptions.TaskNotFoundException;
import com.spotify.docker.client.exceptions.UnsupportedApiVersionException;
import com.spotify.docker.client.exceptions.VolumeNotFoundException;
import com.spotify.docker.client.messages.AttachedNetwork;
@@ -5856,7 +5857,11 @@ public class DefaultDockerClientTest {
final DockerClient client) {
return new Callable<String>() {
public String call() throws Exception {
+ try {
return client.inspectTask(taskId).status().state();
+ } catch (final TaskNotFoundException e) {
+ return "not found";
+ }
}
};
}
