mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
now busybox as nc
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
This commit is contained in:
parent
7e38d6a358
commit
0be44d1a0a
1 changed files with 4 additions and 18 deletions
|
@ -3,22 +3,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/daemon"
|
|
||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/dotcloud/docker/daemon"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNetworkNat(t *testing.T) {
|
func TestNetworkNat(t *testing.T) {
|
||||||
ncPath, err := exec.LookPath("nc")
|
|
||||||
if err != nil {
|
|
||||||
t.Skip("Test not running with `make test`. Netcat not found: %s", err)
|
|
||||||
}
|
|
||||||
ncPath, err = filepath.EvalSymlinks(ncPath)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error resolving netcat symlink: %s", err)
|
|
||||||
}
|
|
||||||
iface, err := net.InterfaceByName("eth0")
|
iface, err := net.InterfaceByName("eth0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Skip("Test not running with `make test`. Interface eth0 not found: %s", err)
|
t.Skip("Test not running with `make test`. Interface eth0 not found: %s", err)
|
||||||
|
@ -34,10 +26,7 @@ func TestNetworkNat(t *testing.T) {
|
||||||
t.Fatalf("Error retrieving the up for eth0: %s", err)
|
t.Fatalf("Error retrieving the up for eth0: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-d",
|
runCmd := exec.Command(dockerBinary, "run", "-d", "-p", "8080", "busybox", "nc", "-lp", "8080")
|
||||||
"-v", ncPath+":/bin/nc",
|
|
||||||
"-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",
|
|
||||||
"-p", "8080", "busybox", "/bin/nc", "-lp", "8080")
|
|
||||||
out, _, err := runCommandWithOutput(runCmd)
|
out, _, err := runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("run1 failed with errors: %v (%s)", err, out))
|
errorOut(err, t, fmt.Sprintf("run1 failed with errors: %v (%s)", err, out))
|
||||||
|
|
||||||
|
@ -60,10 +49,7 @@ func TestNetworkNat(t *testing.T) {
|
||||||
t.Fatal("Port 8080/tcp not found in NetworkSettings")
|
t.Fatal("Port 8080/tcp not found in NetworkSettings")
|
||||||
}
|
}
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "run",
|
runCmd = exec.Command(dockerBinary, "run", "-p", "8080", "busybox", "sh", "-c", fmt.Sprintf("echo hello world | nc -w 30 %s %s", ifaceIp, port8080[0].HostPort))
|
||||||
"-v", ncPath+":/bin/nc",
|
|
||||||
"-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",
|
|
||||||
"-p", "8080", "busybox", "sh", "-c", fmt.Sprintf("echo hello world | /bin/nc -w 30 %s %s", ifaceIp, port8080[0].HostPort))
|
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("run2 failed with errors: %v (%s)", err, out))
|
errorOut(err, t, fmt.Sprintf("run2 failed with errors: %v (%s)", err, out))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue