forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Windows CI fail due to GH13866 and patch up tests
Signed-off-by: John Howard <[email protected]>
- Loading branch information
John Howard
committed
Jul 9, 2015
1 parent
42eb82a
commit c1b5244
Showing
11 changed files
with
365 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// +build !windows | ||
|
||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/go-check/check" | ||
) | ||
|
||
func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *check.C) { | ||
runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts") | ||
out, _, _, err := runCommandWithStdoutStderr(runCmd) | ||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
if !strings.HasPrefix(out, "-") { | ||
c.Errorf("/etc/hosts should be a regular file") | ||
} | ||
} | ||
|
||
func (s *DockerSuite) TestLinksEtcHostsContentMatch(c *check.C) { | ||
testRequires(c, SameHostDaemon) | ||
|
||
runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "cat", "/etc/hosts") | ||
out, _, _, err := runCommandWithStdoutStderr(runCmd) | ||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
hosts, err := ioutil.ReadFile("/etc/hosts") | ||
if os.IsNotExist(err) { | ||
c.Skip("/etc/hosts does not exist, skip this test") | ||
} | ||
|
||
if out != string(hosts) { | ||
c.Errorf("container") | ||
} | ||
|
||
} | ||
|
||
func (s *DockerSuite) TestLinksNetworkHostContainer(c *check.C) { | ||
|
||
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "-d", "--net", "host", "--name", "host_container", "busybox", "top")) | ||
if err != nil { | ||
c.Fatal(err, out) | ||
} | ||
|
||
out, _, err = runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true")) | ||
if err == nil || !strings.Contains(out, "--net=host can't be used with links. This would result in undefined behavior") { | ||
c.Fatalf("Running container linking to a container with --net host should have failed: %s", out) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// +build !windows | ||
|
||
package main | ||
|
||
import ( | ||
"net" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/go-check/check" | ||
) | ||
|
||
func (s *DockerSuite) TestPortHostBinding(c *check.C) { | ||
runCmd := exec.Command(dockerBinary, "run", "-d", "-p", "9876:80", "busybox", | ||
"nc", "-l", "-p", "80") | ||
out, _, err := runCommandWithOutput(runCmd) | ||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
firstID := strings.TrimSpace(out) | ||
|
||
runCmd = exec.Command(dockerBinary, "port", firstID, "80") | ||
out, _, err = runCommandWithOutput(runCmd) | ||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
if !assertPortList(c, out, []string{"0.0.0.0:9876"}) { | ||
c.Error("Port list is not correct") | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "run", "--net=host", "busybox", | ||
"nc", "localhost", "9876") | ||
if out, _, err = runCommandWithOutput(runCmd); err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "rm", "-f", firstID) | ||
if out, _, err = runCommandWithOutput(runCmd); err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "run", "--net=host", "busybox", | ||
"nc", "localhost", "9876") | ||
if out, _, err = runCommandWithOutput(runCmd); err == nil { | ||
c.Error("Port is still bound after the Container is removed") | ||
} | ||
} | ||
|
||
func (s *DockerSuite) TestPortExposeHostBinding(c *check.C) { | ||
runCmd := exec.Command(dockerBinary, "run", "-d", "-P", "--expose", "80", "busybox", | ||
"nc", "-l", "-p", "80") | ||
out, _, err := runCommandWithOutput(runCmd) | ||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
firstID := strings.TrimSpace(out) | ||
|
||
runCmd = exec.Command(dockerBinary, "port", firstID, "80") | ||
out, _, err = runCommandWithOutput(runCmd) | ||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
_, exposedPort, err := net.SplitHostPort(out) | ||
|
||
if err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "run", "--net=host", "busybox", | ||
"nc", "localhost", strings.TrimSpace(exposedPort)) | ||
if out, _, err = runCommandWithOutput(runCmd); err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "rm", "-f", firstID) | ||
if out, _, err = runCommandWithOutput(runCmd); err != nil { | ||
c.Fatal(out, err) | ||
} | ||
|
||
runCmd = exec.Command(dockerBinary, "run", "--net=host", "busybox", | ||
"nc", "localhost", strings.TrimSpace(exposedPort)) | ||
if out, _, err = runCommandWithOutput(runCmd); err == nil { | ||
c.Error("Port is still bound after the Container is removed") | ||
} | ||
} |
Oops, something went wrong.