mirror of https://github.com/docker/docs.git
Add tests of unsupported network-scoped alias on default networks
Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
This commit is contained in:
parent
266a75ac22
commit
0515d9b9c0
|
@ -801,8 +801,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) {
|
||||||
c.Assert(err, check.NotNil)
|
c.Assert(err, check.NotNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerNetworkSuite) TestDockerNetworkLinkOndefaultNetworkOnly(c *check.C) {
|
func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *check.C) {
|
||||||
// Link feature must work only on default network, and not across networks
|
// Legacy Link feature must work only on default network, and not across networks
|
||||||
cnt1 := "container1"
|
cnt1 := "container1"
|
||||||
cnt2 := "container2"
|
cnt2 := "container2"
|
||||||
network := "anotherbridge"
|
network := "anotherbridge"
|
||||||
|
@ -1314,6 +1314,19 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *check.C) {
|
||||||
c.Assert(networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network"))
|
c.Assert(networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *check.C) {
|
||||||
|
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
||||||
|
|
||||||
|
defaults := []string{"bridge", "host", "none"}
|
||||||
|
out, _ := dockerCmd(c, "run", "-d", "--net=none", "busybox", "top")
|
||||||
|
containerID := strings.TrimSpace(out)
|
||||||
|
for _, net := range defaults {
|
||||||
|
res, _, err := dockerCmdWithError("network", "connect", "--alias", "alias"+net, net, containerID)
|
||||||
|
c.Assert(err, checker.NotNil)
|
||||||
|
c.Assert(res, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) {
|
func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) {
|
||||||
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
||||||
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
|
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
|
||||||
|
|
|
@ -273,6 +273,17 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *check.C) {
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *check.C) {
|
||||||
|
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
||||||
|
|
||||||
|
defaults := []string{"bridge", "host", "none"}
|
||||||
|
for _, net := range defaults {
|
||||||
|
out, _, err := dockerCmdWithError("run", "-d", "--net", net, "--net-alias", "alias_"+net, "busybox", "top")
|
||||||
|
c.Assert(err, checker.NotNil)
|
||||||
|
c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestUserDefinedNetworkAlias(c *check.C) {
|
func (s *DockerSuite) TestUserDefinedNetworkAlias(c *check.C) {
|
||||||
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
||||||
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
|
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
|
||||||
|
|
Loading…
Reference in New Issue