Skip to content

Commit

Permalink
Merge pull request #20852 from wenchma/net-alias
Browse files Browse the repository at this point in the history
Add tests of unsupported network-scoped alias on default networks
  • Loading branch information
cpuguy83 committed Mar 7, 2016
2 parents dc82c2d + 0515d9b commit 5ded3a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
17 changes: 15 additions & 2 deletions integration-cli/docker_cli_network_unix_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
11 changes: 11 additions & 0 deletions integration-cli/docker_cli_run_test.go
Expand Up @@ -273,6 +273,17 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *check.C) {
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) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
Expand Down

0 comments on commit 5ded3a2

Please sign in to comment.