mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add integration tests for build with network opts
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
60813af7ae
commit
e3b48fca0d
1 changed files with 28 additions and 0 deletions
|
@ -7042,3 +7042,31 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
|||
}
|
||||
c.Assert(layers1[len(layers1)-1], checker.Not(checker.Equals), layers2[len(layers1)-1])
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildNetNone(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
name := "testbuildnetnone"
|
||||
_, out, err := buildImageWithOut(name, `
|
||||
FROM busybox
|
||||
RUN ping -c 1 8.8.8.8
|
||||
`, true, "--network=none")
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(out, checker.Contains, "unreachable")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildNetContainer(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
id, _ := dockerCmd(c, "run", "--hostname", "foobar", "-d", "busybox", "nc", "-ll", "-p", "1234", "-e", "hostname")
|
||||
|
||||
name := "testbuildnetcontainer"
|
||||
out, err := buildImage(name, `
|
||||
FROM busybox
|
||||
RUN nc localhost 1234 > /otherhost
|
||||
`, true, "--network=container:"+strings.TrimSpace(id))
|
||||
c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
||||
|
||||
host, _ := dockerCmd(c, "run", "testbuildnetcontainer", "cat", "/otherhost")
|
||||
c.Assert(strings.TrimSpace(host), check.Equals, "foobar")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue