mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Fix regression on --link on bridge network
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
@ -31,10 +31,33 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *check.C) {
|
||||
|
||||
func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
dockerCmd(c, "run", "-d", "--name", "container1", "--hostname", "fred", "busybox", "top")
|
||||
dockerCmd(c, "run", "-d", "--name", "container2", "--hostname", "wilma", "busybox", "top")
|
||||
// Test with the three different ways of specifying the default network on Linux
|
||||
testLinkPingOnNetwork(c, "")
|
||||
testLinkPingOnNetwork(c, "default")
|
||||
testLinkPingOnNetwork(c, "bridge")
|
||||
}
|
||||
|
||||
runArgs := []string{"run", "--rm", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "sh", "-c"}
|
||||
func testLinkPingOnNetwork(c *check.C, network string) {
|
||||
var postArgs []string
|
||||
if network != "" {
|
||||
postArgs = append(postArgs, []string{"--net", network}...)
|
||||
}
|
||||
postArgs = append(postArgs, []string{"busybox", "top"}...)
|
||||
runArgs1 := append([]string{"run", "-d", "--name", "container1", "--hostname", "fred"}, postArgs...)
|
||||
runArgs2 := append([]string{"run", "-d", "--name", "container2", "--hostname", "wilma"}, postArgs...)
|
||||
|
||||
// Run the two named containers
|
||||
dockerCmd(c, runArgs1...)
|
||||
dockerCmd(c, runArgs2...)
|
||||
|
||||
postArgs = []string{}
|
||||
if network != "" {
|
||||
postArgs = append(postArgs, []string{"--net", network}...)
|
||||
}
|
||||
postArgs = append(postArgs, []string{"busybox", "sh", "-c"}...)
|
||||
|
||||
// Format a run for a container which links to the other two
|
||||
runArgs := append([]string{"run", "--rm", "--link", "container1:alias1", "--link", "container2:alias2"}, postArgs...)
|
||||
pingCmd := "ping -c 1 %s -W 1 && ping -c 1 %s -W 1"
|
||||
|
||||
// test ping by alias, ping by name, and ping by hostname
|
||||
@ -45,6 +68,9 @@ func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) {
|
||||
// 3. Ping by hostname
|
||||
dockerCmd(c, append(runArgs, fmt.Sprintf(pingCmd, "fred", "wilma"))...)
|
||||
|
||||
// Clean for next round
|
||||
dockerCmd(c, "rm", "-f", "container1")
|
||||
dockerCmd(c, "rm", "-f", "container2")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *check.C) {
|
||||
|
Reference in New Issue
Block a user