mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #39881 from thaJeztah/inspect_test_use_RunningTasksCount
integration: TestInspect(): use swarm.RunningTasksCount
This commit is contained in:
commit
15c25714e8
1 changed files with 1 additions and 21 deletions
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue