Fix testListTaskWithCriteria
@@ -5290,7 +5290,9 @@ public class DefaultDockerClientTest {
sut.createService(spec);
await().until(numberOfTasks(sut), is(greaterThan(0)));
- final Task task = sut.listTasks().get(1);
+ final Task transientTask = sut.listTasks().get(1);
+ await().until(taskState(transientTask.id(), sut), is(transientTask.desiredState()));
+ final Task task = sut.inspectTask(transientTask.id());
final List<Task> tasksWithId = sut.listTasks(Task.find().taskId(task.id()).build());
assertThat(tasksWithId.size(), is(1));
@@ -5514,6 +5516,15 @@ public class DefaultDockerClientTest {
};
}
+ private Callable<String> taskState(final String taskId,
+ final DockerClient client) {
+ return new Callable<String>() {
+ public String call() throws Exception {
+ return client.inspectTask(taskId).status().state();
+ }
+ };
+ }
+
private static Matcher<PortConfig> portConfigWith(
final Matcher<String> nameMatcher, final Matcher<String> protocolMatcher,
final Matcher<Integer> targetPortMatcher, final Matcher<Integer> publishedPortMatcher,
