summaryrefslogtreecommitdiff
path: root/test/e2e/run_networking_test.go
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2019-02-28 09:38:02 -0500
committerChris Evich <cevich@redhat.com>2019-03-01 09:18:45 -0500
commitf67859ffb396be13cb8c4b8d91343b77de4eb288 (patch)
tree44a2ef27d992198f2ce0d9a6e0f0ec6a07c0008f /test/e2e/run_networking_test.go
parente30628eeda9898a64c0a5ed541536d8d5a3cf13c (diff)
downloadpodman-f67859ffb396be13cb8c4b8d91343b77de4eb288.tar.gz
podman-f67859ffb396be13cb8c4b8d91343b77de4eb288.tar.bz2
podman-f67859ffb396be13cb8c4b8d91343b77de4eb288.zip
Fix SystemExec completion race
Some callers assume when SystemExec returns, the command has completed. Other callers explicitly wait for completion (as required). However, forgetting to do that is an incredibly easy mistake to make. Fix this by adding an explicit parameter to the function. This requires every caller to deliberately state whether or not a completion-check is required. Also address **many** resource naming / cleanup completion-races. Signed-off-by: Chris Evich <cevich@redhat.com>
Diffstat (limited to 'test/e2e/run_networking_test.go')
-rw-r--r--test/e2e/run_networking_test.go33
1 files changed, 22 insertions, 11 deletions
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index a07e4d047..c89a4f487 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -58,7 +58,6 @@ var _ = Describe("Podman run networking", func() {
session.Wait(30)
Expect(session.ExitCode()).To(Equal(0))
results := SystemExec("iptables", []string{"-t", "nat", "-L"})
- results.Wait(30)
Expect(results.ExitCode()).To(Equal(0))
Expect(results.OutputToString()).To(ContainSubstring("222"))
Expect(results.OutputToString()).To(ContainSubstring("223"))
@@ -69,12 +68,10 @@ var _ = Describe("Podman run networking", func() {
session.Wait(30)
Expect(session.ExitCode()).To(Equal(0))
results := SystemExec("iptables", []string{"-t", "nat", "-L"})
- results.Wait(30)
Expect(results.ExitCode()).To(Equal(0))
Expect(results.OutputToString()).To(ContainSubstring("8000"))
ncBusy := SystemExec("nc", []string{"-l", "-p", "80"})
- ncBusy.Wait(10)
Expect(ncBusy.ExitCode()).ToNot(Equal(0))
})
@@ -183,26 +180,40 @@ var _ = Describe("Podman run networking", func() {
if Containerized() {
Skip("Can not be run within a container.")
}
- SystemExec("ip", []string{"netns", "add", "xxx"})
+ addXXX := SystemExec("ip", []string{"netns", "add", "xxx"})
+ Expect(addXXX.ExitCode()).To(Equal(0))
+ defer func() {
+ delXXX := SystemExec("ip", []string{"netns", "delete", "xxx"})
+ Expect(delXXX.ExitCode()).To(Equal(0))
+ }()
+
session := podmanTest.Podman([]string{"run", "-dt", "--net", "ns:/run/netns/xxx", ALPINE, "wget", "www.podman.io"})
session.Wait(90)
Expect(session.ExitCode()).To(Equal(0))
- SystemExec("ip", []string{"netns", "delete", "xxx"})
})
It("podman run n user created network namespace with resolv.conf", func() {
if Containerized() {
Skip("Can not be run within a container.")
}
- SystemExec("ip", []string{"netns", "add", "xxx"})
- SystemExec("mkdir", []string{"-p", "/etc/netns/xxx"})
- SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx/resolv.conf"})
- session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx", ALPINE, "cat", "/etc/resolv.conf"})
+ addXXX2 := SystemExec("ip", []string{"netns", "add", "xxx2"})
+ Expect(addXXX2.ExitCode()).To(Equal(0))
+ defer func() {
+ delXXX2 := SystemExec("ip", []string{"netns", "delete", "xxx2"})
+ Expect(delXXX2.ExitCode()).To(Equal(0))
+ }()
+
+ mdXXX2 := SystemExec("mkdir", []string{"-p", "/etc/netns/xxx2"})
+ Expect(mdXXX2.ExitCode()).To(Equal(0))
+ defer os.RemoveAll("/etc/netns/xxx2")
+
+ nsXXX2 := SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx2/resolv.conf"})
+ Expect(nsXXX2.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx2", ALPINE, "cat", "/etc/resolv.conf"})
session.Wait(90)
Expect(session.ExitCode()).To(Equal(0))
Expect(session.OutputToString()).To(ContainSubstring("11.11.11.11"))
- SystemExec("ip", []string{"netns", "delete", "xxx"})
- SystemExec("rm", []string{"-rf", "/etc/netns/xxx"})
})
It("podman run network in bogus user created network namespace", func() {