Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
| ... | ... |
@@ -3,22 +3,14 @@ package main |
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"fmt" |
| 6 |
- "github.com/dotcloud/docker/daemon" |
|
| 7 | 6 |
"net" |
| 8 | 7 |
"os/exec" |
| 9 |
- "path/filepath" |
|
| 10 | 8 |
"testing" |
| 9 |
+ |
|
| 10 |
+ "github.com/dotcloud/docker/daemon" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func TestNetworkNat(t *testing.T) {
|
| 14 |
- ncPath, err := exec.LookPath("nc")
|
|
| 15 |
- if err != nil {
|
|
| 16 |
- t.Skip("Test not running with `make test`. Netcat not found: %s", err)
|
|
| 17 |
- } |
|
| 18 |
- ncPath, err = filepath.EvalSymlinks(ncPath) |
|
| 19 |
- if err != nil {
|
|
| 20 |
- t.Fatalf("Error resolving netcat symlink: %s", err)
|
|
| 21 |
- } |
|
| 22 | 14 |
iface, err := net.InterfaceByName("eth0")
|
| 23 | 15 |
if err != nil {
|
| 24 | 16 |
t.Skip("Test not running with `make test`. Interface eth0 not found: %s", err)
|
| ... | ... |
@@ -34,10 +26,7 @@ func TestNetworkNat(t *testing.T) {
|
| 34 | 34 |
t.Fatalf("Error retrieving the up for eth0: %s", err)
|
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 |
- runCmd := exec.Command(dockerBinary, "run", "-d", |
|
| 38 |
- "-v", ncPath+":/bin/nc", |
|
| 39 |
- "-v", "/lib/x86_64-linux-gnu/libc.so.6:/lib/libc.so.6", "-v", "/lib/x86_64-linux-gnu/libresolv.so.2:/lib/libresolv.so.2", "-v", "/lib/x86_64-linux-gnu/libbsd.so.0:/lib/libbsd.so.0", "-v", "/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2:/lib/ld-linux-x86-64.so.2", |
|
| 40 |
- "-p", "8080", "busybox", "/bin/nc", "-lp", "8080") |
|
| 37 |
+ runCmd := exec.Command(dockerBinary, "run", "-d", "-p", "8080", "busybox", "nc", "-lp", "8080") |
|
| 41 | 38 |
out, _, err := runCommandWithOutput(runCmd) |
| 42 | 39 |
errorOut(err, t, fmt.Sprintf("run1 failed with errors: %v (%s)", err, out))
|
| 43 | 40 |
|
| ... | ... |
@@ -60,10 +49,7 @@ func TestNetworkNat(t *testing.T) {
|
| 60 | 60 |
t.Fatal("Port 8080/tcp not found in NetworkSettings")
|
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
- runCmd = exec.Command(dockerBinary, "run", |
|
| 64 |
- "-v", ncPath+":/bin/nc", |
|
| 65 |
- "-v", "/lib/x86_64-linux-gnu/libc.so.6:/lib/libc.so.6", "-v", "/lib/x86_64-linux-gnu/libresolv.so.2:/lib/libresolv.so.2", "-v", "/lib/x86_64-linux-gnu/libbsd.so.0:/lib/libbsd.so.0", "-v", "/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2:/lib/ld-linux-x86-64.so.2", |
|
| 66 |
- "-p", "8080", "busybox", "sh", "-c", fmt.Sprintf("echo hello world | /bin/nc -w 30 %s %s", ifaceIp, port8080[0].HostPort))
|
|
| 63 |
+ runCmd = exec.Command(dockerBinary, "run", "-p", "8080", "busybox", "sh", "-c", fmt.Sprintf("echo hello world | nc -w 30 %s %s", ifaceIp, port8080[0].HostPort))
|
|
| 67 | 64 |
out, _, err = runCommandWithOutput(runCmd) |
| 68 | 65 |
errorOut(err, t, fmt.Sprintf("run2 failed with errors: %v (%s)", err, out))
|
| 69 | 66 |
|