mirror of
https://github.com/moby/moby.git
synced 2025-10-24 09:13:09 +03:00
Introduce cli.Wait* fuctions
These replace `wait*` functions from `docker_utils_test.go` and work more or less like other `cli` functions. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
committed by
Vincent Demeester
parent
10e171cd94
commit
db35c2a5a8
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/versions/v1p20"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
icmd "github.com/docker/docker/pkg/testutil/cmd"
|
||||
@@ -1797,18 +1798,16 @@ func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) {
|
||||
testRequires(c, IsAmd64, DaemonIsLinux, Network)
|
||||
|
||||
// Create a new network
|
||||
dockerCmd(c, "network", "create", "--subnet=192.168.10.0/24", "--gateway=192.168.10.1", "-o", "com.docker.network.bridge.host_binding_ipv4=192.168.10.1", "testbind")
|
||||
cli.DockerCmd(c, "network", "create", "--subnet=192.168.10.0/24", "--gateway=192.168.10.1", "-o", "com.docker.network.bridge.host_binding_ipv4=192.168.10.1", "testbind")
|
||||
assertNwIsAvailable(c, "testbind")
|
||||
|
||||
// Launch the server, this will remain listening on an exposed port and reply to any request in a ping/pong fashion
|
||||
cmd := "while true; do echo hello | nc -w 1 -lu 8080; done"
|
||||
_, _, err := dockerCmdWithError("run", "-d", "--name", "server", "--net", "testbind", "-p", "8080:8080/udp", "appropriate/nc", "sh", "-c", cmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
cli.DockerCmd(c, "run", "-d", "--name", "server", "--net", "testbind", "-p", "8080:8080/udp", "appropriate/nc", "sh", "-c", cmd)
|
||||
|
||||
// Launch a container client, here the objective is to create a flow that is natted in order to expose the bug
|
||||
cmd = "echo world | nc -q 1 -u 192.168.10.1 8080"
|
||||
_, _, err = dockerCmdWithError("run", "-d", "--name", "client", "--net=host", "appropriate/nc", "sh", "-c", cmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
cli.DockerCmd(c, "run", "-d", "--name", "client", "--net=host", "appropriate/nc", "sh", "-c", cmd)
|
||||
|
||||
// Get all the flows using netlink
|
||||
flows, err := netlink.ConntrackTableList(netlink.ConntrackTable, syscall.AF_INET)
|
||||
@@ -1826,8 +1825,7 @@ func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) {
|
||||
c.Assert(flowMatch, checker.Equals, 1)
|
||||
|
||||
// Now delete the server, this will trigger the conntrack cleanup
|
||||
err = deleteContainer("server")
|
||||
c.Assert(err, checker.IsNil)
|
||||
cli.DockerCmd(c, "rm", "-fv", "server")
|
||||
|
||||
// Fetch again all the flows and validate that there is no server flow in the conntrack laying around
|
||||
flows, err = netlink.ConntrackTableList(netlink.ConntrackTable, syscall.AF_INET)
|
||||
|
||||
Reference in New Issue
Block a user