From dbd946a932ceae3f400ec449cb927aa06b1bffae Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 25 Sep 2023 13:57:02 -0600 Subject: [PATCH 1/2] e2e: ExitCleanly(): a few more Commit 1 of 2: automated string replace Exit(0) -> ExitCleanly() Signed-off-by: Ed Santiago --- test/e2e/run_networking_test.go | 218 ++++++++-------- test/e2e/run_test.go | 440 ++++++++++++++++---------------- test/e2e/runlabel_test.go | 20 +- 3 files changed, 343 insertions(+), 335 deletions(-) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index a0555d98b9..86ab218777 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -20,6 +20,10 @@ import ( var _ = Describe("Podman run networking", func() { + BeforeEach(func() { + Skip("TEMPORARY: to not break git-bisect") + }) + hostname, _ := os.Hostname() It("podman verify network scoped DNS server and also verify updating network dns server", func() { @@ -29,12 +33,12 @@ var _ = Describe("Podman run networking", func() { session := podmanTest.Podman([]string{"network", "create", net, "--dns", "1.1.1.1"}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"network", "inspect", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) var results []types.Network err := json.Unmarshal([]byte(session.OutputToString()), &results) Expect(err).ToNot(HaveOccurred()) @@ -46,22 +50,22 @@ var _ = Describe("Podman run networking", func() { session = podmanTest.Podman([]string{"run", "-d", "--name", "con1", "--network", net, "busybox", "top"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "con1", "nslookup", "google.com", aardvarkDNSGateway}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("Non-authoritative answer: Name: google.com Address:")) // Update to a bad DNS Server session = podmanTest.Podman([]string{"network", "update", net, "--dns-add", "127.0.0.255"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // Remove good DNS server session = podmanTest.Podman([]string{"network", "update", net, "--dns-drop=1.1.1.1"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "con1", "nslookup", "google.com", aardvarkDNSGateway}) session.WaitWithDefaultTimeout() @@ -76,12 +80,12 @@ var _ = Describe("Podman run networking", func() { session := podmanTest.Podman([]string{"network", "create", net, "--dns", "1.1.1.1,8.8.8.8", "--dns", "8.4.4.8"}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"network", "inspect", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) var results []types.Network err := json.Unmarshal([]byte(session.OutputToString()), &results) Expect(err).ToNot(HaveOccurred()) @@ -93,23 +97,23 @@ var _ = Describe("Podman run networking", func() { session = podmanTest.Podman([]string{"run", "-d", "--name", "con1", "--network", net, "busybox", "top"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "con1", "nslookup", "google.com", aardvarkDNSGateway}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("Non-authoritative answer: Name: google.com Address:")) // Update DNS server session = podmanTest.Podman([]string{"network", "update", net, "--dns-drop=1.1.1.1,8.8.8.8", "--dns-drop", "8.4.4.8", "--dns-add", "127.0.0.253,127.0.0.254", "--dns-add", "127.0.0.255"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"network", "inspect", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) err = json.Unmarshal([]byte(session.OutputToString()), &results) Expect(err).ToNot(HaveOccurred()) Expect(results).To(HaveLen(1)) @@ -124,19 +128,19 @@ var _ = Describe("Podman run networking", func() { It("podman run network connection with default bridge", func() { session := podmanTest.RunContainerWithNetworkTest("") session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run network connection with host", func() { session := podmanTest.RunContainerWithNetworkTest("host") session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run network connection with default", func() { session := podmanTest.RunContainerWithNetworkTest("default") session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run network connection with none", func() { @@ -154,7 +158,7 @@ var _ = Describe("Podman run networking", func() { It("podman run network connection with private", func() { session := podmanTest.RunContainerWithNetworkTest("private") session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman verify resolv.conf with --dns + --network", func() { @@ -165,11 +169,11 @@ var _ = Describe("Podman run networking", func() { session := podmanTest.Podman([]string{"network", "create", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--name", "con1", "--dns", "1.1.1.1", "--network", net, ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // Must not contain custom dns server in containers // `/etc/resolv.conf` since custom dns-server is // already expected to be present and processed by @@ -181,7 +185,7 @@ var _ = Describe("Podman run networking", func() { session = podmanTest.Podman([]string{"run", "--name", "con2", "--dns", "1.1.1.1", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // All the networks being used by following container // don't have dns_enabled in such scenario `/etc/resolv.conf` // must contain nameserver which were specified via `--dns`. @@ -192,9 +196,9 @@ var _ = Describe("Podman run networking", func() { SkipIfRootless("iptables is not supported for rootless users") session := podmanTest.Podman([]string{"run", "-dt", "--expose", "222-223", "-P", ALPINE, "/bin/sh"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) results := SystemExec("iptables", []string{"-t", "nat", "-nvL"}) - Expect(results).Should(Exit(0)) + Expect(results).Should(ExitCleanly()) Expect(results.OutputToString()).To(ContainSubstring("222")) Expect(results.OutputToString()).To(ContainSubstring("223")) }) @@ -491,9 +495,9 @@ EXPOSE 2004-2005/tcp`, ALPINE) port2 := GetPort() session := podmanTest.Podman([]string{"run", "-dt", "-p", fmt.Sprintf("%d:%d", port1, port2), ALPINE, "/bin/sh"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) results := SystemExec("iptables", []string{"-t", "nat", "-nvL"}) - Expect(results).Should(Exit(0)) + Expect(results).Should(ExitCleanly()) Expect(results.OutputToString()).To(ContainSubstring(fmt.Sprintf("%d", port2))) ncBusy := SystemExec("nc", []string{"-l", "-p", fmt.Sprintf("%d", port1)}) @@ -505,7 +509,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) port2 := GetPort() session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=rootlesskit", "-dt", "-p", fmt.Sprintf("%d:%d", port2, port1), ALPINE, "/bin/sh"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ncBusy := SystemExec("nc", []string{"-l", "-p", fmt.Sprintf("%d", port2)}) Expect(ncBusy).To(ExitWithError()) @@ -514,7 +518,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) It("podman run slirp4netns verify net.ipv6.conf.default.accept_dad=0", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:enable_ipv6=true", ALPINE, "ip", "addr"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // check the ipv6 setup id done without delay (https://github.com/containers/podman/issues/11062) Expect(session.OutputToString()).To(ContainSubstring("inet6 fd00::")) @@ -522,19 +526,19 @@ EXPOSE 2004-2005/tcp`, ALPINE) cat := SystemExec("cat", []string{ipv6ConfDefaultAcceptDadSysctl}) cat.WaitWithDefaultTimeout() - Expect(cat).Should(Exit(0)) + Expect(cat).Should(ExitCleanly()) sysctlValue := cat.OutputToString() session = podmanTest.Podman([]string{"run", "--network", "slirp4netns:enable_ipv6=true", ALPINE, "cat", ipv6ConfDefaultAcceptDadSysctl}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(sysctlValue)) }) It("podman run network expose host port 18082 to container port 8000 using slirp4netns port handler", func() { session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=slirp4netns", "-dt", "-p", "18082:8000", ALPINE, "/bin/sh"}) session.Wait(30) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ncBusy := SystemExec("nc", []string{"-l", "-p", "18082"}) Expect(ncBusy).To(ExitWithError()) }) @@ -548,26 +552,26 @@ EXPOSE 2004-2005/tcp`, ALPINE) It("podman run slirp4netns network with host loopback", func() { session := podmanTest.Podman([]string{"run", "--cap-add", "net_raw", "--network", "slirp4netns:allow_host_loopback=true", ALPINE, "ping", "-c1", "10.0.2.2"}) session.Wait(30) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) 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).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mtu 9000")) }) It("podman run slirp4netns network with different cidr", func() { slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) - Expect(slirp4netnsHelp).Should(Exit(0)) + Expect(slirp4netnsHelp).Should(ExitCleanly()) networkConfiguration := "slirp4netns:cidr=192.168.0.0/24,allow_host_loopback=true" session := podmanTest.Podman([]string{"run", "--cap-add", "net_raw", "--network", networkConfiguration, ALPINE, "ping", "-c1", "192.168.0.2"}) session.Wait(30) if strings.Contains(slirp4netnsHelp.OutputToString(), "cidr") { - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) } else { Expect(session).To(ExitWithError()) Expect(session.ErrorToString()).To(ContainSubstring("cidr not supported")) @@ -576,7 +580,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) It("podman run network bind to 127.0.0.1", func() { slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) - Expect(slirp4netnsHelp).Should(Exit(0)) + Expect(slirp4netnsHelp).Should(ExitCleanly()) networkConfiguration := "slirp4netns:outbound_addr=127.0.0.1,allow_host_loopback=true" port := GetPort() @@ -586,8 +590,8 @@ EXPOSE 2004-2005/tcp`, ALPINE) session.WaitWithDefaultTimeout() ncListener.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(ncListener).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) + Expect(ncListener).Should(ExitCleanly()) 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", fmt.Sprintf("%d", port)}) @@ -607,7 +611,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) port := GetPort() slirp4netnsHelp := SystemExec("slirp4netns", []string{"--help"}) - Expect(slirp4netnsHelp).Should(Exit(0)) + Expect(slirp4netnsHelp).Should(ExitCleanly()) networkConfiguration := fmt.Sprintf("slirp4netns:outbound_addr=%s,allow_host_loopback=true", ip.String()) if strings.Contains(slirp4netnsHelp.OutputToString(), "outbound-addr") { @@ -616,8 +620,8 @@ EXPOSE 2004-2005/tcp`, ALPINE) session.Wait(30) ncListener.Wait(30) - Expect(session).Should(Exit(0)) - Expect(ncListener).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) + Expect(ncListener).Should(ExitCleanly()) Expect(ncListener.ErrorToString()).To(ContainSubstring(ip.String())) } else { session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)}) @@ -630,10 +634,10 @@ EXPOSE 2004-2005/tcp`, ALPINE) It("podman run network expose ports in image metadata", func() { session := podmanTest.Podman([]string{"create", "--name", "test", "-t", "-P", NGINX_IMAGE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) results := podmanTest.Podman([]string{"inspect", "test"}) results.WaitWithDefaultTimeout() - Expect(results).Should(Exit(0)) + Expect(results).Should(ExitCleanly()) Expect(results.OutputToString()).To(ContainSubstring(`"80/tcp":`)) }) @@ -642,11 +646,11 @@ EXPOSE 2004-2005/tcp`, ALPINE) session := podmanTest.Podman([]string{"run", "--name", "test", "-dt", "-p", port, ALPINE, "/bin/sh"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) inspect := podmanTest.Podman([]string{"inspect", "test"}) inspect.WaitWithDefaultTimeout() - Expect(inspect).Should(Exit(0)) + Expect(inspect).Should(ExitCleanly()) containerConfig := inspect.InspectContainerToJSON() Expect(containerConfig[0].NetworkSettings.Ports).To(Not(BeNil())) @@ -658,7 +662,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) SkipIfRootless("sctp protocol only works as root") session := podmanTest.Podman([]string{"--log-level=info", "run", "--name=test", "-p", "80/sctp", "-p", "81/sctp", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // we can only check logrus on local podman if !IsRemote() { // check that the info message for sctp protocol is only displayed once @@ -666,7 +670,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) } results := podmanTest.Podman([]string{"inspect", "test"}) results.WaitWithDefaultTimeout() - Expect(results).Should(Exit(0)) + Expect(results).Should(ExitCleanly()) Expect(results.OutputToString()).To(ContainSubstring(`"80/sctp":`)) Expect(results.OutputToString()).To(ContainSubstring(`"81/sctp":`)) }) @@ -674,40 +678,40 @@ EXPOSE 2004-2005/tcp`, ALPINE) It("podman run hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Not(ContainSubstring(hostname))) }) It("podman run --net host hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--net", "host", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(hostname)) }) 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).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(hostname)) }) It("podman run --uts host hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--uts", "host", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(hostname)) }) 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).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("foobar")) }) It("podman run --hostname ... hostname test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--hostname", "foobar", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("foobar")) }) @@ -715,18 +719,18 @@ EXPOSE 2004-2005/tcp`, ALPINE) ctrName := "ctrToJoin" ctr1 := podmanTest.RunTopContainer(ctrName) ctr1.WaitWithDefaultTimeout() - Expect(ctr1).Should(Exit(0)) + Expect(ctr1).Should(ExitCleanly()) ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--uts=container:" + ctrName, ALPINE, "true"}) ctr2.WaitWithDefaultTimeout() - Expect(ctr2).Should(Exit(0)) + Expect(ctr2).Should(ExitCleanly()) }) It("podman run --net container: and --add-host should fail", func() { ctrName := "ctrToJoin" ctr1 := podmanTest.RunTopContainer(ctrName) ctr1.WaitWithDefaultTimeout() - Expect(ctr1).Should(Exit(0)) + Expect(ctr1).Should(ExitCleanly()) ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--add-host", "host1:127.0.0.1", ALPINE, "true"}) ctr2.WaitWithDefaultTimeout() @@ -738,44 +742,44 @@ EXPOSE 2004-2005/tcp`, ALPINE) ctrName := "ctr1" ctr1 := podmanTest.RunTopContainer(ctrName) ctr1.WaitWithDefaultTimeout() - Expect(ctr1).Should(Exit(0)) + Expect(ctr1).Should(ExitCleanly()) // 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).Should(Exit(0)) + Expect(exec1).Should(ExitCleanly()) exec2 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo 192.0.2.2 test1 > /etc/hosts"}) exec2.WaitWithDefaultTimeout() - Expect(exec2).Should(Exit(0)) + Expect(exec2).Should(ExitCleanly()) ctrName2 := "ctr2" ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--name", ctrName2, ALPINE, "top"}) ctr2.WaitWithDefaultTimeout() - Expect(ctr2).Should(Exit(0)) + Expect(ctr2).Should(ExitCleanly()) exec3 := podmanTest.Podman([]string{"exec", ctrName2, "cat", "/etc/resolv.conf"}) exec3.WaitWithDefaultTimeout() - Expect(exec3).Should(Exit(0)) + Expect(exec3).Should(ExitCleanly()) Expect(exec3.OutputToString()).To(ContainSubstring("nameserver 192.0.2.1")) exec4 := podmanTest.Podman([]string{"exec", ctrName2, "cat", "/etc/hosts"}) exec4.WaitWithDefaultTimeout() - Expect(exec4).Should(Exit(0)) + Expect(exec4).Should(ExitCleanly()) 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).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) 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).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--uidmap", "0:100000:1000", "--rm", "--hostname", "foohostname", "-v", "/etc/hosts:/etc/hosts", ALPINE, "grep", "foohostname", "/etc/hosts"}) session.WaitWithDefaultTimeout() @@ -788,15 +792,15 @@ EXPOSE 2004-2005/tcp`, ALPINE) Skip("Cannot be run within a container.") } addXXX := SystemExec("ip", []string{"netns", "add", "xxx"}) - Expect(addXXX).Should(Exit(0)) + Expect(addXXX).Should(ExitCleanly()) defer func() { delXXX := SystemExec("ip", []string{"netns", "delete", "xxx"}) - Expect(delXXX).Should(Exit(0)) + Expect(delXXX).Should(ExitCleanly()) }() session := podmanTest.Podman([]string{"run", "-dt", "--net", "ns:/run/netns/xxx", ALPINE, "wget", "www.redhat.com"}) session.Wait(90) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run n user created network namespace with resolv.conf", func() { @@ -805,22 +809,22 @@ EXPOSE 2004-2005/tcp`, ALPINE) Skip("Cannot be run within a container.") } addXXX2 := SystemExec("ip", []string{"netns", "add", "xxx2"}) - Expect(addXXX2).Should(Exit(0)) + Expect(addXXX2).Should(ExitCleanly()) defer func() { delXXX2 := SystemExec("ip", []string{"netns", "delete", "xxx2"}) - Expect(delXXX2).Should(Exit(0)) + Expect(delXXX2).Should(ExitCleanly()) }() mdXXX2 := SystemExec("mkdir", []string{"-p", "/etc/netns/xxx2"}) - Expect(mdXXX2).Should(Exit(0)) + Expect(mdXXX2).Should(ExitCleanly()) defer os.RemoveAll("/etc/netns/xxx2") nsXXX2 := SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx2/resolv.conf"}) - Expect(nsXXX2).Should(Exit(0)) + Expect(nsXXX2).Should(ExitCleanly()) session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx2", ALPINE, "cat", "/etc/resolv.conf"}) session.Wait(90) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("11.11.11.11")) }) @@ -898,7 +902,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) networkNSName := RandomString(12) addNamedNetwork := SystemExec("ip", []string{"netns", "add", networkNSName}) - Expect(addNamedNetwork).Should(Exit(0)) + Expect(addNamedNetwork).Should(ExitCleanly()) setupNetworkNs(networkNSName) @@ -908,7 +912,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) // delete the named network ns before inspect delNetworkNamespace := SystemExec("ip", []string{"netns", "delete", networkNSName}) - Expect(delNetworkNamespace).Should(Exit(0)) + Expect(delNetworkNamespace).Should(ExitCleanly()) inspectOut := podmanTest.InspectContainer(name) Expect(inspectOut[0].NetworkSettings).To(HaveField("IPAddress", "")) @@ -920,10 +924,10 @@ EXPOSE 2004-2005/tcp`, ALPINE) networkNSName := RandomString(12) addNamedNetwork := SystemExec("ip", []string{"netns", "add", networkNSName}) - Expect(addNamedNetwork).Should(Exit(0)) + Expect(addNamedNetwork).Should(ExitCleanly()) defer func() { delNetworkNamespace := SystemExec("ip", []string{"netns", "delete", networkNSName}) - Expect(delNetworkNamespace).Should(Exit(0)) + Expect(delNetworkNamespace).Should(ExitCleanly()) }() setupNetworkNs(networkNSName) @@ -946,10 +950,10 @@ EXPOSE 2004-2005/tcp`, ALPINE) networkNSName := RandomString(12) addNamedNetwork := SystemExec("ip", []string{"netns", "add", networkNSName}) - Expect(addNamedNetwork).Should(Exit(0)) + Expect(addNamedNetwork).Should(ExitCleanly()) defer func() { delNetworkNamespace := SystemExec("ip", []string{"netns", "delete", networkNSName}) - Expect(delNetworkNamespace).Should(Exit(0)) + Expect(delNetworkNamespace).Should(ExitCleanly()) }() setupNetworkNs(networkNSName) @@ -988,12 +992,12 @@ EXPOSE 2004-2005/tcp`, ALPINE) ipAddr := "10.25.30.128" create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.30.0/24", netName}) create.WaitWithDefaultTimeout() - Expect(create).Should(Exit(0)) + Expect(create).Should(ExitCleanly()) defer podmanTest.removeNetwork(netName) run := podmanTest.Podman([]string{"run", "--rm", "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.OutputToString()).To(ContainSubstring(ipAddr)) }) @@ -1001,24 +1005,24 @@ EXPOSE 2004-2005/tcp`, ALPINE) netName := createNetworkName("") create := podmanTest.Podman([]string{"network", "create", netName}) create.WaitWithDefaultTimeout() - Expect(create).Should(Exit(0)) + Expect(create).Should(ExitCleanly()) defer podmanTest.removeNetwork(netName) name := "nc-server" run := podmanTest.Podman([]string{"run", "--log-driver", "k8s-file", "-d", "--name", name, "--net", netName, ALPINE, "nc", "-l", "-p", "9480"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) // NOTE: we force the k8s-file log driver to make sure the // tests are passing inside a container. // "sleep" needed to give aardvark-dns time to come up; #16272 run = podmanTest.Podman([]string{"run", "--log-driver", "k8s-file", "--rm", "--net", netName, "--uidmap", "0:1:4096", ALPINE, "sh", "-c", fmt.Sprintf("sleep 2;echo podman | nc -w 1 %s.dns.podman 9480", name)}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) log := podmanTest.Podman([]string{"logs", name}) log.WaitWithDefaultTimeout() - Expect(log).Should(Exit(0)) + Expect(log).Should(ExitCleanly()) Expect(log.OutputToString()).To(Equal("podman")) }) @@ -1028,24 +1032,24 @@ EXPOSE 2004-2005/tcp`, ALPINE) podname := "testpod" create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.40.0/24", netName}) create.WaitWithDefaultTimeout() - Expect(create).Should(Exit(0)) + Expect(create).Should(ExitCleanly()) defer podmanTest.removeNetwork(netName) run := podmanTest.Podman([]string{"run", "--rm", "--pod", "new:" + podname, "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.OutputToString()).To(ContainSubstring(ipAddr)) podrm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", podname}) podrm.WaitWithDefaultTimeout() - Expect(podrm).Should(Exit(0)) + Expect(podrm).Should(ExitCleanly()) }) It("podman run with --net=host and --hostname sets correct hostname", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=host", "--hostname", hostname, ALPINE, "hostname"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.OutputToString()).To(ContainSubstring(hostname)) }) @@ -1053,7 +1057,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "hostname"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.OutputToString()).To(ContainSubstring(hostname)) }) @@ -1061,7 +1065,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.OutputToString()).To(ContainSubstring(hostname)) }) @@ -1070,10 +1074,10 @@ EXPOSE 2004-2005/tcp`, ALPINE) hostname := "test-hostname" run := podmanTest.Podman([]string{"pod", "create", "--hostname", hostname, "--name", pod}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) run = podmanTest.Podman([]string{"run", "--pod", pod, ALPINE, "cat", "/etc/hosts"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.OutputToString()).ToNot(ContainSubstring("127.0.0.1 %s", hostname)) }) @@ -1081,11 +1085,11 @@ EXPOSE 2004-2005/tcp`, ALPINE) hostname := "testctr" run := podmanTest.Podman([]string{"run", netns, "--cap-add", "net_raw", "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) run = podmanTest.Podman([]string{"run", netns, "--cap-add", "net_raw", "--hostname", hostname, "--name", "test", ALPINE, "ping", "-c", "1", "test"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) } It("podman attempt to ping container name and hostname --net=none", func() { @@ -1100,27 +1104,27 @@ EXPOSE 2004-2005/tcp`, ALPINE) pod := "testpod" session := podmanTest.Podman([]string{"pod", "create", "--name", pod}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) net := createNetworkName("IntTest") session = podmanTest.Podman([]string{"network", "create", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) pod2 := "testpod2" hostname := "hostn1" session = podmanTest.Podman([]string{"pod", "create", "--network", net, "--name", pod2, "--hostname", hostname}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--name", "con1", "--network", net, ALPINE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--name", "con2", "--pod", pod, "--network", net, ALPINE, "nslookup", "con2"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() @@ -1129,11 +1133,11 @@ EXPOSE 2004-2005/tcp`, ALPINE) session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, ALPINE, "nslookup", pod2 + ".dns.podman"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "nslookup", hostname}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman network adds dns search domain with dns", func() { @@ -1141,11 +1145,11 @@ EXPOSE 2004-2005/tcp`, ALPINE) session := podmanTest.Podman([]string{"network", "create", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("search dns.podman")) }) @@ -1154,7 +1158,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) ctrName := "testctr" ctr := podmanTest.Podman([]string{"run", "-d", "--net=bridge", "--name", ctrName, ALPINE, "top"}) ctr.WaitWithDefaultTimeout() - Expect(ctr).Should(Exit(0)) + Expect(ctr).Should(ExitCleanly()) inspectOut := podmanTest.InspectContainer(ctrName) Expect(inspectOut).To(HaveLen(1)) @@ -1168,11 +1172,11 @@ EXPOSE 2004-2005/tcp`, ALPINE) session := podmanTest.Podman([]string{"network", "create", "--disable-dns", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--network", net, "--network-alias", "abcdef", ALPINE, "true"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run with ipam none driver", func() { @@ -1180,11 +1184,11 @@ EXPOSE 2004-2005/tcp`, ALPINE) session := podmanTest.Podman([]string{"network", "create", "--ipam-driver=none", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "ip", "addr", "show", "eth0"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).To(HaveLen(4), "output should only show link local address") }) @@ -1193,13 +1197,13 @@ EXPOSE 2004-2005/tcp`, ALPINE) session := podmanTest.Podman([]string{"network", "create", "-d", "macvlan", "--subnet", "10.10.0.0/24", net}) session.WaitWithDefaultTimeout() defer podmanTest.removeNetwork(net) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // use options and search to make sure we get the same resolv.conf everywhere run := podmanTest.Podman([]string{"run", "--network", net, "--dns", "127.0.0.128", "--dns-option", "ndots:1", "--dns-search", ".", ALPINE, "cat", "/etc/resolv.conf"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(string(run.Out.Contents())).To(Equal(`nameserver 127.0.0.128 options ndots:1 `)) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 4f66cfd4c8..02d6bec16f 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -22,10 +22,14 @@ import ( var _ = Describe("Podman run", func() { + BeforeEach(func() { + Skip("TEMPORARY: to not break git-bisect") + }) + It("podman run a container based on local image", func() { session := podmanTest.Podman([]string{"run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) // This test may seem entirely pointless, it is not. Due to compatibility @@ -41,19 +45,19 @@ var _ = Describe("Podman run", func() { for i := range names { session := podmanTest.Podman([]string{"create", ALPINE, "true"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) cid := session.OutputToString() Expect(cid).To(Not(Equal(""))) session = podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Name}}", cid}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) names[i] = session.OutputToString() Expect(names[i]).To(Not(Equal(""))) session = podmanTest.Podman([]string{"rm", cid}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) } Expect(names[0]).ToNot(Equal(names[1]), "Podman generated duplicate successive container names, has the global RNG been seeded correctly?") }) @@ -61,34 +65,34 @@ var _ = Describe("Podman run", func() { It("podman run check /run/.containerenv", func() { session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/run/.containerenv"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("")) session = podmanTest.Podman([]string{"run", "--privileged", "--name=test1", ALPINE, "cat", "/run/.containerenv"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("name=\"test1\"")) Expect(session.OutputToString()).To(ContainSubstring("image=\"" + ALPINE + "\"")) session = podmanTest.Podman([]string{"run", "-v", "/:/host", ALPINE, "cat", "/run/.containerenv"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("graphRootMounted=1")) session = podmanTest.Podman([]string{"run", "-v", "/:/host", "--privileged", ALPINE, "cat", "/run/.containerenv"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("graphRootMounted=1")) }) It("podman run from manifest list", func() { session := podmanTest.Podman([]string{"manifest", "create", "localhost/test:latest"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"build", "-f", "build/Containerfile.with-platform", "--platform", "linux/amd64,linux/arm64", "--manifest", "localhost/test:latest"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--platform", "linux/arm64", "localhost/test", "uname", "-a"}) session.WaitWithDefaultTimeout() @@ -109,7 +113,7 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", imageName, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run --signature-policy", func() { @@ -123,22 +127,22 @@ var _ = Describe("Podman run", func() { Expect(session).To(ExitWithError()) Expect(session.ErrorToString()).To(ContainSubstring("unknown flag")) } else { - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) } }) It("podman run --rm with --restart", func() { session := podmanTest.Podman([]string{"run", "--rm", "--restart", "", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--rm", "--restart", "no", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--rm", "--restart", "on-failure", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--rm", "--restart", "always", ALPINE}) session.WaitWithDefaultTimeout() @@ -159,7 +163,7 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "libpod/alpine_nginx:latest", "ls"}) session.WaitWithDefaultTimeout() Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman container run a container based on on a short name with localhost", func() { @@ -172,20 +176,20 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"container", "run", "libpod/alpine_nginx:latest", "ls"}) session.WaitWithDefaultTimeout() Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run a container based on local image with short options", func() { session := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run a container based on local image with short options and args", func() { // regression test for #714 session := podmanTest.Podman([]string{"run", ALPINE, "find", "/etc", "-name", "hosts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("/etc/hosts")) }) @@ -194,7 +198,7 @@ var _ = Describe("Podman run", func() { hostname := "test_hostname" session := podmanTest.Podman([]string{"run", "--rm", "--name", name, "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(name)) Expect(session.OutputToString()).To(ContainSubstring(hostname)) }) @@ -203,13 +207,13 @@ var _ = Describe("Podman run", func() { // Changing session to rsession rsession := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"}) rsession.WaitWithDefaultTimeout() - Expect(rsession).Should(Exit(0)) + Expect(rsession).Should(ExitCleanly()) lock := GetPortLock("5000") defer lock.Unlock() session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) { Skip("Cannot start docker registry.") @@ -217,14 +221,14 @@ var _ = Describe("Podman run", func() { run := podmanTest.Podman([]string{"run", "--tls-verify=false", ALPINE}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(podmanTest.NumberOfContainers()).To(Equal(3)) // Now registries.conf will be consulted where localhost:5000 // is set to be insecure. run = podmanTest.Podman([]string{"run", ALPINE}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) }) It("podman run a container with a --rootfs", func() { @@ -241,25 +245,25 @@ var _ = Describe("Podman run", func() { csession := podmanTest.Podman([]string{"run", "--name", uniqueString, ALPINE, "/bin/sh", "-c", fmt.Sprintf("echo %s > %s", uniqueString, testFilePath)}) csession.WaitWithDefaultTimeout() - Expect(csession).Should(Exit(0)) + Expect(csession).Should(ExitCleanly()) // Export from working container image guarantees working root esession := podmanTest.Podman([]string{"export", "--output", tarball, uniqueString}) esession.WaitWithDefaultTimeout() - Expect(esession).Should(Exit(0)) + Expect(esession).Should(ExitCleanly()) Expect(tarball).Should(BeARegularFile()) // N/B: This will lose any extended attributes like SELinux types GinkgoWriter.Printf("Extracting container root tarball\n") tarsession := SystemExec("tar", []string{"xf", tarball, "-C", rootfs}) - Expect(tarsession).Should(Exit(0)) + Expect(tarsession).Should(ExitCleanly()) Expect(filepath.Join(rootfs, uls)).Should(BeADirectory()) // Other tests confirm SELinux types, just confirm --rootfs is working. session := podmanTest.Podman([]string{"run", "-i", "--security-opt", "label=disable", "--rootfs", rootfs, "cat", testFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // Validate changes made in original container and export stdoutLines := session.OutputToStringArray() @@ -280,43 +284,43 @@ var _ = Describe("Podman run", func() { osession := podmanTest.Podman([]string{"run", "-i", "--rm", "--security-opt", "label=disable", "--rootfs", rootfs + ":O", "cat", testFilePath}) osession.WaitWithDefaultTimeout() - Expect(osession).Should(Exit(0)) + Expect(osession).Should(ExitCleanly()) // Test podman start stop with overlay osession = podmanTest.Podman([]string{"run", "--name", "overlay-foo", "--security-opt", "label=disable", "--rootfs", rootfs + ":O", "echo", "hello"}) osession.WaitWithDefaultTimeout() - Expect(osession).Should(Exit(0)) + Expect(osession).Should(ExitCleanly()) osession = podmanTest.Podman([]string{"stop", "overlay-foo"}) osession.WaitWithDefaultTimeout() - Expect(osession).Should(Exit(0)) + Expect(osession).Should(ExitCleanly()) startsession := podmanTest.Podman([]string{"start", "--attach", "overlay-foo"}) startsession.WaitWithDefaultTimeout() - Expect(startsession).Should(Exit(0)) + Expect(startsession).Should(ExitCleanly()) Expect(startsession.OutputToString()).To(Equal("hello")) // remove container for above test overlay-foo osession = podmanTest.Podman([]string{"rm", "overlay-foo"}) osession.WaitWithDefaultTimeout() - Expect(osession).Should(Exit(0)) + Expect(osession).Should(ExitCleanly()) // Test --rootfs with an external overlay with --uidmap osession = podmanTest.Podman([]string{"run", "--uidmap", "0:1000:1000", "--rm", "--security-opt", "label=disable", "--rootfs", rootfs + ":O", "echo", "hello"}) osession.WaitWithDefaultTimeout() - Expect(osession).Should(Exit(0)) + Expect(osession).Should(ExitCleanly()) Expect(osession.OutputToString()).To(Equal("hello")) }) It("podman run a container with --init", func() { session := podmanTest.Podman([]string{"run", "--name", "test", "--init", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) result := podmanTest.Podman([]string{"inspect", "test"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) conData := result.InspectContainerToJSON() Expect(conData[0]).To(HaveField("Path", define.ContainerInitPath)) Expect(conData[0].Config.Annotations).To(HaveKeyWithValue("io.podman.annotations.init", "TRUE")) @@ -326,10 +330,10 @@ var _ = Describe("Podman run", func() { // Also bind-mount /dev (#14251). session := podmanTest.Podman([]string{"run", "-v", "/dev:/dev", "--name", "test", "--init", "--init-path", "/usr/libexec/podman/catatonit", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) result := podmanTest.Podman([]string{"inspect", "test"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) conData := result.InspectContainerToJSON() Expect(conData[0]).To(HaveField("Path", define.ContainerInitPath)) Expect(conData[0].Config.Annotations).To(HaveKeyWithValue("io.podman.annotations.init", "TRUE")) @@ -338,10 +342,10 @@ var _ = Describe("Podman run", func() { It("podman run a container without --init", func() { session := podmanTest.Podman([]string{"run", "--name", "test", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) result := podmanTest.Podman([]string{"inspect", "test"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) conData := result.InspectContainerToJSON() Expect(conData[0]).To(HaveField("Path", "ls")) Expect(conData[0].Config.Annotations).To(Not(HaveKey("io.podman.annotations.init"))) @@ -360,56 +364,56 @@ var _ = Describe("Podman run", func() { It("podman run mask and unmask path test", func() { session := podmanTest.Podman([]string{"run", "-d", "--name=maskCtr1", "--security-opt", "unmask=ALL", "--security-opt", "mask=/proc/acpi", ALPINE, "sleep", "200"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "maskCtr1", "ls", "/sys/firmware"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(BeEmpty())) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "maskCtr1", "ls", "/proc/acpi"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(BeEmpty()) session = podmanTest.Podman([]string{"run", "-d", "--name=maskCtr2", "--security-opt", "unmask=/proc/acpi:/sys/firmware", ALPINE, "sleep", "200"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "maskCtr2", "ls", "/sys/firmware"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(BeEmpty())) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "maskCtr2", "ls", "/proc/acpi"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(BeEmpty())) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "-d", "--name=maskCtr3", "--security-opt", "mask=/sys/power/disk", ALPINE, "sleep", "200"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "maskCtr3", "cat", "/sys/power/disk"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(BeEmpty()) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "-d", "--name=maskCtr4", "--security-opt", "systempaths=unconfined", ALPINE, "sleep", "200"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "maskCtr4", "ls", "/sys/firmware"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(BeEmpty())) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "-d", "--name=maskCtr5", "--security-opt", "systempaths=unconfined", ALPINE, "grep", "/proc", "/proc/self/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).Should(HaveLen(1)) session = podmanTest.Podman([]string{"run", "-d", "--security-opt", "unmask=/proc/*", ALPINE, "grep", "/proc", "/proc/self/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).Should(HaveLen(1)) session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/proc/a*", ALPINE, "ls", "/proc/acpi"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Not(BeEmpty())) }) @@ -420,32 +424,32 @@ var _ = Describe("Podman run", func() { rwOnCgroups := "/sys/fs/cgroup cgroup2 rw" session := podmanTest.Podman([]string{"run", "--security-opt", "unmask=ALL", "--security-opt", "mask=/sys/fs/cgroup", ALPINE, "cat", "/proc/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(rwOnCgroups)) session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/sys/fs/cgroup", ALPINE, "cat", "/proc/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(rwOnCgroups)) session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/sys/fs/cgroup///", ALPINE, "cat", "/proc/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(rwOnCgroups)) session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=ALL", ALPINE, "cat", "/proc/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(rwOnCgroups)) session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/sys/fs/cgroup", "--security-opt", "mask=/sys/fs/cgroup", ALPINE, "cat", "/proc/mounts"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(rwOnCgroups)) session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/sys/fs/cgroup", ALPINE, "ls", "/sys/fs/cgroup"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).ToNot(BeEmpty()) }) @@ -467,32 +471,32 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "--privileged", ALPINE, "grep", "Seccomp", "/proc/self/status"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(ContainSubstring("0")) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run seccomp test no profile should be default", func() { session := podmanTest.Podman([]string{"run", ALPINE, "grep", "Seccomp", "/proc/self/status"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(ContainSubstring("2")) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run capabilities test", func() { session := podmanTest.Podman([]string{"run", "--rm", "--cap-add", "all", ALPINE, "cat", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--rm", "--cap-add", "sys_admin", ALPINE, "cat", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--rm", "--cap-drop", "all", ALPINE, "cat", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--rm", "--cap-drop", "setuid", ALPINE, "cat", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run user capabilities test", func() { @@ -503,72 +507,72 @@ var _ = Describe("Podman run", func() { } session := podmanTest.Podman([]string{"run", "--rm", "--user", "bin", ALPINE, "grep", "CapBnd", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "bin", ALPINE, "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "bin", ALPINE, "grep", "CapInh", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "root", ALPINE, "grep", "CapBnd", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "root", ALPINE, "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "root", ALPINE, "grep", "CapInh", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "grep", "CapBnd", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb")) session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb")) session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapInh", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) session = podmanTest.Podman([]string{"run", "--user=0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--user=0:0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--user=0:0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapInh", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--user=1:1", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) if isRootless() { @@ -580,17 +584,17 @@ var _ = Describe("Podman run", func() { } session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--privileged", "--rm", ALPINE, "grep", "CapInh", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapInh", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) } }) @@ -606,12 +610,12 @@ USER bin`, BB) podmanTest.BuildImage(dockerfile, "test", "false") session := podmanTest.Podman([]string{"run", "--rm", "--user", "bin", "test", "grep", "CapBnd", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("00000000800405fb")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "bin", "test", "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) }) @@ -621,29 +625,29 @@ USER bin`, BB) if !isRootless() { session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "rtprio=99", "--cap-add=sys_nice", fedoraMinimal, "cat", "/proc/self/sched"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) } session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "nofile=2048:2048", fedoraMinimal, "ulimit", "-n"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("2048")) session = podmanTest.Podman([]string{"run", "--rm", "--ulimit", "nofile=1024:1028", fedoraMinimal, "ulimit", "-n"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("1024")) if !CGROUPSV2 { // --oom-kill-disable not supported on cgroups v2. session = podmanTest.Podman([]string{"run", "--rm", "--oom-kill-disable=true", fedoraMinimal, "echo", "memory-hog"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) } session = podmanTest.Podman([]string{"run", "--rm", "--oom-score-adj=111", fedoraMinimal, "cat", "/proc/self/oom_score_adj"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("111")) currentOOMScoreAdj, err := os.ReadFile("/proc/self/oom_score_adj") @@ -651,12 +655,12 @@ USER bin`, BB) name := "ctr-with-oom-score" session = podmanTest.Podman([]string{"create", "--name", name, fedoraMinimal, "cat", "/proc/self/oom_score_adj"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) for i := 0; i < 2; i++ { session = podmanTest.Podman([]string{"start", "-a", name}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(strings.TrimRight(string(currentOOMScoreAdj), "\n"))) } }) @@ -671,7 +675,7 @@ USER bin`, BB) session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "host", fedoraMinimal, "ulimit", "-Hn"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ulimitCtrStr := strings.TrimSpace(session.OutputToString()) ulimitCtr, err := strconv.ParseUint(ulimitCtrStr, 10, 0) @@ -683,7 +687,7 @@ USER bin`, BB) It("podman run with cidfile", func() { session := podmanTest.Podman([]string{"run", "--cidfile", tempdir + "cidfile", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) err := os.Remove(tempdir + "cidfile") Expect(err).ToNot(HaveOccurred()) }) @@ -692,7 +696,7 @@ USER bin`, BB) SkipIfRootless("Network sysctls are not available root rootless") session := podmanTest.Podman([]string{"run", "--rm", "--sysctl", "net.core.somaxconn=65535", ALPINE, "sysctl", "net.core.somaxconn"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("net.core.somaxconn = 65535")) // network sysctls should fail if --net=host is set @@ -713,7 +717,7 @@ USER bin`, BB) } session := podmanTest.Podman([]string{"run", "--rm", "--blkio-weight=15", ALPINE, "sh", "-c", "cat /sys/fs/cgroup/io.bfq.weight"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // there was a documentation issue in the kernel that reported a different range [1-10000] for the io controller. // older versions of crun/runc used it. For the time being allow both versions to pass the test. // FIXME: drop "|51" once all the runtimes we test have the fix in place. @@ -724,7 +728,7 @@ USER bin`, BB) } session := podmanTest.Podman([]string{"run", "--rm", "--blkio-weight=15", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.weight"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("15")) } }) @@ -741,7 +745,7 @@ USER bin`, BB) } session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if !CGROUPSV2 { // TODO: Test Simplification. For now, we only care about exit(0) w/ cgroupsv2 Expect(session.OutputToString()).To(ContainSubstring("1048576")) } @@ -758,7 +762,7 @@ USER bin`, BB) session = podmanTest.Podman([]string{"run", "--rm", "--device-write-bps=/dev/zero:1mb", ALPINE, "cat", "/sys/fs/cgroup/blkio/blkio.throttle.write_bps_device"}) } session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if !CGROUPSV2 { // TODO: Test Simplification. For now, we only care about exit(0) w/ cgroupsv2 Expect(session.OutputToString()).To(ContainSubstring("1048576")) } @@ -775,7 +779,7 @@ USER bin`, BB) } session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if !CGROUPSV2 { // TODO: Test Simplification. For now, we only care about exit(0) w/ cgroupsv2 Expect(session.OutputToString()).To(ContainSubstring("100")) } @@ -792,7 +796,7 @@ USER bin`, BB) } session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if !CGROUPSV2 { // TODO: Test Simplification. For now, we only care about exit(0) w/ cgroupsv2 Expect(session.OutputToString()).To(ContainSubstring("100")) } @@ -820,7 +824,7 @@ USER bin`, BB) session := podmanTest.Podman([]string{"run", ALPINE, "printenv", "NOTIFY_SOCKET"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).ToNot(BeEmpty()) }) @@ -828,7 +832,7 @@ USER bin`, BB) log := filepath.Join(podmanTest.TempDir, "/container.log") session := podmanTest.Podman([]string{"run", "--rm", "--log-driver", "k8s-file", "--log-opt", fmt.Sprintf("path=%s", log), ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) _, err := os.Stat(log) Expect(err).ToNot(HaveOccurred()) _ = os.Remove(log) @@ -838,11 +842,11 @@ USER bin`, BB) podmanTest.AddImageToRWStore(BB) tag := podmanTest.Podman([]string{"tag", BB, "bb"}) tag.WaitWithDefaultTimeout() - Expect(tag).Should(Exit(0)) + Expect(tag).Should(ExitCleanly()) session := podmanTest.Podman([]string{"run", "--rm", "bb", "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman test hooks", func() { @@ -873,7 +877,7 @@ echo -n %s >%s session := podmanTest.Podman([]string{"--hooks-dir", hooksDir, "run", ALPINE, "ls"}) session.Wait(10) - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) b, err := os.ReadFile(targetFile) Expect(err).ToNot(HaveOccurred()) @@ -907,16 +911,16 @@ echo -n %s >%s err = os.WriteFile(keyFile, []byte(mountString), 0755) Expect(err).ToNot(HaveOccurred()) execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")}) - Expect(execSession).Should(Exit(0)) + Expect(execSession).Should(ExitCleanly()) session := podmanTest.Podman([]string{"--default-mounts-file=" + mountsFile, "run", "--rm", ALPINE, "cat", "/run/secrets/test.txt"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) session = podmanTest.Podman([]string{"--default-mounts-file=" + mountsFile, "run", "--rm", ALPINE, "ls", "/run/secrets/mysymlink"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("key.pem")) }) @@ -928,7 +932,7 @@ echo -n %s >%s session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls", "/run/secrets"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("system-fips")) err = os.Remove(fipsFile) @@ -938,63 +942,63 @@ echo -n %s >%s It("podman run without group-add", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Not(ContainSubstring("27(video),777,65533(nogroup)"))) }) It("podman run with group-add", func() { session := podmanTest.Podman([]string{"run", "--rm", "--group-add=audio", "--group-add=nogroup", "--group-add=777", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("777,65533(nogroup)")) }) It("podman run with user (default)", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("uid=0(root) gid=0(root)")) }) It("podman run with user (integer, not in /etc/passwd)", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=1234", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("uid=1234(1234) gid=0(root) groups=0(root)")) }) It("podman run with user (integer, in /etc/passwd)", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=8", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("uid=8(mail) gid=12(mail)")) }) It("podman run with user (username)", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=mail", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("uid=8(mail) gid=12(mail)")) }) It("podman run with user:group (username:integer)", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=mail:21", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("uid=8(mail) gid=21(ftp) groups=21(ftp)")) }) It("podman run with user:group (integer:groupname)", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=8:ftp", ALPINE, "id"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("uid=8(mail) gid=21(ftp) groups=21(ftp)")) }) It("podman run with user, verify caps dropped", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=1234", ALPINE, "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) capEff := strings.Split(session.OutputToString(), " ") Expect("0000000000000000").To(Equal(capEff[1])) }) @@ -1002,7 +1006,7 @@ echo -n %s >%s It("podman run with user, verify group added", func() { session := podmanTest.Podman([]string{"run", "--rm", "--user=1000:1000", ALPINE, "grep", "Groups:", "/proc/self/status"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) groups := strings.Split(session.OutputToString(), " ")[1] Expect("1000").To(Equal(groups)) }) @@ -1010,10 +1014,10 @@ echo -n %s >%s It("podman run with attach stdin outputs container ID", func() { session := podmanTest.Podman([]string{"run", "--attach", "stdin", ALPINE, "printenv"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ps := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"}) ps.WaitWithDefaultTimeout() - Expect(ps).Should(Exit(0)) + Expect(ps).Should(ExitCleanly()) Expect(ps.OutputToString()).To(ContainSubstring(session.OutputToString())) }) @@ -1026,7 +1030,7 @@ echo -n %s >%s It("podman run with attach stderr does not print stdout", func() { session := podmanTest.Podman([]string{"run", "--rm", "--attach", "stderr", ALPINE, "ls", "/"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("")) }) @@ -1051,19 +1055,19 @@ echo -n %s >%s It("podman run with named volume", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "stat", "-c", "%a %Y", "/var/tmp"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) perms := session.OutputToString() session = podmanTest.Podman([]string{"run", "--rm", "-v", "test:/var/tmp", ALPINE, "stat", "-c", "%a %Y", "/var/tmp"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(perms)) }) It("podman run with built-in volume image", func() { session := podmanTest.Podman([]string{"run", "--rm", REDIS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) dockerfile := fmt.Sprintf(`FROM %s RUN mkdir -p /myvol/data && chown -R mail.0 /myvol @@ -1073,7 +1077,7 @@ USER mail`, BB) podmanTest.BuildImage(dockerfile, "test", "false") session = podmanTest.Podman([]string{"run", "--rm", "test", "ls", "-al", "/myvol/data"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mail root")) }) @@ -1091,21 +1095,21 @@ USER mail`, BB) session := podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint + ":z", ALPINE, "cat", mountpoint + filename}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ctrID := session.OutputToString() session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID, ALPINE, "cat", mountpoint + filename}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(data)) session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID, ALPINE, "sh", "-c", "echo test >> " + mountpoint + filename}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"start", "--attach", ctrID}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(data + "test")) }) @@ -1123,7 +1127,7 @@ USER mail`, BB) session := podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint, ALPINE, "cat", mountpoint + filename}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ctrID := session.OutputToString() // check that the read-only option works @@ -1135,7 +1139,7 @@ USER mail`, BB) // check that both z and ro options work session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID + ":ro,z", ALPINE, "cat", mountpoint + filename}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(data)) // check that multiple ro/rw are not working @@ -1153,7 +1157,7 @@ USER mail`, BB) // create new read-only volume session = podmanTest.Podman([]string{"create", "--volume", vol + ":" + mountpoint + ":ro", ALPINE, "cat", mountpoint + filename}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ctrID = session.OutputToString() // check if the original volume was mounted as read-only that --volumes-from also mount it as read-only @@ -1166,12 +1170,12 @@ USER mail`, BB) It("podman run --volumes-from flag with built-in volumes", func() { session := podmanTest.Podman([]string{"create", REDIS_IMAGE, "sh"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) ctrID := session.OutputToString() session = podmanTest.Podman([]string{"run", "--volumes-from", ctrID, ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("data")) }) @@ -1190,16 +1194,16 @@ VOLUME %s`, ALPINE, volPath, volPath) ctr1 := "ctr1" run1 := podmanTest.Podman([]string{"run", "-d", "-v", fmt.Sprintf("%s:%s:z", volPathOnHost, volPath), "--name", ctr1, ALPINE, "top"}) run1.WaitWithDefaultTimeout() - Expect(run1).Should(Exit(0)) + Expect(run1).Should(ExitCleanly()) testFile := "testfile1" ctr1Exec := podmanTest.Podman([]string{"exec", "-t", ctr1, "touch", fmt.Sprintf("%s/%s", volPath, testFile)}) ctr1Exec.WaitWithDefaultTimeout() - Expect(ctr1Exec).Should(Exit(0)) + Expect(ctr1Exec).Should(ExitCleanly()) run2 := podmanTest.Podman([]string{"run", "--volumes-from", ctr1, imgName, "ls", volPath}) run2.WaitWithDefaultTimeout() - Expect(run2).Should(Exit(0)) + Expect(run2).Should(ExitCleanly()) Expect(run2.OutputToString()).To(Equal(testFile)) }) @@ -1213,7 +1217,7 @@ VOLUME %s`, ALPINE, volPath, volPath) session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", ALPINE, "touch", "/myvol2/foo.txt"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run --volumes flag with empty host dir", func() { @@ -1241,7 +1245,7 @@ VOLUME %s`, ALPINE, volPath, volPath) session := podmanTest.Podman([]string{"run", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run findmnt nothing shared", func() { @@ -1254,7 +1258,7 @@ VOLUME %s`, ALPINE, volPath, volPath) session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Not(ContainSubstring("shared"))) }) @@ -1265,12 +1269,12 @@ VOLUME %s`, ALPINE, volPath, volPath) session := podmanTest.Podman([]string{"run", "--volume", vol + ":/myvol:z", fedoraMinimal, "findmnt", "-no", "PROPAGATION", "/myvol"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("private")) session = podmanTest.Podman([]string{"run", "--volume", vol + ":/myvol:shared,z", fedoraMinimal, "findmnt", "-no", "PROPAGATION", "/myvol"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if isRootless() { // we need to relax the rootless test because it can be "shared" only when the user owns the outer mount namespace. @@ -1284,7 +1288,7 @@ VOLUME %s`, ALPINE, volPath, volPath) It("podman run --security-opts proc-opts=", func() { session := podmanTest.Podman([]string{"run", "--security-opt", "proc-opts=nosuid,exec", fedoraMinimal, "findmnt", "-noOPTIONS", "/proc"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) output := session.OutputToString() Expect(output).To(ContainSubstring("nosuid")) Expect(output).To(Not(ContainSubstring("exec"))) @@ -1294,14 +1298,14 @@ VOLUME %s`, ALPINE, volPath, volPath) SkipIfRootless("FIXME: rootless users are not allowed to mount bind-nonrecursive") session := podmanTest.Podman([]string{"run", "--mount", "type=bind,bind-nonrecursive,private,src=/sys,target=/host-sys", fedoraMinimal, "findmnt", "-nR", "/host-sys"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).To(HaveLen(1)) }) It("podman run --mount type=devpts,target=/foo/bar", func() { session := podmanTest.Podman([]string{"run", "--mount", "type=devpts,target=/foo/bar", fedoraMinimal, "stat", "-f", "-c%T", "/foo/bar"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(define.TypeDevpts)) }) @@ -1309,18 +1313,18 @@ VOLUME %s`, ALPINE, volPath, volPath) // runc doesn't seem to honor uid= so avoid testing it session := podmanTest.Podman([]string{"run", "-t", "--mount", "type=devpts,target=/dev/pts,uid=1000,gid=1001,mode=123", fedoraMinimal, "stat", "-c%g-%a", "/dev/pts/0"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("1001-123")) }) It("podman run --pod automatically", func() { session := podmanTest.Podman([]string{"run", "-d", "--pod", "new:foobar", ALPINE, "nc", "-l", "-p", "8686"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--pod", "foobar", ALPINE, "/bin/sh", "-c", "echo test | nc -w 1 127.0.0.1 8686"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"}) check.WaitWithDefaultTimeout() @@ -1331,14 +1335,14 @@ VOLUME %s`, ALPINE, volPath, volPath) hostname := "abc" session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", "--hostname", hostname, ALPINE, "cat", "/etc/hostname"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(hostname)) }) It("podman run --rm should work", func() { session := podmanTest.Podman([]string{"run", "--name", "test", "--rm", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"wait", "test"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) @@ -1374,7 +1378,7 @@ VOLUME %s`, ALPINE, volPath, volPath) It("podman run readonly container should NOT mount /dev/shm read/only", func() { session := podmanTest.Podman([]string{"run", "--read-only", ALPINE, "mount"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Not(ContainSubstring("/dev/shm type tmpfs (ro,"))) }) @@ -1382,7 +1386,7 @@ VOLUME %s`, ALPINE, volPath, volPath) It("podman run readonly container should NOT mount /run noexec", func() { session := podmanTest.Podman([]string{"run", "--read-only", ALPINE, "sh", "-c", "mount | grep \"/run \""}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Not(ContainSubstring("noexec"))) }) @@ -1460,11 +1464,11 @@ VOLUME %s`, ALPINE, volPath, volPath) ctrName := "testCtr" ctr := podmanTest.Podman([]string{"run", "-dt", "--restart=always", "--name", ctrName, ALPINE, "top"}) ctr.WaitWithDefaultTimeout() - Expect(ctr).Should(Exit(0)) + Expect(ctr).Should(ExitCleanly()) stop := podmanTest.Podman([]string{"stop", ctrName}) stop.WaitWithDefaultTimeout() - Expect(stop).Should(Exit(0)) + Expect(stop).Should(ExitCleanly()) // This is ugly, but I don't see a better way time.Sleep(10 * time.Second) @@ -1505,13 +1509,13 @@ VOLUME %s`, ALPINE, volPath, volPath) container := podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) container.WaitWithDefaultTimeout() - Expect(container).Should(Exit(0)) + Expect(container).Should(ExitCleanly()) checkLines(container.OutputToStringArray()) // check that --cgroups=split is honored also when a container runs in a pod container = podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) container.WaitWithDefaultTimeout() - Expect(container).Should(Exit(0)) + Expect(container).Should(ExitCleanly()) checkLines(container.OutputToStringArray()) }) @@ -1541,7 +1545,7 @@ VOLUME %s`, ALPINE, volPath, volPath) container := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroups=disabled", ALPINE, "cat", "/proc/self/cgroup"}) container.WaitWithDefaultTimeout() - Expect(container).Should(Exit(0)) + Expect(container).Should(ExitCleanly()) ctrCgroups := trim(container.OutputToString()) GinkgoWriter.Printf("Output\n:%s\n", ctrCgroups) @@ -1565,7 +1569,7 @@ VOLUME %s`, ALPINE, volPath, volPath) ctrName := "testctr" container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=enabled", ALPINE, "top"}) container.WaitWithDefaultTimeout() - Expect(container).Should(Exit(0)) + Expect(container).Should(ExitCleanly()) // Get PID and get cgroups of that PID inspectOut := podmanTest.InspectContainer(ctrName) @@ -1597,10 +1601,10 @@ VOLUME %s`, ALPINE, volPath, volPath) deviceCgroupRule := "c 42:* rwm" session := podmanTest.Podman([]string{"run", "--cap-add", "mknod", "--name", "test", "-d", "--device-cgroup-rule", deviceCgroupRule, ALPINE, "top"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"exec", "test", "mknod", "newDev", "c", "42", "1"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run --replace", func() { @@ -1614,7 +1618,7 @@ VOLUME %s`, ALPINE, volPath, volPath) for i := 0; i < 5; i++ { session := podmanTest.Podman([]string{"run", "--detach", "--replace", "--name", ctrName, ALPINE, "/bin/sh"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) } }) @@ -1627,7 +1631,7 @@ VOLUME %s`, ALPINE, volPath, volPath) } session := podmanTest.PodmanExtraFiles([]string{"run", "--preserve-fds", "1", ALPINE, "ls"}, files) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run --preserve-fds invalid fd", func() { @@ -1641,7 +1645,7 @@ VOLUME %s`, ALPINE, volPath, volPath) groupName := "mail" session := podmanTest.Podman([]string{"run", "--group-add", groupName, "--privileged", fedoraMinimal, "groups"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(groupName)) }) @@ -1668,12 +1672,12 @@ VOLUME %s`, ALPINE, volPath, volPath) session = podmanTest.Podman([]string{"run", "--tz", "Pacific/Honolulu", "--rm", ALPINE, "date", "+'%H %Z'"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("HST")) session = podmanTest.Podman([]string{"run", "--tz", "local", "--rm", ALPINE, "date", "+'%H %Z'"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) t := time.Now() z, _ := t.Zone() h := strconv.Itoa(t.Hour()) @@ -1687,7 +1691,7 @@ VOLUME %s`, ALPINE, volPath, volPath) limit := "4321" session := podmanTest.Podman([]string{"run", "--pids-limit", limit, "--net=none", "--rm", ALPINE, "cat", "/sys/fs/cgroup/pids.max"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(limit)) }) @@ -1698,22 +1702,22 @@ VOLUME %s`, ALPINE, volPath, volPath) session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "umask"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("0022")) session = podmanTest.Podman([]string{"run", "--umask", "0002", "--rm", ALPINE, "sh", "-c", "umask"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("0002")) session = podmanTest.Podman([]string{"run", "--umask", "0077", "--rm", fedoraMinimal, "umask"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("0077")) session = podmanTest.Podman([]string{"run", "--umask", "22", "--rm", ALPINE, "sh", "-c", "umask"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("0022")) session = podmanTest.Podman([]string{"run", "--umask", "9999", "--rm", ALPINE, "sh", "-c", "umask"}) @@ -1729,14 +1733,14 @@ WORKDIR /madethis`, BB) podmanTest.BuildImage(dockerfile, "test", "false") session := podmanTest.Podman([]string{"run", "--rm", "test", "pwd"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("/madethis")) }) It("podman run --entrypoint does not use image command", func() { session := podmanTest.Podman([]string{"run", "--entrypoint", "/bin/echo", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // We can't guarantee the output is completely empty, some // nonprintables seem to work their way in. Expect(session.OutputToString()).To(Not(ContainSubstring("/bin/sh"))) @@ -1745,13 +1749,13 @@ WORKDIR /madethis`, BB) It("podman run a container with log-level (lower case)", func() { session := podmanTest.Podman([]string{"--log-level=info", "run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run a container with log-level (upper case)", func() { session := podmanTest.Podman([]string{"--log-level=INFO", "run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) }) It("podman run a container with --pull never should fail if no local store", func() { @@ -1763,24 +1767,24 @@ WORKDIR /madethis`, BB) It("podman run container with --pull missing and only pull once", func() { session := podmanTest.Podman([]string{"run", "--pull", "missing", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) session = podmanTest.Podman([]string{"run", "--pull", "missing", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) }) It("podman run container with --pull missing should pull image multiple times", func() { session := podmanTest.Podman([]string{"run", "--pull", "always", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) session = podmanTest.Podman([]string{"run", "--pull", "always", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) }) @@ -1788,7 +1792,7 @@ WORKDIR /madethis`, BB) hostnameEnv := "test123" session := podmanTest.Podman([]string{"run", "--hostname", "testctr", "--env", fmt.Sprintf("HOSTNAME=%s", hostnameEnv), ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(hostnameEnv)) }) @@ -1800,16 +1804,16 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "mysecret", "--name", "secr", ALPINE, "cat", "/run/secrets/mysecret"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) session = podmanTest.Podman([]string{"inspect", "secr", "--format", " {{(index .Config.Secrets 0).Name}}"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret")) }) @@ -1822,16 +1826,16 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=mount", "--name", "secr", ALPINE, "cat", "/run/secrets/mysecret"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) session = podmanTest.Podman([]string{"inspect", "secr", "--format", " {{(index .Config.Secrets 0).Name}}"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret")) }) @@ -1844,16 +1848,16 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret_target", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret_target,type=mount,target=hello", "--name", "secr_target", ALPINE, "cat", "/run/secrets/hello"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) session = podmanTest.Podman([]string{"inspect", "secr_target", "--format", " {{(index .Config.Secrets 0).Name}}"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret_target")) }) @@ -1866,16 +1870,16 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret_target2", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret_target2,type=mount,target=/tmp/hello", "--name", "secr_target2", ALPINE, "cat", "/tmp/hello"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) session = podmanTest.Podman([]string{"inspect", "secr_target2", "--format", " {{(index .Config.Secrets 0).Name}}"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret_target2")) }) @@ -1888,11 +1892,11 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "printenv", "mysecret"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) }) @@ -1904,11 +1908,11 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=env,target=anotherplace", "--name", "secr", ALPINE, "printenv", "anotherplace"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) }) @@ -1920,19 +1924,19 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // check default permissions session = podmanTest.Podman([]string{"run", "--secret", "mysecret", "--name", "secr", ALPINE, "ls", "-l", "/run/secrets/mysecret"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) output := session.OutputToString() Expect(output).To(ContainSubstring("-r--r--r--")) Expect(output).To(ContainSubstring("root")) session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=mount,uid=1000,gid=1001,mode=777", "--name", "secr2", ALPINE, "ls", "-ln", "/run/secrets/mysecret"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) output = session.OutputToString() Expect(output).To(ContainSubstring("-rwxrwxrwx")) Expect(output).To(ContainSubstring("1000")) @@ -1947,11 +1951,11 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--secret", "mysecret", "--name", "nonroot", "--user", "200:200", ALPINE, "cat", "/run/secrets/mysecret"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal(secretsString)) }) @@ -1963,7 +1967,7 @@ WORKDIR /madethis`, BB) session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) // Invalid type session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=other", "--name", "secr", ALPINE, "printenv", "mysecret"}) @@ -1995,24 +1999,24 @@ WORKDIR /madethis`, BB) depName := "ctr1" depContainer := podmanTest.Podman([]string{"create", "--name", depName, ALPINE, "top"}) depContainer.WaitWithDefaultTimeout() - Expect(depContainer).Should(Exit(0)) + Expect(depContainer).Should(ExitCleanly()) mainName := "ctr2" mainContainer := podmanTest.Podman([]string{"run", "--name", mainName, "--requires", depName, "-d", ALPINE, "top"}) mainContainer.WaitWithDefaultTimeout() - Expect(mainContainer).Should(Exit(0)) + Expect(mainContainer).Should(ExitCleanly()) stop := podmanTest.Podman([]string{"stop", "--all"}) stop.WaitWithDefaultTimeout() - Expect(stop).Should(Exit(0)) + Expect(stop).Should(ExitCleanly()) start := podmanTest.Podman([]string{"start", mainName}) start.WaitWithDefaultTimeout() - Expect(start).Should(Exit(0)) + Expect(start).Should(ExitCleanly()) running := podmanTest.Podman([]string{"ps", "-q"}) running.WaitWithDefaultTimeout() - Expect(running).Should(Exit(0)) + Expect(running).Should(ExitCleanly()) Expect(running.OutputToStringArray()).To(HaveLen(2)) }) @@ -2021,7 +2025,7 @@ WORKDIR /madethis`, BB) pidfile := tempdir + "pidfile" session := podmanTest.Podman([]string{"run", "--pidfile", pidfile, ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) readFirstLine := func(path string) string { content, err := os.ReadFile(path) Expect(err).ToNot(HaveOccurred()) @@ -2039,14 +2043,14 @@ WORKDIR /madethis`, BB) } session := podmanTest.Podman([]string{"run", "--personality=LINUX32", "--name=testpersonality", ALPINE, "uname", "-a"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("i686")) }) It("podman run /dev/shm has nosuid,noexec,nodev", func() { session := podmanTest.Podman([]string{"run", ALPINE, "grep", "/dev/shm", "/proc/self/mountinfo"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) output := session.OutputToString() Expect(output).To(ContainSubstring("nosuid")) Expect(output).To(ContainSubstring("noexec")) @@ -2070,7 +2074,7 @@ WORKDIR /madethis`, BB) defer lock.Unlock() session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) { Skip("Cannot start docker registry.") @@ -2087,11 +2091,11 @@ WORKDIR /madethis`, BB) session = podmanTest.Podman([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"run", "--decryption-key", privateKeyFileName, imgPath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) + Expect(session).Should(ExitCleanly()) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) }) @@ -2099,15 +2103,15 @@ WORKDIR /madethis`, BB) ctrName := "testShmSizeSystemd" run := podmanTest.Podman([]string{"run", "--name", ctrName, "--shm-size-systemd", "10mb", "-d", SYSTEMD_IMAGE, "/sbin/init"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) logs := podmanTest.Podman([]string{"logs", ctrName}) logs.WaitWithDefaultTimeout() - Expect(logs).Should(Exit(0)) + Expect(logs).Should(ExitCleanly()) mount := podmanTest.Podman([]string{"exec", ctrName, "mount"}) mount.WaitWithDefaultTimeout() - Expect(mount).Should(Exit(0)) + Expect(mount).Should(ExitCleanly()) t, strings := mount.GrepString("tmpfs on /run/lock") Expect(t).To(BeTrue(), "found /run/lock") Expect(strings[0]).Should(ContainSubstring("size=10240k")) @@ -2119,18 +2123,18 @@ WORKDIR /madethis`, BB) imgName := "basicalpine" build := podmanTest.Podman([]string{"build", "-f", "build/basicalpine/Containerfile.with_label", "--annotation", fmt.Sprintf("%s=%s", annoName, annoValue), "-t", imgName}) build.WaitWithDefaultTimeout() - Expect(build).Should(Exit(0)) + Expect(build).Should(ExitCleanly()) Expect(build.ErrorToString()).To(BeEmpty(), "build error logged") ctrName := "ctr1" run := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, imgName, "top"}) run.WaitWithDefaultTimeout() - Expect(run).Should(Exit(0)) + Expect(run).Should(ExitCleanly()) Expect(run.ErrorToString()).To(BeEmpty(), "run error logged") inspect := podmanTest.Podman([]string{"inspect", ctrName}) inspect.WaitWithDefaultTimeout() - Expect(inspect).Should(Exit(0)) + Expect(inspect).Should(ExitCleanly()) Expect(inspect.ErrorToString()).To(BeEmpty(), "inspect error logged") inspectData := inspect.InspectContainerToJSON() diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index 069be08f7a..3937e84413 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -6,7 +6,6 @@ import ( . "github.com/containers/podman/v4/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var PodmanDockerfile = fmt.Sprintf(` @@ -24,6 +23,7 @@ LABEL RUN podman run --name NAME IMAGE`, ALPINE) var _ = Describe("podman container runlabel", func() { BeforeEach(func() { + Skip("TEMPORARY: to not break git-bisect") SkipIfRemote("runlabel is not supported for remote connections") }) @@ -33,11 +33,11 @@ var _ = Describe("podman container runlabel", func() { result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) result = podmanTest.Podman([]string{"rmi", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) }) It("podman container runlabel (ls -la)", func() { @@ -46,11 +46,11 @@ var _ = Describe("podman container runlabel", func() { result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) result = podmanTest.Podman([]string{"rmi", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) }) It("podman container runlabel --display", func() { image := "podman-runlabel-test:ls" @@ -58,12 +58,12 @@ var _ = Describe("podman container runlabel", func() { result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) Expect(result.OutputToString()).To(ContainSubstring(podmanTest.PodmanBinary + " -la")) result = podmanTest.Podman([]string{"rmi", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) }) It("podman container runlabel bogus label should result in non-zero exit code", func() { result := podmanTest.Podman([]string{"container", "runlabel", "RUN", ALPINE}) @@ -91,7 +91,7 @@ var _ = Describe("podman container runlabel", func() { result = podmanTest.Podman([]string{"rmi", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) }) It("podman container runlabel name removes tag from image", func() { @@ -100,11 +100,11 @@ var _ = Describe("podman container runlabel", func() { result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) Expect(result.OutputToString()).To(Equal("command: " + podmanTest.PodmanBinary + " run --name podman-runlabel-name localhost/" + image)) result = podmanTest.Podman([]string{"rmi", image}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) + Expect(result).Should(ExitCleanly()) }) }) From e4b7455b727e85687995a82396863f36bf892f33 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 25 Sep 2023 14:40:59 -0600 Subject: [PATCH 2/2] e2e: ExitCleanly(): manual fixes to get tests working Commit 2 of 2: fixes to get tests passing Mostly reverting back to Exit(0) on tests that produce stderr, adding stderr checks when those are missing. One pretty big exception: "run check dns" test was completely broken in many respects. It should never have worked under CNI, but was passing because nslookup in that alpine image was checking /etc/hosts. This has been fixed in subsequent alpine images, which we're now using in this test (CITEST_IMAGE). Signed-off-by: Ed Santiago --- test/e2e/common_test.go | 2 +- test/e2e/run_networking_test.go | 27 ++++++++++++--------------- test/e2e/run_test.go | 30 +++++++++++++++--------------- test/e2e/runlabel_test.go | 1 - 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 4c13a45407..4cc1ba576a 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -540,7 +540,7 @@ func (p *PodmanTestIntegration) RunContainerWithNetworkTest(mode string) *Podman if mode != "" { podmanArgs = append(podmanArgs, "--network", mode) } - podmanArgs = append(podmanArgs, fedoraMinimal, "curl", "-k", "-o", "/dev/null", "http://www.redhat.com:80") + podmanArgs = append(podmanArgs, fedoraMinimal, "curl", "-s", "-S", "-k", "-o", "/dev/null", "http://www.redhat.com:80") session := p.Podman(podmanArgs) return session } diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 86ab218777..d8712547ac 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -20,10 +20,6 @@ import ( var _ = Describe("Podman run networking", func() { - BeforeEach(func() { - Skip("TEMPORARY: to not break git-bisect") - }) - hostname, _ := os.Hostname() It("podman verify network scoped DNS server and also verify updating network dns server", func() { @@ -591,8 +587,8 @@ EXPOSE 2004-2005/tcp`, ALPINE) ncListener.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - Expect(ncListener).Should(ExitCleanly()) - Expect(ncListener.ErrorToString()).To(ContainSubstring("127.0.0.1")) + Expect(ncListener).Should(Exit(0)) + Expect(ncListener.ErrorToString()).To(ContainSubstring("Connection from 127.0.0.1")) } else { session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, "-dt", ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)}) session.WaitWithDefaultTimeout() @@ -621,8 +617,8 @@ EXPOSE 2004-2005/tcp`, ALPINE) ncListener.Wait(30) Expect(session).Should(ExitCleanly()) - Expect(ncListener).Should(ExitCleanly()) - Expect(ncListener.ErrorToString()).To(ContainSubstring(ip.String())) + Expect(ncListener).Should(Exit(0)) + Expect(ncListener.ErrorToString()).To(ContainSubstring("Connection from " + ip.String())) } else { session := podmanTest.Podman([]string{"run", "--network", networkConfiguration, ALPINE, "nc", "-w", "2", "10.0.2.2", fmt.Sprintf("%d", port)}) session.Wait(30) @@ -662,7 +658,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) SkipIfRootless("sctp protocol only works as root") session := podmanTest.Podman([]string{"--log-level=info", "run", "--name=test", "-p", "80/sctp", "-p", "81/sctp", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) // we can only check logrus on local podman if !IsRemote() { // check that the info message for sctp protocol is only displayed once @@ -1101,6 +1097,7 @@ EXPOSE 2004-2005/tcp`, ALPINE) }) It("podman run check dns", func() { + SkipIfCNI(podmanTest) pod := "testpod" session := podmanTest.Podman([]string{"pod", "create", "--name", pod}) session.WaitWithDefaultTimeout() @@ -1118,24 +1115,24 @@ EXPOSE 2004-2005/tcp`, ALPINE) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"run", "--name", "con1", "--network", net, ALPINE, "nslookup", "con1"}) + session = podmanTest.Podman([]string{"run", "--name", "con1", "--network", net, CITEST_IMAGE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"run", "--name", "con2", "--pod", pod, "--network", net, ALPINE, "nslookup", "con2"}) + session = podmanTest.Podman([]string{"run", "--name", "con2", "--pod", pod, "--network", net, CITEST_IMAGE, "nslookup", "con2"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con1"}) + session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, CITEST_IMAGE, "nslookup", "con1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(1)) - Expect(session.ErrorToString()).To(ContainSubstring("can't resolve 'con1'")) + Expect(session.OutputToString()).To(ContainSubstring("server can't find con1.dns.podman: NXDOMAIN")) - session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, ALPINE, "nslookup", pod2 + ".dns.podman"}) + session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, CITEST_IMAGE, "nslookup", pod2 + ".dns.podman"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"run", "--network", net, ALPINE, "nslookup", hostname}) + session = podmanTest.Podman([]string{"run", "--network", net, CITEST_IMAGE, "nslookup", hostname}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 02d6bec16f..0b65122c9c 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -22,10 +22,6 @@ import ( var _ = Describe("Podman run", func() { - BeforeEach(func() { - Skip("TEMPORARY: to not break git-bisect") - }) - It("podman run a container based on local image", func() { session := podmanTest.Podman([]string{"run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() @@ -90,7 +86,7 @@ var _ = Describe("Podman run", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"build", "-f", "build/Containerfile.with-platform", "--platform", "linux/amd64,linux/arm64", "--manifest", "localhost/test:latest"}) + session = podmanTest.Podman([]string{"build", "-q", "-f", "build/Containerfile.with-platform", "--platform", "linux/amd64,linux/arm64", "--manifest", "localhost/test:latest"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -127,7 +123,8 @@ var _ = Describe("Podman run", func() { Expect(session).To(ExitWithError()) Expect(session.ErrorToString()).To(ContainSubstring("unknown flag")) } else { - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) + Expect(session.ErrorToString()).To(ContainSubstring("Getting image source signatures")) } }) @@ -1509,14 +1506,16 @@ VOLUME %s`, ALPINE, volPath, volPath) container := podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) container.WaitWithDefaultTimeout() - Expect(container).Should(ExitCleanly()) + Expect(container).Should(Exit(0)) checkLines(container.OutputToStringArray()) + Expect(container.ErrorToString()).To(ContainSubstring("Running scope as unit: ")) // check that --cgroups=split is honored also when a container runs in a pod container = podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) container.WaitWithDefaultTimeout() - Expect(container).Should(ExitCleanly()) + Expect(container).Should(Exit(0)) checkLines(container.OutputToStringArray()) + Expect(container.ErrorToString()).To(ContainSubstring("Running scope as unit: ")) }) It("podman run with cgroups=disabled runs without cgroups", func() { @@ -1749,13 +1748,15 @@ WORKDIR /madethis`, BB) It("podman run a container with log-level (lower case)", func() { session := podmanTest.Podman([]string{"--log-level=info", "run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) + Expect(session.ErrorToString()).To(ContainSubstring(" level=info ")) }) It("podman run a container with log-level (upper case)", func() { session := podmanTest.Podman([]string{"--log-level=INFO", "run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) + Expect(session.ErrorToString()).To(ContainSubstring(" level=info ")) }) It("podman run a container with --pull never should fail if no local store", func() { @@ -1767,24 +1768,23 @@ WORKDIR /madethis`, BB) It("podman run container with --pull missing and only pull once", func() { session := podmanTest.Podman([]string{"run", "--pull", "missing", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) session = podmanTest.Podman([]string{"run", "--pull", "missing", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) }) It("podman run container with --pull missing should pull image multiple times", func() { session := podmanTest.Podman([]string{"run", "--pull", "always", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) session = podmanTest.Podman([]string{"run", "--pull", "always", CIRROS_IMAGE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) }) @@ -2095,7 +2095,7 @@ WORKDIR /madethis`, BB) session = podmanTest.Podman([]string{"run", "--decryption-key", privateKeyFileName, imgPath}) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) }) diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index 3937e84413..488b0b6ef8 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -23,7 +23,6 @@ LABEL RUN podman run --name NAME IMAGE`, ALPINE) var _ = Describe("podman container runlabel", func() { BeforeEach(func() { - Skip("TEMPORARY: to not break git-bisect") SkipIfRemote("runlabel is not supported for remote connections") })