mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #38558 from thaJeztah/pass_client_instead_of_daemon
GetRunningTasks: pass client instead of daemon
This commit is contained in:
commit
beef00cb26
3 changed files with 10 additions and 12 deletions
|
@ -269,7 +269,7 @@ func TestTemplatedConfig(t *testing.T) {
|
|||
|
||||
var tasks []swarmtypes.Task
|
||||
waitAndAssert(t, 60*time.Second, func(t *testing.T) bool {
|
||||
tasks = swarm.GetRunningTasks(t, d, serviceID)
|
||||
tasks = swarm.GetRunningTasks(t, client, serviceID)
|
||||
return len(tasks) > 0
|
||||
})
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
swarmtypes "github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/internal/test/daemon"
|
||||
"github.com/docker/docker/internal/test/environment"
|
||||
"gotest.tools/assert"
|
||||
|
@ -180,19 +181,16 @@ func ServiceWithSysctls(sysctls map[string]string) ServiceSpecOpt {
|
|||
}
|
||||
|
||||
// GetRunningTasks gets the list of running tasks for a service
|
||||
func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmtypes.Task {
|
||||
func GetRunningTasks(t *testing.T, c client.ServiceAPIClient, serviceID string) []swarmtypes.Task {
|
||||
t.Helper()
|
||||
client := d.NewClientT(t)
|
||||
defer client.Close()
|
||||
|
||||
filterArgs := filters.NewArgs()
|
||||
filterArgs.Add("desired-state", "running")
|
||||
filterArgs.Add("service", serviceID)
|
||||
tasks, err := c.TaskList(context.Background(), types.TaskListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
filters.Arg("service", serviceID),
|
||||
filters.Arg("desired-state", "running"),
|
||||
),
|
||||
})
|
||||
|
||||
options := types.TaskListOptions{
|
||||
Filters: filterArgs,
|
||||
}
|
||||
tasks, err := client.TaskList(context.Background(), options)
|
||||
assert.NilError(t, err)
|
||||
return tasks
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ func TestTemplatedSecret(t *testing.T) {
|
|||
|
||||
var tasks []swarmtypes.Task
|
||||
waitAndAssert(t, 60*time.Second, func(t *testing.T) bool {
|
||||
tasks = swarm.GetRunningTasks(t, d, serviceID)
|
||||
tasks = swarm.GetRunningTasks(t, client, serviceID)
|
||||
return len(tasks) > 0
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue