Instead of using the locally crafted `serviceContainerCount()` utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit f874f8b6fd10a180cc47d7a9829dff63233ee20c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -7,9 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 | 9 |
"github.com/docker/docker/api/types/container" |
| 10 |
- "github.com/docker/docker/api/types/filters" |
|
| 11 | 10 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 12 |
- "github.com/docker/docker/client" |
|
| 13 | 11 |
"github.com/docker/docker/integration/internal/swarm" |
| 14 | 12 |
"github.com/google/go-cmp/cmp" |
| 15 | 13 |
"gotest.tools/assert" |
| ... | ... |
@@ -38,7 +36,7 @@ func TestInspect(t *testing.T) {
|
| 38 | 38 |
assert.NilError(t, err) |
| 39 | 39 |
|
| 40 | 40 |
id := resp.ID |
| 41 |
- poll.WaitOn(t, serviceContainerCount(client, id, instances)) |
|
| 41 |
+ poll.WaitOn(t, swarm.RunningTasksCount(client, id, instances)) |
|
| 42 | 42 |
|
| 43 | 43 |
service, _, err := client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
|
| 44 | 44 |
assert.NilError(t, err) |
| ... | ... |
@@ -134,21 +132,3 @@ func fullSwarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec {
|
| 134 | 134 |
}, |
| 135 | 135 |
} |
| 136 | 136 |
} |
| 137 |
- |
|
| 138 |
-func serviceContainerCount(client client.ServiceAPIClient, id string, count uint64) func(log poll.LogT) poll.Result {
|
|
| 139 |
- return func(log poll.LogT) poll.Result {
|
|
| 140 |
- filter := filters.NewArgs() |
|
| 141 |
- filter.Add("service", id)
|
|
| 142 |
- tasks, err := client.TaskList(context.Background(), types.TaskListOptions{
|
|
| 143 |
- Filters: filter, |
|
| 144 |
- }) |
|
| 145 |
- switch {
|
|
| 146 |
- case err != nil: |
|
| 147 |
- return poll.Error(err) |
|
| 148 |
- case len(tasks) == int(count): |
|
| 149 |
- return poll.Success() |
|
| 150 |
- default: |
|
| 151 |
- return poll.Continue("task count at %d waiting for %d", len(tasks), count)
|
|
| 152 |
- } |
|
| 153 |
- } |
|
| 154 |
-} |