Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit f858816

Browse files
committed
integration: TestInspect(): use swarm.RunningTasksCount
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> Upstream-commit: 0459d8c7a6d4f1c82c5da2d9ebb4bfa3832c793a Component: engine
1 parent c1e33c6 commit f858816

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

components/engine/integration/service/inspect_test.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import (
77

88
"github.com/docker/docker/api/types"
99
"github.com/docker/docker/api/types/container"
10-
"github.com/docker/docker/api/types/filters"
1110
swarmtypes "github.com/docker/docker/api/types/swarm"
12-
"github.com/docker/docker/client"
1311
"github.com/docker/docker/integration/internal/swarm"
1412
"github.com/google/go-cmp/cmp"
1513
"gotest.tools/assert"
@@ -38,7 +36,7 @@ func TestInspect(t *testing.T) {
3836
assert.NilError(t, err)
3937

4038
id := resp.ID
41-
poll.WaitOn(t, serviceContainerCount(client, id, instances))
39+
poll.WaitOn(t, swarm.RunningTasksCount(client, id, instances))
4240

4341
service, _, err := client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
4442
assert.NilError(t, err)
@@ -134,21 +132,3 @@ func fullSwarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec {
134132
},
135133
}
136134
}
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-
}

0 commit comments

Comments
 (0)