Skip to content

Commit

Permalink
Merge pull request containers#12387 from edsantiago/remove_betrue
Browse files Browse the repository at this point in the history
e2e tests: clean up antihelpful BeTrue()s
  • Loading branch information
openshift-merge-robot authored Nov 23, 2021
2 parents 1bfbb28 + 49d63ad commit a55473b
Show file tree
Hide file tree
Showing 30 changed files with 165 additions and 239 deletions.
21 changes: 7 additions & 14 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/containers_conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
})

Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/image_scp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ 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() {
session := podmanTest.Podman([]string{"image", "list"})
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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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"))
})
})
8 changes: 4 additions & 4 deletions test/e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 6 additions & 12 deletions test/e2e/pod_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

Expand All @@ -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() {
Expand Down Expand Up @@ -646,17 +644,15 @@ 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"})
session.WaitWithDefaultTimeout()
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"})
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/pod_infra_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down
Loading

0 comments on commit a55473b

Please sign in to comment.