mirror of https://github.com/docker/docs.git
Cleanup errorOut resp in port test
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
This commit is contained in:
parent
3182ee5c9b
commit
88d65cbdf4
|
@ -11,12 +11,16 @@ func TestPortList(t *testing.T) {
|
||||||
// one port
|
// one port
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-d", "-p", "9876:80", "busybox", "top")
|
runCmd := exec.Command(dockerBinary, "run", "-d", "-p", "9876:80", "busybox", "top")
|
||||||
out, _, err := runCommandWithOutput(runCmd)
|
out, _, err := runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
firstID := stripTrailingCharacters(out)
|
firstID := stripTrailingCharacters(out)
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "port", firstID, "80")
|
runCmd = exec.Command(dockerBinary, "port", firstID, "80")
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !assertPortList(t, out, []string{"0.0.0.0:9876"}) {
|
if !assertPortList(t, out, []string{"0.0.0.0:9876"}) {
|
||||||
t.Error("Port list is not correct")
|
t.Error("Port list is not correct")
|
||||||
|
@ -24,14 +28,17 @@ func TestPortList(t *testing.T) {
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "port", firstID)
|
runCmd = exec.Command(dockerBinary, "port", firstID)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !assertPortList(t, out, []string{"80/tcp -> 0.0.0.0:9876"}) {
|
if !assertPortList(t, out, []string{"80/tcp -> 0.0.0.0:9876"}) {
|
||||||
t.Error("Port list is not correct")
|
t.Error("Port list is not correct")
|
||||||
}
|
}
|
||||||
runCmd = exec.Command(dockerBinary, "rm", "-f", firstID)
|
runCmd = exec.Command(dockerBinary, "rm", "-f", firstID)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
||||||
errorOut(err, t, out)
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
// three port
|
// three port
|
||||||
runCmd = exec.Command(dockerBinary, "run", "-d",
|
runCmd = exec.Command(dockerBinary, "run", "-d",
|
||||||
|
@ -40,12 +47,16 @@ func TestPortList(t *testing.T) {
|
||||||
"-p", "9878:82",
|
"-p", "9878:82",
|
||||||
"busybox", "top")
|
"busybox", "top")
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
ID := stripTrailingCharacters(out)
|
ID := stripTrailingCharacters(out)
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "port", ID, "80")
|
runCmd = exec.Command(dockerBinary, "port", ID, "80")
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !assertPortList(t, out, []string{"0.0.0.0:9876"}) {
|
if !assertPortList(t, out, []string{"0.0.0.0:9876"}) {
|
||||||
t.Error("Port list is not correct")
|
t.Error("Port list is not correct")
|
||||||
|
@ -53,7 +64,9 @@ func TestPortList(t *testing.T) {
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "port", ID)
|
runCmd = exec.Command(dockerBinary, "port", ID)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !assertPortList(t, out, []string{
|
if !assertPortList(t, out, []string{
|
||||||
"80/tcp -> 0.0.0.0:9876",
|
"80/tcp -> 0.0.0.0:9876",
|
||||||
|
@ -63,7 +76,9 @@ func TestPortList(t *testing.T) {
|
||||||
}
|
}
|
||||||
runCmd = exec.Command(dockerBinary, "rm", "-f", ID)
|
runCmd = exec.Command(dockerBinary, "rm", "-f", ID)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
// more and one port mapped to the same container port
|
// more and one port mapped to the same container port
|
||||||
runCmd = exec.Command(dockerBinary, "run", "-d",
|
runCmd = exec.Command(dockerBinary, "run", "-d",
|
||||||
|
@ -73,12 +88,16 @@ func TestPortList(t *testing.T) {
|
||||||
"-p", "9878:82",
|
"-p", "9878:82",
|
||||||
"busybox", "top")
|
"busybox", "top")
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
ID = stripTrailingCharacters(out)
|
ID = stripTrailingCharacters(out)
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "port", ID, "80")
|
runCmd = exec.Command(dockerBinary, "port", ID, "80")
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !assertPortList(t, out, []string{"0.0.0.0:9876", "0.0.0.0:9999"}) {
|
if !assertPortList(t, out, []string{"0.0.0.0:9876", "0.0.0.0:9999"}) {
|
||||||
t.Error("Port list is not correct")
|
t.Error("Port list is not correct")
|
||||||
|
@ -86,7 +105,9 @@ func TestPortList(t *testing.T) {
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "port", ID)
|
runCmd = exec.Command(dockerBinary, "port", ID)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !assertPortList(t, out, []string{
|
if !assertPortList(t, out, []string{
|
||||||
"80/tcp -> 0.0.0.0:9876",
|
"80/tcp -> 0.0.0.0:9876",
|
||||||
|
@ -96,8 +117,9 @@ func TestPortList(t *testing.T) {
|
||||||
t.Error("Port list is not correct\n", out)
|
t.Error("Port list is not correct\n", out)
|
||||||
}
|
}
|
||||||
runCmd = exec.Command(dockerBinary, "rm", "-f", ID)
|
runCmd = exec.Command(dockerBinary, "rm", "-f", ID)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
if out, _, err = runCommandWithOutput(runCmd); err != nil {
|
||||||
errorOut(err, t, out)
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
deleteAllContainers()
|
deleteAllContainers()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue