|
@@ -7,6 +7,7 @@ import (
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
|
|
+ "github.com/docker/docker/integration-cli/cli"
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
|
icmd "github.com/docker/docker/pkg/testutil/cmd"
|
|
icmd "github.com/docker/docker/pkg/testutil/cmd"
|
|
"github.com/go-check/check"
|
|
"github.com/go-check/check"
|
|
@@ -368,24 +369,23 @@ func (s *DockerSuite) TestDockerNetworkMacVlanBridgeNilParent(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkMacVlanBridgeInternalMode(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkMacVlanBridgeInternalMode(c *check.C) {
|
|
// macvlan bridge mode --internal containers can communicate inside the network but not externally
|
|
// macvlan bridge mode --internal containers can communicate inside the network but not externally
|
|
testRequires(c, DaemonIsLinux, macvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
|
|
testRequires(c, DaemonIsLinux, macvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
|
|
- dockerCmd(c, "network", "create", "--driver=macvlan", "--internal", "dm-internal")
|
|
|
|
|
|
+ cli.DockerCmd(c, "network", "create", "--driver=macvlan", "--internal", "dm-internal")
|
|
assertNwIsAvailable(c, "dm-internal")
|
|
assertNwIsAvailable(c, "dm-internal")
|
|
nr := getNetworkResource(c, "dm-internal")
|
|
nr := getNetworkResource(c, "dm-internal")
|
|
c.Assert(nr.Internal, checker.True)
|
|
c.Assert(nr.Internal, checker.True)
|
|
|
|
|
|
// start two containers on the same subnet
|
|
// start two containers on the same subnet
|
|
- dockerCmd(c, "run", "-d", "--net=dm-internal", "--name=first", "busybox", "top")
|
|
|
|
|
|
+ cli.DockerCmd(c, "run", "-d", "--net=dm-internal", "--name=first", "busybox", "top")
|
|
c.Assert(waitRun("first"), check.IsNil)
|
|
c.Assert(waitRun("first"), check.IsNil)
|
|
- dockerCmd(c, "run", "-d", "--net=dm-internal", "--name=second", "busybox", "top")
|
|
|
|
|
|
+ cli.DockerCmd(c, "run", "-d", "--net=dm-internal", "--name=second", "busybox", "top")
|
|
c.Assert(waitRun("second"), check.IsNil)
|
|
c.Assert(waitRun("second"), check.IsNil)
|
|
|
|
|
|
// access outside of the network should fail
|
|
// access outside of the network should fail
|
|
- result := dockerCmdWithTimeout(time.Second, "exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8")
|
|
|
|
|
|
+ result := cli.Docker(cli.Args("exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8"), cli.WithTimeout(time.Second))
|
|
c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})
|
|
c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})
|
|
|
|
|
|
// intra-network communications should succeed
|
|
// intra-network communications should succeed
|
|
- _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
|
|
|
|
- c.Assert(err, check.IsNil)
|
|
|
|
|
|
+ cli.DockerCmd(c, "exec", "second", "ping", "-c", "1", "first")
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL2NilParent(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL2NilParent(c *check.C) {
|
|
@@ -408,23 +408,22 @@ func (s *DockerSuite) TestDockerNetworkIpvlanL2NilParent(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL2InternalMode(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL2InternalMode(c *check.C) {
|
|
// ipvlan l2 mode --internal containers can communicate inside the network but not externally
|
|
// ipvlan l2 mode --internal containers can communicate inside the network but not externally
|
|
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
|
|
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
|
|
- dockerCmd(c, "network", "create", "--driver=ipvlan", "--internal", "di-internal")
|
|
|
|
|
|
+ cli.DockerCmd(c, "network", "create", "--driver=ipvlan", "--internal", "di-internal")
|
|
assertNwIsAvailable(c, "di-internal")
|
|
assertNwIsAvailable(c, "di-internal")
|
|
nr := getNetworkResource(c, "di-internal")
|
|
nr := getNetworkResource(c, "di-internal")
|
|
c.Assert(nr.Internal, checker.True)
|
|
c.Assert(nr.Internal, checker.True)
|
|
|
|
|
|
// start two containers on the same subnet
|
|
// start two containers on the same subnet
|
|
- dockerCmd(c, "run", "-d", "--net=di-internal", "--name=first", "busybox", "top")
|
|
|
|
|
|
+ cli.DockerCmd(c, "run", "-d", "--net=di-internal", "--name=first", "busybox", "top")
|
|
c.Assert(waitRun("first"), check.IsNil)
|
|
c.Assert(waitRun("first"), check.IsNil)
|
|
- dockerCmd(c, "run", "-d", "--net=di-internal", "--name=second", "busybox", "top")
|
|
|
|
|
|
+ cli.DockerCmd(c, "run", "-d", "--net=di-internal", "--name=second", "busybox", "top")
|
|
c.Assert(waitRun("second"), check.IsNil)
|
|
c.Assert(waitRun("second"), check.IsNil)
|
|
|
|
|
|
// access outside of the network should fail
|
|
// access outside of the network should fail
|
|
- result := dockerCmdWithTimeout(time.Second, "exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8")
|
|
|
|
|
|
+ result := cli.Docker(cli.Args("exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8"), cli.WithTimeout(time.Second))
|
|
c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})
|
|
c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})
|
|
// intra-network communications should succeed
|
|
// intra-network communications should succeed
|
|
- _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
|
|
|
|
- c.Assert(err, check.IsNil)
|
|
|
|
|
|
+ cli.DockerCmd(c, "exec", "second", "ping", "-c", "1", "first")
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL3NilParent(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL3NilParent(c *check.C) {
|
|
@@ -448,24 +447,23 @@ func (s *DockerSuite) TestDockerNetworkIpvlanL3NilParent(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL3InternalMode(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkIpvlanL3InternalMode(c *check.C) {
|
|
// ipvlan l3 mode --internal containers can communicate inside the network but not externally
|
|
// ipvlan l3 mode --internal containers can communicate inside the network but not externally
|
|
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
|
|
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
|
|
- dockerCmd(c, "network", "create", "--driver=ipvlan", "--subnet=172.28.230.0/24",
|
|
|
|
|
|
+ cli.DockerCmd(c, "network", "create", "--driver=ipvlan", "--subnet=172.28.230.0/24",
|
|
"--subnet=172.28.220.0/24", "-o", "ipvlan_mode=l3", "--internal", "di-internal-l3")
|
|
"--subnet=172.28.220.0/24", "-o", "ipvlan_mode=l3", "--internal", "di-internal-l3")
|
|
assertNwIsAvailable(c, "di-internal-l3")
|
|
assertNwIsAvailable(c, "di-internal-l3")
|
|
nr := getNetworkResource(c, "di-internal-l3")
|
|
nr := getNetworkResource(c, "di-internal-l3")
|
|
c.Assert(nr.Internal, checker.True)
|
|
c.Assert(nr.Internal, checker.True)
|
|
|
|
|
|
// start two containers on separate subnets
|
|
// start two containers on separate subnets
|
|
- dockerCmd(c, "run", "-d", "--ip=172.28.220.10", "--net=di-internal-l3", "--name=first", "busybox", "top")
|
|
|
|
|
|
+ cli.DockerCmd(c, "run", "-d", "--ip=172.28.220.10", "--net=di-internal-l3", "--name=first", "busybox", "top")
|
|
c.Assert(waitRun("first"), check.IsNil)
|
|
c.Assert(waitRun("first"), check.IsNil)
|
|
- dockerCmd(c, "run", "-d", "--ip=172.28.230.10", "--net=di-internal-l3", "--name=second", "busybox", "top")
|
|
|
|
|
|
+ cli.DockerCmd(c, "run", "-d", "--ip=172.28.230.10", "--net=di-internal-l3", "--name=second", "busybox", "top")
|
|
c.Assert(waitRun("second"), check.IsNil)
|
|
c.Assert(waitRun("second"), check.IsNil)
|
|
|
|
|
|
// access outside of the network should fail
|
|
// access outside of the network should fail
|
|
- result := dockerCmdWithTimeout(time.Second, "exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8")
|
|
|
|
|
|
+ result := cli.Docker(cli.Args("exec", "first", "ping", "-c", "1", "-w", "1", "8.8.8.8"), cli.WithTimeout(time.Second))
|
|
c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})
|
|
c.Assert(result, icmd.Matches, icmd.Expected{Timeout: true})
|
|
// intra-network communications should succeed
|
|
// intra-network communications should succeed
|
|
- _, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
|
|
|
|
- c.Assert(err, check.IsNil)
|
|
|
|
|
|
+ cli.DockerCmd(c, "exec", "second", "ping", "-c", "1", "first")
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestDockerNetworkMacVlanExistingParent(c *check.C) {
|
|
func (s *DockerSuite) TestDockerNetworkMacVlanExistingParent(c *check.C) {
|