diff options
30 files changed, 165 insertions, 239 deletions
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index aca2b831b..420ed929f 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -230,8 +230,7 @@ RUN printenv http_proxy`, ALPINE) session := podmanTest.Podman([]string{"build", "--pull-never", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir}) session.Wait(120) Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("1.2.3.4") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) os.Unsetenv("http_proxy") }) @@ -284,8 +283,7 @@ RUN find /test`, ALPINE) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "Containerfile", targetSubPath}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("/test/dummy") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/test/dummy")) }) It("podman remote test container/docker file is not at root of context dir", func() { @@ -392,8 +390,7 @@ subdir**` Expect(session).Should(Exit(0)) ok, _ := session.GrepString("/testfilter/dummy1") Expect(ok).NotTo(BeTrue()) - ok, _ = session.GrepString("/testfilter/dummy2") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/testfilter/dummy2")) ok, _ = session.GrepString("/testfilter/subdir") Expect(ok).NotTo(BeTrue()) //.dockerignore filters both subdir and inside subdir ok, _ = session.GrepString("/testfilter/subdir/dummy3") @@ -450,14 +447,10 @@ RUN [[ -L /test/dummy-symlink ]] && echo SYMLNKOK || echo SYMLNKERR`, ALPINE) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", targetSubPath}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("/test/dummy") - Expect(ok).To(BeTrue()) - ok, _ = session.GrepString("/test/emptyDir") - Expect(ok).To(BeTrue()) - ok, _ = session.GrepString("/test/dummy-symlink") - Expect(ok).To(BeTrue()) - ok, _ = session.GrepString("SYMLNKOK") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/test/dummy")) + Expect(session.OutputToString()).To(ContainSubstring("/test/emptyDir")) + Expect(session.OutputToString()).To(ContainSubstring("/test/dummy-symlink")) + Expect(session.OutputToString()).To(ContainSubstring("SYMLNKOK")) }) It("podman build --from, --add-host, --cap-drop, --cap-add", func() { diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index e34c07d49..cc827a453 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -191,7 +191,7 @@ var _ = Describe("Podman checkpoint", func() { ps := podmanTest.Podman([]string{"ps", "-q", "--no-trunc"}) ps.WaitWithDefaultTimeout() Expect(ps).Should(Exit(0)) - Expect(ps.LineInOutputContains(session1.OutputToString())).To(BeTrue()) + Expect(ps.OutputToString()).To(ContainSubstring(session1.OutputToString())) Expect(ps.LineInOutputContains(session2.OutputToString())).To(BeFalse()) result = podmanTest.Podman([]string{"container", "restore", "second"}) diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index 2faad8d91..6a760da17 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -224,21 +224,21 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("search foobar.com") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search foobar.com"))) }) It("podman run add dns server", func() { session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("server 1.2.3.4") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4"))) }) It("podman run add dns option", func() { session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("options debug") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("options debug"))) }) It("podman run containers.conf remove all search domain", func() { @@ -252,7 +252,7 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputStartsWith("search")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search"))) Expect(session.OutputToString()).To(ContainSubstring("foobar.com")) Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) @@ -308,7 +308,7 @@ var _ = Describe("Podman run", func() { session = podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputStartsWith("search")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search"))) Expect(session.OutputToString()).To(ContainSubstring("foobar.com")) Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) Expect(session.OutputToString()).To(ContainSubstring("debug")) @@ -430,7 +430,7 @@ var _ = Describe("Podman run", func() { session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains("containers/storage/tmp")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("containers/storage/tmp")) containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"storage1\"")) err = ioutil.WriteFile(configPath, containersConf, os.ModePerm) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index d20dc8874..f237d24b9 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -237,8 +237,7 @@ var _ = Describe("Podman create", func() { check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString("foobar") - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring("foobar")) }) It("podman create --pod-id-file", func() { diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index 65ec0d1de..71696f5b6 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -64,8 +64,8 @@ var _ = Describe("Podman diff", func() { session.WaitWithDefaultTimeout() containerDiff := session.OutputToStringArray() sort.Strings(containerDiff) - Expect(session.LineInOutputContains("C /tmp")).To(BeTrue()) - Expect(session.LineInOutputContains("A /tmp/diff-test")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("C /tmp")) + Expect(session.OutputToString()).To(ContainSubstring("A /tmp/diff-test")) session = podmanTest.Podman([]string{"commit", "diff-test", "diff-test-img"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -88,8 +88,8 @@ var _ = Describe("Podman diff", func() { session.WaitWithDefaultTimeout() containerDiff := session.OutputToStringArray() sort.Strings(containerDiff) - Expect(session.LineInOutputContains("C /tmp")).To(BeTrue()) - Expect(session.LineInOutputContains("A /tmp/diff-test")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("C /tmp")) + Expect(session.OutputToString()).To(ContainSubstring("A /tmp/diff-test")) Expect(session).Should(Exit(0)) }) @@ -127,9 +127,9 @@ RUN echo test session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically("==", 4)) - Expect(session.LineInOutputContains("A " + file1)).To(BeTrue()) - Expect(session.LineInOutputContains("A " + file2)).To(BeTrue()) - Expect(session.LineInOutputContains("A " + file3)).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("A " + file1)) + Expect(session.OutputToString()).To(ContainSubstring("A " + file2)) + Expect(session.OutputToString()).To(ContainSubstring("A " + file3)) }) It("podman image diff of single image", func() { diff --git a/test/e2e/image_scp_test.go b/test/e2e/image_scp_test.go index 3e7e8da48..63276e57f 100644 --- a/test/e2e/image_scp_test.go +++ b/test/e2e/image_scp_test.go @@ -77,7 +77,7 @@ var _ = Describe("podman image scp", func() { list := podmanTest.Podman([]string{"image", "list"}) // our image should now contain alpine loaded in from root list.WaitWithDefaultTimeout() Expect(list).To(Exit(0)) - Expect(list.LineInOutputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(list.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine"))) scp = podmanTest.PodmanAsUser([]string{"image", "scp", "root@localhost::" + ALPINE}, 0, 0, "", env) //transfer from root to rootless (us) scp.WaitWithDefaultTimeout() diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index b07e287ac..3ed8ef462 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -41,8 +41,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOutputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) - Expect(session.LineInOutputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine"))) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox"))) }) It("podman image List", func() { @@ -50,8 +50,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOutputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) - Expect(session.LineInOutputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine"))) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox"))) }) It("podman images with multiple tags", func() { @@ -86,8 +86,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOutputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) - Expect(session.LineInOutputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/alpine"))) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("quay.io/libpod/busybox"))) }) It("podman empty images list in JSON format", func() { @@ -150,13 +150,13 @@ var _ = Describe("Podman images", func() { retalpine.WaitWithDefaultTimeout() Expect(retalpine).Should(Exit(0)) Expect(len(retalpine.OutputToStringArray())).To(Equal(6)) - Expect(retalpine.LineInOutputContains("alpine")).To(BeTrue()) + Expect(retalpine.OutputToString()).To(ContainSubstring("alpine")) retalpine = podmanTest.Podman([]string{"images", "-f", "reference=alpine"}) retalpine.WaitWithDefaultTimeout() Expect(retalpine).Should(Exit(0)) Expect(len(retalpine.OutputToStringArray())).To(Equal(6)) - Expect(retalpine.LineInOutputContains("alpine")).To(BeTrue()) + Expect(retalpine.OutputToString()).To(ContainSubstring("alpine")) retnone := podmanTest.Podman([]string{"images", "-q", "-f", "reference=bogus"}) retnone.WaitWithDefaultTimeout() diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index 13a0f6f90..5531bed8c 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -87,7 +87,7 @@ var _ = Describe("Podman import", func() { results := podmanTest.Podman([]string{"history", "imported-image", "--format", "{{.Comment}}"}) results.WaitWithDefaultTimeout() Expect(results).Should(Exit(0)) - Expect(results.LineInOutputStartsWith("importing container test message")).To(BeTrue()) + Expect(results.OutputToStringArray()).To(ContainElement(HavePrefix("importing container test message"))) }) It("podman import with change flag CMD=<path>", func() { diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index a3ee1814a..e79c1eb8a 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -214,7 +214,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"images", "hello:world"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) - Expect(result.LineInOutputContains("localhost")).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring("localhost")) }) It("podman load localhost registry from scratch and :latest", func() { @@ -239,7 +239,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"images", "hello:latest"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) - Expect(result.LineInOutputContains("localhost")).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring("localhost")) }) It("podman load localhost registry from dir", func() { @@ -265,7 +265,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"images", "load:latest"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) - Expect(result.LineInOutputContains("localhost")).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring("localhost")) }) It("podman load xz compressed image", func() { @@ -290,7 +290,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"load", "-i", "./testdata/docker-two-images.tar.xz"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(result.LineInOutputContains("example.com/empty:latest")).To(BeTrue()) - Expect(result.LineInOutputContains("example.com/empty/but:different")).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring("example.com/empty:latest")) + Expect(result.OutputToString()).To(ContainSubstring("example.com/empty/but:different")) }) }) diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index d64b28063..953380335 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -46,7 +46,7 @@ var _ = Describe("Podman network", func() { session := podmanTest.Podman([]string{"network", "ls"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains(name)).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(name)) }) It("podman network list -q", func() { @@ -56,7 +56,7 @@ var _ = Describe("Podman network", func() { session := podmanTest.Podman([]string{"network", "ls", "--quiet"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains(name)).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(name)) }) It("podman network list --filter success", func() { @@ -66,7 +66,7 @@ var _ = Describe("Podman network", func() { session := podmanTest.Podman([]string{"network", "ls", "--filter", "driver=bridge"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains(name)).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(name)) }) It("podman network list --filter driver and name", func() { @@ -200,7 +200,7 @@ var _ = Describe("Podman network", func() { session := podmanTest.Podman([]string{"network", "ls", "--quiet"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains(name)).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(name)) rm := podmanTest.Podman([]string{"network", rm, name}) rm.WaitWithDefaultTimeout() diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index f5a2caad7..820b13a17 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -48,8 +48,7 @@ var _ = Describe("Podman pod create", func() { check := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString(podID) - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring(podID)) Expect(len(check.OutputToStringArray())).To(Equal(1)) }) @@ -60,8 +59,7 @@ var _ = Describe("Podman pod create", func() { check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString(name) - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring(name)) }) It("podman create pod with doubled name", func() { @@ -646,8 +644,7 @@ ENTRYPOINT ["sleep","99999"] session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) uid := fmt.Sprintf("%d", os.Geteuid()) - ok, _ := session.GrepString(uid) - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(uid)) // Check passwd session = podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "id", "-un"}) @@ -655,8 +652,7 @@ ENTRYPOINT ["sleep","99999"] Expect(session).Should(Exit(0)) u, err := user.Current() Expect(err).To(BeNil()) - ok, _ = session.GrepString(u.Name) - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(u.Name)) // root owns /usr session = podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "stat", "-c%u", "/usr"}) @@ -808,8 +804,7 @@ ENTRYPOINT ["sleep","99999"] session = podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("8191") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("8191")) }) It("podman pod create --userns=auto:gidmapping=", func() { @@ -846,8 +841,7 @@ ENTRYPOINT ["sleep","99999"] session = podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "cat", "/proc/self/gid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("8191") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("8191")) }) It("podman pod create --volume", func() { diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 3bd7f48ab..6d57c3887 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -42,8 +42,7 @@ var _ = Describe("Podman pod create", func() { check := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString(podID) - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring(podID)) Expect(len(check.OutputToStringArray())).To(Equal(1)) check = podmanTest.Podman([]string{"ps", "-qa", "--no-trunc"}) diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index e5c7576ae..776687113 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -62,7 +62,7 @@ var _ = Describe("Podman port", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) port := strings.Split(result.OutputToStringArray()[0], ":")[1] - Expect(result.LineInOutputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue()) + Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port)))) }) It("podman container port -l nginx", func() { @@ -80,7 +80,7 @@ var _ = Describe("Podman port", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) port := strings.Split(result.OutputToStringArray()[0], ":")[1] - Expect(result.LineInOutputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue()) + Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port)))) }) It("podman port -l port nginx", func() { @@ -98,7 +98,7 @@ var _ = Describe("Podman port", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) port := strings.Split(result.OutputToStringArray()[0], ":")[1] - Expect(result.LineInOutputStartsWith(fmt.Sprintf("0.0.0.0:%s", port))).To(BeTrue()) + Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix(fmt.Sprintf("0.0.0.0:%s", port)))) }) It("podman port -a nginx", func() { @@ -125,7 +125,7 @@ var _ = Describe("Podman port", func() { result := podmanTest.Podman([]string{"port", "portcheck"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - result.LineInOutputStartsWith("80/tcp -> 0.0.0.0:") + Expect(result.OutputToStringArray()).To(ContainElement(HavePrefix("80/tcp -> 0.0.0.0:"))) }) It("podman port multiple ports", func() { @@ -143,12 +143,12 @@ var _ = Describe("Podman port", func() { result1 := podmanTest.Podman([]string{"port", "test", "5000"}) result1.WaitWithDefaultTimeout() Expect(result1).Should(Exit(0)) - Expect(result1.LineInOutputStartsWith("0.0.0.0:5000")).To(BeTrue()) + Expect(result1.OutputToStringArray()).To(ContainElement(HavePrefix("0.0.0.0:5000"))) // Check that the second port was honored result2 := podmanTest.Podman([]string{"port", "test", "5001"}) result2.WaitWithDefaultTimeout() Expect(result2).Should(Exit(0)) - Expect(result2.LineInOutputStartsWith("0.0.0.0:5001")).To(BeTrue()) + Expect(result2.OutputToStringArray()).To(ContainElement(HavePrefix("0.0.0.0:5001"))) }) }) diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index ff70a8cf4..223fcc5b2 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -153,8 +153,7 @@ var _ = Describe("Podman prune", func() { session := podmanTest.Podman([]string{"images", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - hasNone, _ := session.GrepString("<none>") - Expect(hasNone).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("<none>")) // Nothing will be pruned. session = podmanTest.Podman([]string{"image", "prune", "-f"}) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 881d9fcf0..0afd74bcb 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -671,51 +671,51 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(5)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test2")) + Expect(session.OutputToString()).To(ContainSubstring("test3")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "name=test1", "--filter", "name=test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test2")) // check container id matches with regex session = podmanTest.Podman([]string{"ps", "--all", "--filter", "id=" + cid1[:40], "--filter", "id=" + cid1 + "$"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) session = podmanTest.Podman([]string{"ps", "--filter", "status=created"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test3")) session = podmanTest.Podman([]string{"ps", "--filter", "status=created", "--filter", "status=exited"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(4)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) + Expect(session.OutputToString()).To(ContainSubstring("test3")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test2")) session = podmanTest.Podman([]string{"ps", "--filter", "label=foo=1", "--filter", "status=exited"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1", "--filter", "label=non=1"}) session.WaitWithDefaultTimeout() @@ -726,46 +726,46 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "exited=1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "exited=1", "--filter", "exited=0"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test2")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test2")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "volume=volume1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "volume=/:/test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test4")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "before=test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test1")) session = podmanTest.Podman([]string{"ps", "--all", "--filter", "since=test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(3)) - Expect(session.LineInOutputContains("test3")).To(BeTrue()) - Expect(session.LineInOutputContains("test4")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("test3")) + Expect(session.OutputToString()).To(ContainSubstring("test4")) }) It("podman ps filter pod", func() { pod1 := podmanTest.Podman([]string{"pod", "create", "--name", "pod1"}) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 03a347a6f..196d8879d 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -89,7 +89,7 @@ var _ = Describe("Podman rmi", func() { result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(result.LineInOutputContains(setup.OutputToString())).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring(setup.OutputToString())) }) It("podman rmi image with tags by ID cannot be done without force", func() { diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index 6dbb5886d..dc9c6820b 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -52,7 +52,7 @@ var _ = Describe("Podman run cpu", func() { } result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(result.LineInOutputContains("5000")).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring("5000")) }) It("podman run cpu-quota", func() { @@ -65,7 +65,7 @@ var _ = Describe("Podman run cpu", func() { } result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(result.LineInOutputContains("5000")).To(BeTrue()) + Expect(result.OutputToString()).To(ContainSubstring("5000")) }) It("podman run cpus", func() { diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go index 166160ad2..beb6390e0 100644 --- a/test/e2e/run_dns_test.go +++ b/test/e2e/run_dns_test.go @@ -37,7 +37,7 @@ var _ = Describe("Podman run dns", func() { session := podmanTest.Podman([]string{"run", "--dns-search=foobar.com", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("search foobar.com") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search foobar.com"))) }) It("podman run remove all search domain", func() { @@ -57,14 +57,15 @@ var _ = Describe("Podman run dns", func() { session := podmanTest.Podman([]string{"run", "--dns=1.2.3.4", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("server 1.2.3.4") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4"))) + }) It("podman run add dns option", func() { session := podmanTest.Podman([]string{"run", "--dns-opt=debug", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("options debug") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("options debug"))) }) It("podman run add bad host", func() { @@ -77,8 +78,8 @@ var _ = Describe("Podman run dns", func() { session := podmanTest.Podman([]string{"run", "--add-host=foobar:1.1.1.1", "--add-host=foobaz:2001:db8::68", ALPINE, "cat", "/etc/hosts"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputStartsWith("1.1.1.1 foobar") - session.LineInOutputStartsWith("2001:db8::68 foobaz") + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("1.1.1.1 foobar"))) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("2001:db8::68 foobaz"))) }) It("podman run add hostname", func() { @@ -97,7 +98,7 @@ var _ = Describe("Podman run dns", func() { session := podmanTest.Podman([]string{"run", "-t", "-i", "--hostname=foobar", ALPINE, "cat", "/etc/hosts"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains("foobar")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("foobar")) }) It("podman run mutually excludes --dns* and --network", func() { diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index 9560b1627..f500a3c7c 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -112,12 +112,12 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputStartsWith("Linux")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("Linux"))) session = podmanTest.Podman([]string{"run", "--entrypoint", "", "foobar.com/entrypoint:latest", "uname"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputStartsWith("Linux")).To(BeTrue()) + Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("Linux"))) }) It("podman run user entrypoint with command overrides image entrypoint and image cmd", func() { diff --git a/test/e2e/run_env_test.go b/test/e2e/run_env_test.go index 9324c1957..5a62db809 100644 --- a/test/e2e/run_env_test.go +++ b/test/e2e/run_env_test.go @@ -37,39 +37,33 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "HOME"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("/root") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/root")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "2", ALPINE, "printenv", "HOME"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("/sbin") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/sbin")) session = podmanTest.Podman([]string{"run", "--rm", "--env", "HOME=/foo", ALPINE, "printenv", "HOME"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("/foo") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/foo")) session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO=BAR,BAZ", ALPINE, "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("BAR,BAZ") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("BAR,BAZ")) session = podmanTest.Podman([]string{"run", "--rm", "--env", "PATH=/bin", ALPINE, "printenv", "PATH"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("/bin") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/bin")) os.Setenv("FOO", "BAR") session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("BAR")) os.Unsetenv("FOO") session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"}) @@ -86,8 +80,7 @@ var _ = Describe("Podman run", func() { session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "printenv"}) session.Wait(10) Expect(session).Should(Exit(0)) - match, _ = session.GrepString("HOSTNAME") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("HOSTNAME")) }) It("podman run --env-host environment test", func() { @@ -101,14 +94,12 @@ var _ = Describe("Podman run", func() { return } Expect(session).Should(Exit(0)) - match, _ := session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("BAR")) session = podmanTest.PodmanAsUser([]string{"run", "--rm", "--env", "FOO=BAR1", "--env-host", ALPINE, "/bin/printenv", "FOO"}, 0, 0, "", env) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("BAR1") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("BAR1")) os.Unsetenv("FOO") }) @@ -121,8 +112,7 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("1.2.3.4") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) session = podmanTest.Podman([]string{"run", "--http-proxy=false", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() @@ -132,15 +122,13 @@ var _ = Describe("Podman run", func() { session = podmanTest.Podman([]string{"run", "--env", "http_proxy=5.6.7.8", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("5.6.7.8") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("5.6.7.8")) os.Unsetenv("http_proxy") session = podmanTest.Podman([]string{"run", "--http-proxy=false", "--env", "http_proxy=5.6.7.8", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ = session.GrepString("5.6.7.8") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("5.6.7.8")) os.Unsetenv("http_proxy") }) }) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 596159fe9..e2004c8e0 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -559,38 +559,33 @@ EXPOSE 2004-2005/tcp`, ALPINE) session := podmanTest.Podman([]string{"run", "--rm", "--net", "host", ALPINE, "printenv", "HOSTNAME"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString(hostname) - Expect(match).Should(BeTrue()) + 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)) - match, _ := session.GrepString(hostname) - Expect(match).Should(BeTrue()) + 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)) - match, _ := session.GrepString(hostname) - Expect(match).Should(BeTrue()) + 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)) - match, _ := session.GrepString("foobar") - Expect(match).Should(BeTrue()) + 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)) - match, _ := session.GrepString("foobar") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("foobar")) }) It("podman run --net container: and --uts container:", func() { diff --git a/test/e2e/run_passwd_test.go b/test/e2e/run_passwd_test.go index 3e7e73fad..05cdc7d80 100644 --- a/test/e2e/run_passwd_test.go +++ b/test/e2e/run_passwd_test.go @@ -58,7 +58,7 @@ var _ = Describe("Podman run passwd", func() { session := podmanTest.Podman([]string{"run", "--read-only", "-u", "20001:1", BB, "mount"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains("passwd")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("passwd")) }) It("podman can run container without /etc/passwd", func() { @@ -104,14 +104,14 @@ USER 1000`, ALPINE) session := podmanTest.Podman([]string{"run", "--read-only", "-u", "20001:20001", BB, "mount"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains("/etc/group")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/etc/group")) }) It("podman run numeric user not specified in container modifies group", func() { session := podmanTest.Podman([]string{"run", "--read-only", "-u", "20001", BB, "mount"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains("/etc/group")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/etc/group")) }) It("podman run numeric group from image and no group file", func() { diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go index 3cb0663e0..cf63760cc 100644 --- a/test/e2e/run_selinux_test.go +++ b/test/e2e/run_selinux_test.go @@ -42,24 +42,21 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/proc/self/attr/current"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_t")) }) It("podman run selinux grep test", func() { session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=level:s0:c1,c2", ALPINE, "cat", "/proc/self/attr/current"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("s0:c1,c2") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("s0:c1,c2")) }) It("podman run selinux disable test", func() { session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=disable", ALPINE, "cat", "/proc/self/attr/current"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("spc_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("spc_t")) }) It("podman run selinux type check test", func() { @@ -75,88 +72,77 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=type:spc_t", ALPINE, "cat", "/proc/self/attr/current"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("spc_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("spc_t")) }) It("podman privileged selinux", func() { session := podmanTest.Podman([]string{"run", "--privileged", ALPINE, "cat", "/proc/self/attr/current"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("spc_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("spc_t")) }) It("podman test selinux label resolv.conf", func() { session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-Z", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux label hosts", func() { session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-Z", "/etc/hosts"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux label hostname", func() { session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-Z", "/etc/hostname"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux label /run/secrets", func() { session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-dZ", "/run/secrets"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux --privileged label resolv.conf", func() { session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-Z", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux --privileged label hosts", func() { session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-Z", "/etc/hosts"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux --privileged label hostname", func() { session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-Z", "/etc/hostname"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman test selinux --privileged label /run/secrets", func() { session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-dZ", "/run/secrets"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_file_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_file_t")) }) It("podman run selinux file type setup test", func() { session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=type:spc_t", "--security-opt", "label=filetype:container_var_lib_t", fedoraMinimal, "ls", "-Z", "/dev"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("container_var_lib_t") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("container_var_lib_t")) session = podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=type:spc_t", "--security-opt", "label=filetype:foobar", fedoraMinimal, "ls", "-Z", "/dev"}) session.WaitWithDefaultTimeout() @@ -179,10 +165,8 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "-it", "--privileged", "--security-opt", "label=type:spc_t", "--security-opt", "label=level:s0:c1,c2", ALPINE, "cat", "/proc/self/attr/current"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("spc_t") - Expect(match).To(BeTrue()) - match2, _ := session.GrepString("s0:c1,c2") - Expect(match2).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("spc_t")) + Expect(session.OutputToString()).To(ContainSubstring("s0:c1,c2")) }) It("podman pod container share SELinux labels", func() { @@ -349,7 +333,6 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "-v", "testvol:/test1/test:Z", fedoraMinimal, "ls", "-alZ", "/test1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString(":s0:") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(":s0:")) }) }) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 2be2154ff..ec64d2166 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -152,8 +152,7 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", ALPINE, "find", "/etc", "-name", "hosts"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString("/etc/hosts") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("/etc/hosts")) }) It("podman create pod with name in /etc/hosts", func() { @@ -162,10 +161,8 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "-ti", "--rm", "--name", name, "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - match, _ := session.GrepString(name) - Expect(match).Should(BeTrue()) - match, _ = session.GrepString(hostname) - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(name)) + Expect(session.OutputToString()).To(ContainSubstring(hostname)) }) It("podman run a container based on remote image", func() { @@ -421,16 +418,14 @@ var _ = Describe("Podman run", func() { session := podmanTest.Podman([]string{"run", "-it", "--security-opt", strings.Join([]string{"seccomp=", forbidGetCWDSeccompProfile()}, ""), ALPINE, "pwd"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) - match, _ := session.GrepString("Operation not permitted") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("Operation not permitted")) }) It("podman run seccomp test --privileged", func() { session := podmanTest.Podman([]string{"run", "-it", "--privileged", "--security-opt", strings.Join([]string{"seccomp=", forbidGetCWDSeccompProfile()}, ""), ALPINE, "pwd"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) - match, _ := session.GrepString("Operation not permitted") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("Operation not permitted")) }) It("podman run seccomp test --privileged no profile should be unconfined", func() { @@ -879,14 +874,14 @@ USER bin`, BB) 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.LineInOutputContains("777,65533(nogroup)")).To(BeTrue()) + 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.LineInOutputContains("uid=0(root) gid=0(root)")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("uid=0(root) gid=0(root)")) }) It("podman run with user (integer, not in /etc/passwd)", func() { @@ -900,14 +895,14 @@ USER bin`, BB) session := podmanTest.Podman([]string{"run", "--rm", "--user=8", ALPINE, "id"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContains("uid=8(mail) gid=12(mail)")).To(BeTrue()) + 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.LineInOutputContains("uid=8(mail) gid=12(mail)")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("uid=8(mail) gid=12(mail)")) }) It("podman run with user:group (username:integer)", func() { @@ -939,7 +934,7 @@ USER bin`, BB) ps := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"}) ps.WaitWithDefaultTimeout() Expect(ps).Should(Exit(0)) - Expect(ps.LineInOutputContains(session.OutputToString())).To(BeTrue()) + Expect(ps.OutputToString()).To(ContainSubstring(session.OutputToString())) }) It("podman run with attach stdout does not print stderr", func() { @@ -1217,8 +1212,7 @@ USER mail`, BB) check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString("foobar") - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring("foobar")) }) It("podman run --pod new with hostname", func() { diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 1fe95a1bf..9b981ef72 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -47,8 +47,7 @@ var _ = Describe("Podman UserNS support", func() { session := podmanTest.Podman([]string{"run", "--uidmap=0:100:5000", "--gidmap=0:200:5000", "alpine", "echo", "hello"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("hello") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("hello")) }) // It essentially repeats the test above but with the `-it` short option @@ -59,24 +58,21 @@ var _ = Describe("Podman UserNS support", func() { session := podmanTest.Podman([]string{"run", "--uidmap=0:1:5000", "--gidmap=0:200:5000", "-it", "alpine", "echo", "hello"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("hello") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("hello")) }) It("podman uidmapping and gidmapping with a volume", func() { session := podmanTest.Podman([]string{"run", "--uidmap=0:1:500", "--gidmap=0:200:5000", "-v", "my-foo-volume:/foo:Z", "alpine", "echo", "hello"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("hello") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("hello")) }) It("podman uidmapping and gidmapping --net=host", func() { session := podmanTest.Podman([]string{"run", "--net=host", "--uidmap=0:1:5000", "--gidmap=0:200:5000", "alpine", "echo", "hello"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("hello") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("hello")) }) It("podman --userns=keep-id", func() { @@ -84,8 +80,7 @@ var _ = Describe("Podman UserNS support", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) uid := fmt.Sprintf("%d", os.Geteuid()) - ok, _ := session.GrepString(uid) - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(uid)) }) It("podman --userns=keep-id check passwd", func() { @@ -94,8 +89,7 @@ var _ = Describe("Podman UserNS support", func() { Expect(session).Should(Exit(0)) u, err := user.Current() Expect(err).To(BeNil()) - ok, _ := session.GrepString(u.Name) - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(u.Name)) }) It("podman --userns=keep-id root owns /usr", func() { @@ -186,23 +180,22 @@ var _ = Describe("Podman UserNS support", func() { session := podmanTest.Podman([]string{"run", "--userns=auto:size=500", "alpine", "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("500") + Expect(session.OutputToString()).To(ContainSubstring("500")) session = podmanTest.Podman([]string{"run", "--userns=auto:size=3000", "alpine", "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ = session.GrepString("3000") + Expect(session.OutputToString()).To(ContainSubstring("3000")) session = podmanTest.Podman([]string{"run", "--userns=auto", "--user=2000:3000", "alpine", "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ = session.GrepString("3001") + Expect(session.OutputToString()).To(ContainSubstring("3001")) session = podmanTest.Podman([]string{"run", "--userns=auto", "--user=4000:1000", "alpine", "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ = session.GrepString("4001") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("4001")) }) It("podman --userns=auto:uidmapping=", func() { @@ -231,8 +224,7 @@ var _ = Describe("Podman UserNS support", func() { session = podmanTest.Podman([]string{"run", "--userns=auto:size=8192,uidmapping=0:0:1", "alpine", "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("8191") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("8191")) }) It("podman --userns=auto:gidmapping=", func() { @@ -261,8 +253,7 @@ var _ = Describe("Podman UserNS support", func() { session = podmanTest.Podman([]string{"run", "--userns=auto:size=8192,gidmapping=0:0:1", "alpine", "cat", "/proc/self/gid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("8191") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("8191")) }) It("podman --userns=container:CTR", func() { @@ -276,15 +267,13 @@ var _ = Describe("Podman UserNS support", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ := session.GrepString("4998") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("4998")) session = podmanTest.Podman([]string{"run", "--rm", "--userns=container:" + ctrName, "--net=container:" + ctrName, "alpine", "cat", "/proc/self/uid_map"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - ok, _ = session.GrepString("4998") - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("4998")) }) It("podman --user with volume", func() { diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index 5ce4d9acf..0de2dbd65 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -681,21 +681,18 @@ VOLUME /test/`, ALPINE) session := podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - found, _ := session.GrepString("888:888") - Expect(found).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("888:888")) session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "auto", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - found, _ = session.GrepString("888:888") - Expect(found).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("888:888")) vol = vol + ",O" session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "keep-id", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - found, _ = session.GrepString("888:888") - Expect(found).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("888:888")) }) It("podman run with --mount and U flag", func() { diff --git a/test/e2e/run_working_dir_test.go b/test/e2e/run_working_dir_test.go index ac78110bf..bcc85dd9b 100644 --- a/test/e2e/run_working_dir_test.go +++ b/test/e2e/run_working_dir_test.go @@ -60,7 +60,7 @@ WORKDIR /etc/foobar`, ALPINE) session = podmanTest.Podman([]string{"run", "test", "ls", "-ld", "."}) session.WaitWithDefaultTimeout() - Expect(session.LineInOutputContains("bin")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("bin")) session = podmanTest.Podman([]string{"run", "--workdir", "/home/foobar", "test", "pwd"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 0b3a88da3..9f3f750b7 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -253,8 +253,7 @@ func multiImageSave(podmanTest *PodmanTestIntegration, images []string) { Expect(session).Should(Exit(0)) // Grep for each image in the `podman load` output. for _, image := range images { - found, _ := session.GrepString(image) - Expect(found).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(image)) } // Make sure that each image has really been loaded. diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 10e991d9f..2ea88eb5e 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -92,14 +92,14 @@ registries = ['{{.Host}}:{{.Port}}']` search.WaitWithDefaultTimeout() Expect(search).Should(Exit(0)) Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1)) - Expect(search.LineInOutputContains("docker.io/library/alpine")).To(BeTrue()) + Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine")) }) It("podman search single registry flag", func() { search := podmanTest.Podman([]string{"search", "quay.io/skopeo/stable:latest"}) search.WaitWithDefaultTimeout() Expect(search).Should(Exit(0)) - Expect(search.LineInOutputContains("quay.io/skopeo/stable")).To(BeTrue()) + Expect(search.OutputToString()).To(ContainSubstring("quay.io/skopeo/stable")) }) It("podman search image with description", func() { @@ -127,7 +127,7 @@ registries = ['{{.Host}}:{{.Port}}']` search.WaitWithDefaultTimeout() Expect(search).Should(Exit(0)) Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1)) - Expect(search.LineInOutputContains("docker.io/library/alpine")).To(BeTrue()) + Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine")) }) It("podman search format json", func() { @@ -277,8 +277,7 @@ registries = ['{{.Host}}:{{.Port}}']` searchEmpty.WaitWithDefaultTimeout() Expect(searchEmpty).Should(Exit(0)) Expect(len(searchEmpty.OutputToStringArray())).To(BeNumerically(">=", 1)) - match, _ := search.GrepString("my-alpine") - Expect(match).Should(BeTrue()) + Expect(search.OutputToString()).To(ContainSubstring("my-alpine")) }) It("podman search attempts HTTP if registry is in registries.insecure and force secure is false", func() { @@ -317,8 +316,7 @@ registries = ['{{.Host}}:{{.Port}}']` search.WaitWithDefaultTimeout() Expect(search).Should(Exit(0)) - match, _ := search.GrepString("my-alpine") - Expect(match).Should(BeTrue()) + Expect(search.OutputToString()).To(ContainSubstring("my-alpine")) Expect(search.ErrorToString()).Should(BeEmpty()) // cleanup diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index 3be1486d8..d1f769724 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -42,8 +42,7 @@ var _ = Describe("Podman volume create", func() { check := podmanTest.Podman([]string{"volume", "ls", "-q"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString(volName) - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring(volName)) Expect(len(check.OutputToStringArray())).To(Equal(1)) }) @@ -55,8 +54,7 @@ var _ = Describe("Podman volume create", func() { check := podmanTest.Podman([]string{"volume", "ls", "-q"}) check.WaitWithDefaultTimeout() - match, _ := check.GrepString(volName) - Expect(match).To(BeTrue()) + Expect(check.OutputToString()).To(ContainSubstring(volName)) Expect(len(check.OutputToStringArray())).To(Equal(1)) }) |