mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
waitAndAssert -> poll.WaitOn
go get -d golang.org/x/tools/cmd/eg && \ dir=$(go env GOPATH)/src/golang.org/x/tools && \ git -C "$dir" fetch https://github.com/tiborvass/tools handle-variadic && \ git -C "$dir" checkout 61a94b82347c29b3289e83190aa3dda74d47abbb && \ go install golang.org/x/tools/cmd/eg eg -w -t template.waitAndAssert.go ./integration-cli 2>&1 \ | awk '{print $2}' | while read file; do # removing vendor/ in import paths # not sure why eg adds them sed -E -i 's#^([\t]+").*/vendor/([^"]+)#\1\2#g' "$file" sed -E -i 's#\.\(eg_compareFunc\)##g' "$file" goimports -w "$file" done Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
@ -17,6 +17,7 @@ import (
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"gotest.tools/assert"
|
||||
"gotest.tools/icmd"
|
||||
"gotest.tools/poll"
|
||||
)
|
||||
|
||||
func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string) {
|
||||
@ -24,19 +25,21 @@ func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string
|
||||
assert.NilError(c, err)
|
||||
|
||||
for _, s := range kept {
|
||||
waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
|
||||
poll.WaitOn(c, pollCheck(c, func(*testing.T) (interface{}, string) {
|
||||
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
|
||||
assert.NilError(c, err)
|
||||
return out, ""
|
||||
}, checker.Contains, s)
|
||||
}, checker.Contains(s)), poll.WithTimeout(defaultReconciliationTimeout))
|
||||
|
||||
}
|
||||
|
||||
for _, s := range pruned {
|
||||
waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
|
||||
poll.WaitOn(c, pollCheck(c, func(*testing.T) (interface{}, string) {
|
||||
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
|
||||
assert.NilError(c, err)
|
||||
return out, ""
|
||||
}, checker.Not(checker.Contains(s)))
|
||||
}, checker.Not(checker.Contains(s))()), poll.WithTimeout(defaultReconciliationTimeout))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +67,7 @@ func (s *DockerSwarmSuite) TestPruneNetwork(c *testing.T) {
|
||||
"busybox", "top")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out) != "")
|
||||
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, replicas+1)
|
||||
poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(replicas+1)), poll.WithTimeout(defaultReconciliationTimeout))
|
||||
|
||||
// prune and verify
|
||||
pruneNetworkAndVerify(c, d, []string{"n1", "n3"}, []string{"n2", "n4"})
|
||||
@ -74,7 +77,7 @@ func (s *DockerSwarmSuite) TestPruneNetwork(c *testing.T) {
|
||||
assert.NilError(c, err)
|
||||
_, err = d.Cmd("service", "rm", serviceName)
|
||||
assert.NilError(c, err)
|
||||
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0)
|
||||
poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
|
||||
|
||||
pruneNetworkAndVerify(c, d, []string{}, []string{"n1", "n3"})
|
||||
}
|
||||
|
Reference in New Issue
Block a user