1
0
mirror of https://github.com/moby/moby.git synced 2026-01-06 07:21:23 +03:00

Merge pull request #7934 from LK4D4/fix_double_allocation

Fix error propagation from userland-proxy
This commit is contained in:
Michael Crosby
2014-09-12 11:39:10 -07:00
3 changed files with 84 additions and 16 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
"path"
@@ -1895,3 +1896,23 @@ func TestRunDeallocatePortOnMissingIptablesRule(t *testing.T) {
deleteAllContainers()
logDone("run - port should be deallocated even on iptables error")
}
func TestRunPortInUse(t *testing.T) {
port := "1234"
l, err := net.Listen("tcp", ":"+port)
if err != nil {
t.Fatal(err)
}
defer l.Close()
cmd := exec.Command(dockerBinary, "run", "-p", port+":80", "busybox", "true")
out, _, err := runCommandWithOutput(cmd)
if err == nil {
t.Fatalf("Binding on used port must fail")
}
if !strings.Contains(out, "address already in use") {
t.Fatalf("Out must be about \"address already in use\", got %s", out)
}
deleteAllContainers()
logDone("run - fail if port already in use")
}