diff options
Diffstat (limited to 'test/e2e/run_networking_test.go')
-rw-r--r-- | test/e2e/run_networking_test.go | 161 |
1 files changed, 81 insertions, 80 deletions
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 696cec76c..80a82ea05 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -9,6 +9,7 @@ import ( "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" "github.com/uber/jaeger-client-go/utils" ) @@ -40,47 +41,47 @@ var _ = Describe("Podman run networking", func() { It("podman run network connection with default bridge", func() { session := podmanTest.Podman([]string{"run", "-dt", ALPINE, "wget", "www.podman.io"}) session.Wait(90) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run network connection with host", func() { session := podmanTest.Podman([]string{"run", "-dt", "--network", "host", ALPINE, "wget", "www.podman.io"}) session.Wait(90) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run network connection with default", func() { session := podmanTest.Podman([]string{"run", "--network", "default", ALPINE, "wget", "www.podman.io"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run network connection with none", func() { session := podmanTest.Podman([]string{"run", "--network", "none", ALPINE, "wget", "www.podman.io"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(1)) + Expect(session).Should(Exit(1)) Expect(session.ErrorToString()).To(ContainSubstring("wget: bad address 'www.podman.io'")) }) It("podman run network connection with private", func() { session := podmanTest.Podman([]string{"run", "--network", "private", ALPINE, "wget", "www.podman.io"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run network connection with loopback", func() { session := podmanTest.Podman([]string{"run", "--network", "host", ALPINE, "wget", "www.podman.io"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run network expose port 222", func() { SkipIfRootless("iptables is not supported for rootless users") session := podmanTest.Podman([]string{"run", "-dt", "--expose", "222-223", "-P", ALPINE, "/bin/sh"}) session.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) results := SystemExec("iptables", []string{"-t", "nat", "-L"}) - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) Expect(results.OutputToString()).To(ContainSubstring("222")) Expect(results.OutputToString()).To(ContainSubstring("223")) }) @@ -338,9 +339,9 @@ var _ = Describe("Podman run networking", func() { SkipIfRootless("iptables is not supported for rootless users") session := podmanTest.Podman([]string{"run", "-dt", "-p", "80:8000", ALPINE, "/bin/sh"}) session.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) results := SystemExec("iptables", []string{"-t", "nat", "-L"}) - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) Expect(results.OutputToString()).To(ContainSubstring("8000")) ncBusy := SystemExec("nc", []string{"-l", "-p", "80"}) @@ -350,7 +351,7 @@ var _ = Describe("Podman run networking", func() { It("podman run network expose host port 8081 to container port 8000 using rootlesskit port handler", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=rootlesskit", "-dt", "-p", "8081:8000", ALPINE, "/bin/sh"}) session.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) ncBusy := SystemExec("nc", []string{"-l", "-p", "8081"}) Expect(ncBusy).To(ExitWithError()) @@ -359,7 +360,7 @@ var _ = Describe("Podman run networking", func() { It("podman run network expose host port 8082 to container port 8000 using slirp4netns port handler", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=slirp4netns", "-dt", "-p", "8082:8000", ALPINE, "/bin/sh"}) session.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) ncBusy := SystemExec("nc", []string{"-l", "-p", "8082"}) Expect(ncBusy).To(ExitWithError()) }) @@ -367,41 +368,41 @@ var _ = Describe("Podman run networking", func() { It("podman run network expose host port 8080 to container port 8000 using invalid port handler", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=invalid", "-dt", "-p", "8080:8000", ALPINE, "/bin/sh"}) session.Wait(30) - Expect(session.ExitCode()).To(Not(Equal(0))) + Expect(session).To(ExitWithError()) }) It("podman run slirp4netns network with host loopback", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:allow_host_loopback=true", ALPINE, "ping", "-c1", "10.0.2.2"}) session.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run slirp4netns network with mtu", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:mtu=9000", ALPINE, "ip", "addr"}) session.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("mtu 9000")) }) It("podman run slirp4netns network with different cidr", func() { slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) - Expect(slirp4netnsHelp.ExitCode()).To(Equal(0)) + Expect(slirp4netnsHelp).Should(Exit(0)) networkConfiguration := "slirp4netns:cidr=192.168.0.0/24,allow_host_loopback=true" session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "ping", "-c1", "192.168.0.2"}) session.Wait(30) if strings.Contains(slirp4netnsHelp.OutputToString(), "cidr") { - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) } else { - Expect(session.ExitCode()).ToNot(Equal(0)) + Expect(session).To(ExitWithError()) Expect(session.ErrorToString()).To(ContainSubstring("cidr not supported")) } }) It("podman run network bind to 127.0.0.1", func() { slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) - Expect(slirp4netnsHelp.ExitCode()).To(Equal(0)) + Expect(slirp4netnsHelp).Should(Exit(0)) networkConfiguration := "slirp4netns:outbound_addr=127.0.0.1,allow_host_loopback=true" if strings.Contains(slirp4netnsHelp.OutputToString(), "outbound-addr") { @@ -410,13 +411,13 @@ var _ = Describe("Podman run networking", func() { session.Wait(30) ncListener.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) - Expect(ncListener.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) + Expect(ncListener).Should(Exit(0)) Expect(ncListener.ErrorToString()).To(ContainSubstring("127.0.0.1")) } else { session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", "8083"}) session.Wait(30) - Expect(session.ExitCode()).ToNot(Equal(0)) + Expect(session).To(ExitWithError()) Expect(session.ErrorToString()).To(ContainSubstring("outbound_addr not supported")) } }) @@ -426,7 +427,7 @@ var _ = Describe("Podman run networking", func() { Expect(err).To(BeNil()) slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) - Expect(slirp4netnsHelp.ExitCode()).To(Equal(0)) + Expect(slirp4netnsHelp).Should(Exit(0)) networkConfiguration := fmt.Sprintf("slirp4netns:outbound_addr=%s,allow_host_loopback=true", ip.String()) if strings.Contains(slirp4netnsHelp.OutputToString(), "outbound-addr") { @@ -435,13 +436,13 @@ var _ = Describe("Podman run networking", func() { session.Wait(30) ncListener.Wait(30) - Expect(session.ExitCode()).To(Equal(0)) - Expect(ncListener.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) + Expect(ncListener).Should(Exit(0)) Expect(ncListener.ErrorToString()).To(ContainSubstring(ip.String())) } else { session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", "8084"}) session.Wait(30) - Expect(session.ExitCode()).ToNot(Equal(0)) + Expect(session).To(ExitWithError()) Expect(session.ErrorToString()).To(ContainSubstring("outbound_addr not supported")) } }) @@ -449,10 +450,10 @@ var _ = Describe("Podman run networking", func() { It("podman run network expose ports in image metadata", func() { session := podmanTest.Podman([]string{"create", "--name", "test", "-t", "-P", nginx}) session.Wait(90) - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) results := podmanTest.Podman([]string{"inspect", "test"}) results.Wait(30) - Expect(results.ExitCode()).To(Equal(0)) + Expect(results).Should(Exit(0)) Expect(results.OutputToString()).To(ContainSubstring(`"80/tcp":`)) }) @@ -461,11 +462,11 @@ var _ = Describe("Podman run networking", func() { session := podmanTest.Podman([]string{"run", "--name", "test", "-dt", "-p", "80", ALPINE, "/bin/sh"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) inspect := podmanTest.Podman([]string{"inspect", "test"}) inspect.WaitWithDefaultTimeout() - Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect).Should(Exit(0)) containerConfig := inspect.InspectContainerToJSON() Expect(containerConfig[0].NetworkSettings.Ports).To(Not(BeNil())) @@ -476,7 +477,7 @@ var _ = Describe("Podman run networking", func() { It("podman run hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) match, _ := session.GrepString(hostname) Expect(match).Should(BeFalse()) }) @@ -484,21 +485,21 @@ var _ = Describe("Podman run networking", func() { It("podman run --net host hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--net", "host", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) match, _ := session.GrepString(hostname) Expect(match).Should(BeTrue()) }) It("podman run --net host --uts host hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--net", "host", "--uts", "host", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) match, _ := session.GrepString(hostname) Expect(match).Should(BeTrue()) }) It("podman run --uts host hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--uts", "host", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) match, _ := session.GrepString(hostname) Expect(match).Should(BeTrue()) }) @@ -506,7 +507,7 @@ var _ = Describe("Podman run networking", func() { It("podman run --net host --hostname ... hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--net", "host", "--hostname", "foobar", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) match, _ := session.GrepString("foobar") Expect(match).Should(BeTrue()) }) @@ -514,7 +515,7 @@ var _ = Describe("Podman run networking", func() { It("podman run --hostname ... hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--hostname", "foobar", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) match, _ := session.GrepString("foobar") Expect(match).Should(BeTrue()) }) @@ -523,59 +524,59 @@ var _ = Describe("Podman run networking", func() { ctrName := "ctrToJoin" ctr1 := podmanTest.RunTopContainer(ctrName) ctr1.WaitWithDefaultTimeout() - Expect(ctr1.ExitCode()).To(Equal(0)) + Expect(ctr1).Should(Exit(0)) ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--uts=container:" + ctrName, ALPINE, "true"}) ctr2.WaitWithDefaultTimeout() - Expect(ctr2.ExitCode()).To(Equal(0)) + Expect(ctr2).Should(Exit(0)) }) It("podman run --net container: copies hosts and resolv", func() { ctrName := "ctr1" ctr1 := podmanTest.RunTopContainer(ctrName) ctr1.WaitWithDefaultTimeout() - Expect(ctr1.ExitCode()).To(Equal(0)) + Expect(ctr1).Should(Exit(0)) // Exec in and modify /etc/resolv.conf and /etc/hosts exec1 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo nameserver 192.0.2.1 > /etc/resolv.conf"}) exec1.WaitWithDefaultTimeout() - Expect(exec1.ExitCode()).To(Equal(0)) + Expect(exec1).Should(Exit(0)) exec2 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo 192.0.2.2 test1 > /etc/hosts"}) exec2.WaitWithDefaultTimeout() - Expect(exec2.ExitCode()).To(Equal(0)) + Expect(exec2).Should(Exit(0)) ctrName2 := "ctr2" ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--name", ctrName2, ALPINE, "top"}) ctr2.WaitWithDefaultTimeout() - Expect(ctr2.ExitCode()).To(Equal(0)) + Expect(ctr2).Should(Exit(0)) exec3 := podmanTest.Podman([]string{"exec", "-i", ctrName2, "cat", "/etc/resolv.conf"}) exec3.WaitWithDefaultTimeout() - Expect(exec3.ExitCode()).To(Equal(0)) + Expect(exec3).Should(Exit(0)) Expect(exec3.OutputToString()).To(ContainSubstring("nameserver 192.0.2.1")) exec4 := podmanTest.Podman([]string{"exec", "-i", ctrName2, "cat", "/etc/hosts"}) exec4.WaitWithDefaultTimeout() - Expect(exec4.ExitCode()).To(Equal(0)) + Expect(exec4).Should(Exit(0)) Expect(exec4.OutputToString()).To(ContainSubstring("192.0.2.2 test1")) }) It("podman run /etc/hosts contains --hostname", func() { session := podmanTest.Podman([]string{"run", "--rm", "--hostname", "foohostname", ALPINE, "grep", "foohostname", "/etc/hosts"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) }) It("podman run --uidmap /etc/hosts contains --hostname", func() { SkipIfRootless("uidmap population of cninetworks not supported for rootless users") session := podmanTest.Podman([]string{"run", "--uidmap", "0:100000:1000", "--rm", "--hostname", "foohostname", ALPINE, "grep", "foohostname", "/etc/hosts"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) + Expect(session).Should(Exit(0)) session = podmanTest.Podman([]string{"run", "--uidmap", "0:100000:1000", "--rm", "--hostname", "foohostname", "-v", "/etc/hosts:/etc/hosts", ALPINE, "grep", "foohostname", "/etc/hosts"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(1)) + Expect(session).Should(Exit(1)) }) It("podman run network in user created network namespace", func() { @@ -584,15 +585,15 @@ var _ = Describe("Podman run networking", func() { Skip("Cannot be run within a container.") } addXXX := SystemExec("ip", []string{"netns", "add", "xxx"}) - Expect(addXXX.ExitCode()).To(Equal(0)) + Expect(addXXX).Should(Exit(0)) defer func() { delXXX := SystemExec("ip", []string{"netns", "delete", "xxx"}) - Expect(delXXX.ExitCode()).To(Equal(0)) + Expect(delXXX).Should(Exit(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)) + Expect(session).Should(Exit(0)) }) It("podman run n user created network namespace with resolv.conf", func() { @@ -601,22 +602,22 @@ var _ = Describe("Podman run networking", func() { Skip("Cannot be run within a container.") } addXXX2 := SystemExec("ip", []string{"netns", "add", "xxx2"}) - Expect(addXXX2.ExitCode()).To(Equal(0)) + Expect(addXXX2).Should(Exit(0)) defer func() { delXXX2 := SystemExec("ip", []string{"netns", "delete", "xxx2"}) - Expect(delXXX2.ExitCode()).To(Equal(0)) + Expect(delXXX2).Should(Exit(0)) }() mdXXX2 := SystemExec("mkdir", []string{"-p", "/etc/netns/xxx2"}) - Expect(mdXXX2.ExitCode()).To(Equal(0)) + Expect(mdXXX2).Should(Exit(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)) + Expect(nsXXX2).Should(Exit(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).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("11.11.11.11")) }) @@ -632,12 +633,12 @@ var _ = Describe("Podman run networking", func() { ipAddr := "10.25.30.128" create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.30.0/24", netName}) create.WaitWithDefaultTimeout() - Expect(create.ExitCode()).To(BeZero()) + Expect(create).Should(Exit(0)) defer podmanTest.removeCNINetwork(netName) run := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) Expect(run.OutputToString()).To(ContainSubstring(ipAddr)) }) @@ -645,23 +646,23 @@ var _ = Describe("Podman run networking", func() { netName := stringid.GenerateNonCryptoID() create := podmanTest.Podman([]string{"network", "create", netName}) create.WaitWithDefaultTimeout() - Expect(create.ExitCode()).To(BeZero()) + Expect(create).Should(Exit(0)) defer podmanTest.removeCNINetwork(netName) name := "nc-server" run := podmanTest.Podman([]string{"run", "--log-driver", "k8s-file", "-d", "--name", name, "--net", netName, ALPINE, "nc", "-l", "-p", "8080"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(Equal(0)) + Expect(run).Should(Exit(0)) // NOTE: we force the k8s-file log driver to make sure the // tests are passing inside a container. run = podmanTest.Podman([]string{"run", "--log-driver", "k8s-file", "--rm", "--net", netName, "--uidmap", "0:1:4096", ALPINE, "sh", "-c", fmt.Sprintf("echo podman | nc -w 1 %s.dns.podman 8080", name)}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(Equal(0)) + Expect(run).Should(Exit(0)) log := podmanTest.Podman([]string{"logs", name}) log.WaitWithDefaultTimeout() - Expect(log.ExitCode()).To(Equal(0)) + Expect(log).Should(Exit(0)) Expect(log.OutputToString()).To(Equal("podman")) }) @@ -671,23 +672,23 @@ var _ = Describe("Podman run networking", func() { podname := "testpod" create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.40.0/24", netName}) create.WaitWithDefaultTimeout() - Expect(create.ExitCode()).To(BeZero()) + Expect(create).Should(Exit(0)) defer podmanTest.removeCNINetwork(netName) run := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "--pod", "new:" + podname, "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) Expect(run.OutputToString()).To(ContainSubstring(ipAddr)) podrm := podmanTest.Podman([]string{"pod", "rm", "-f", podname}) podrm.WaitWithDefaultTimeout() - Expect(podrm.ExitCode()).To(BeZero()) + Expect(podrm).Should(Exit(0)) }) It("podman run net=host adds entry to /etc/hosts", func() { run := podmanTest.Podman([]string{"run", "--net=host", ALPINE, "cat", "/etc/hosts"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) Expect(strings.Contains(run.OutputToString(), "127.0.1.1")).To(BeTrue()) }) @@ -695,7 +696,7 @@ var _ = Describe("Podman run networking", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=host", "--hostname", hostname, ALPINE, "hostname"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) @@ -703,7 +704,7 @@ var _ = Describe("Podman run networking", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "hostname"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) @@ -711,7 +712,7 @@ var _ = Describe("Podman run networking", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) @@ -719,11 +720,11 @@ var _ = Describe("Podman run networking", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", netns, "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) run = podmanTest.Podman([]string{"run", netns, "--hostname", hostname, "--name", "test", ALPINE, "ping", "-c", "1", "test"}) run.WaitWithDefaultTimeout() - Expect(run.ExitCode()).To(BeZero()) + Expect(run).Should(Exit(0)) } It("podman attempt to ping container name and hostname --net=none", func() { @@ -742,35 +743,35 @@ var _ = Describe("Podman run networking", func() { pod := "testpod" session := podmanTest.Podman([]string{"pod", "create", "--name", pod}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) net := "IntTest" + stringid.GenerateNonCryptoID() session = podmanTest.Podman([]string{"network", "create", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeCNINetwork(net) - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) pod2 := "testpod2" session = podmanTest.Podman([]string{"pod", "create", "--network", net, "--name", pod2}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) session = podmanTest.Podman([]string{"run", "--name", "con1", "--network", net, ALPINE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) session = podmanTest.Podman([]string{"run", "--name", "con2", "--pod", pod, "--network", net, ALPINE, "nslookup", "con2"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(1)) + Expect(session).Should(Exit(1)) Expect(session.ErrorToString()).To(ContainSubstring("can't resolve 'con1'")) session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, ALPINE, "nslookup", pod2 + ".dns.podman"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) }) It("podman run check dnsname adds dns search domain", func() { @@ -779,11 +780,11 @@ var _ = Describe("Podman run networking", func() { session := podmanTest.Podman([]string{"network", "create", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeCNINetwork(net) - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(BeZero()) + Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("search dns.podman")) }) @@ -792,7 +793,7 @@ var _ = Describe("Podman run networking", func() { ctrName := "testctr" ctr := podmanTest.Podman([]string{"run", "-d", "--net=bridge", "--name", ctrName, ALPINE, "top"}) ctr.WaitWithDefaultTimeout() - Expect(ctr.ExitCode()).To(BeZero()) + Expect(ctr).Should(Exit(0)) inspectOut := podmanTest.InspectContainer(ctrName) Expect(len(inspectOut)).To(Equal(1)) |