mirror of
https://github.com/moby/moby.git
synced 2025-10-25 20:38:05 +03:00
Merge pull request #20852 from wenchma/net-alias
Add tests of unsupported network-scoped alias on default networks
This commit is contained in:
@@ -801,8 +801,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) {
|
||||
c.Assert(err, check.NotNil)
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkLinkOndefaultNetworkOnly(c *check.C) {
|
||||
// Link feature must work only on default network, and not across networks
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *check.C) {
|
||||
// Legacy Link feature must work only on default network, and not across networks
|
||||
cnt1 := "container1"
|
||||
cnt2 := "container2"
|
||||
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"))
|
||||
}
|
||||
|
||||
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) {
|
||||
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
|
||||
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
|
||||
|
||||
Reference in New Issue
Block a user