Skip to content

Commit

Permalink
integration: TestInspect(): use swarm.RunningTasksCount
Browse files Browse the repository at this point in the history
Instead of using the locally crafted `serviceContainerCount()` utility

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Sep 9, 2019
1 parent 4ce0402 commit f874f8b
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions integration/service/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/swarm"
"github.com/google/go-cmp/cmp"
"gotest.tools/assert"
Expand Down Expand Up @@ -38,7 +36,7 @@ func TestInspect(t *testing.T) {
assert.NilError(t, err)

id := resp.ID
poll.WaitOn(t, serviceContainerCount(client, id, instances))
poll.WaitOn(t, swarm.RunningTasksCount(client, id, instances))

service, _, err := client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
assert.NilError(t, err)
Expand Down Expand Up @@ -134,21 +132,3 @@ func fullSwarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec {
},
}
}

func serviceContainerCount(client client.ServiceAPIClient, id string, count uint64) func(log poll.LogT) poll.Result {
return func(log poll.LogT) poll.Result {
filter := filters.NewArgs()
filter.Add("service", id)
tasks, err := client.TaskList(context.Background(), types.TaskListOptions{
Filters: filter,
})
switch {
case err != nil:
return poll.Error(err)
case len(tasks) == int(count):
return poll.Success()
default:
return poll.Continue("task count at %d waiting for %d", len(tasks), count)
}
}
}

0 comments on commit f874f8b

Please sign in to comment.