2014-04-07 22:34:07 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPingUnlinkedContainers(t *testing.T) {
|
|
|
|
runCmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
|
|
|
|
exitCode, err := runCommand(runCmd)
|
|
|
|
|
|
|
|
if exitCode == 0 {
|
|
|
|
t.Fatal("run ping did not fail")
|
|
|
|
} else if exitCode != 1 {
|
|
|
|
errorOut(err, t, fmt.Sprintf("run ping failed with errors: %v", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPingLinkedContainers(t *testing.T) {
|
2014-05-06 06:51:03 +04:00
|
|
|
var out string
|
|
|
|
out, _, _ = cmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
|
2014-04-07 22:34:07 +04:00
|
|
|
idA := stripTrailingCharacters(out)
|
2014-05-06 19:05:15 +04:00
|
|
|
out, _, _ = cmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
|
2014-04-07 22:34:07 +04:00
|
|
|
idB := stripTrailingCharacters(out)
|
2014-05-06 19:05:15 +04:00
|
|
|
cmd(t, "run", "--rm", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
|
|
|
|
cmd(t, "kill", idA)
|
|
|
|
cmd(t, "kill", idB)
|
2014-04-07 22:34:07 +04:00
|
|
|
deleteAllContainers()
|
|
|
|
}
|