e2e: yet more cleanup of BeTrue/BeFalse

Thanks to Paul for teaching me about HaveKey()

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago
2021-11-30 13:14:56 -07:00
parent 295a6f7dd0
commit 9ce7ade8c8
21 changed files with 67 additions and 109 deletions

View File

@ -192,7 +192,7 @@ var _ = Describe("Podman checkpoint", func() {
ps.WaitWithDefaultTimeout() ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0)) Expect(ps).Should(Exit(0))
Expect(ps.OutputToString()).To(ContainSubstring(session1.OutputToString())) Expect(ps.OutputToString()).To(ContainSubstring(session1.OutputToString()))
Expect(ps.LineInOutputContains(session2.OutputToString())).To(BeFalse()) Expect(ps.OutputToString()).To(Not(ContainSubstring(session2.OutputToString())))
result = podmanTest.Podman([]string{"container", "restore", "second"}) result = podmanTest.Podman([]string{"container", "restore", "second"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
@ -228,8 +228,8 @@ var _ = Describe("Podman checkpoint", func() {
ps := podmanTest.Podman([]string{"ps", "-q", "--no-trunc"}) ps := podmanTest.Podman([]string{"ps", "-q", "--no-trunc"})
ps.WaitWithDefaultTimeout() ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0)) Expect(ps).Should(Exit(0))
Expect(ps.LineInOutputContains(session1.OutputToString())).To(BeFalse()) Expect(ps.OutputToString()).To(Not(ContainSubstring(session1.OutputToString())))
Expect(ps.LineInOutputContains(session2.OutputToString())).To(BeFalse()) Expect(ps.OutputToString()).To(Not(ContainSubstring(session2.OutputToString())))
result = podmanTest.Podman([]string{"container", "restore", "-a"}) result = podmanTest.Podman([]string{"container", "restore", "-a"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
@ -1297,8 +1297,8 @@ var _ = Describe("Podman checkpoint", func() {
}) })
ps.WaitWithDefaultTimeout() ps.WaitWithDefaultTimeout()
Expect(ps).Should(Exit(0)) Expect(ps).Should(Exit(0))
Expect(ps.LineInOutputContains(session1.OutputToString())).To(BeFalse()) Expect(ps.OutputToString()).To(Not(ContainSubstring(session1.OutputToString())))
Expect(ps.LineInOutputContains(session2.OutputToString())).To(BeFalse()) Expect(ps.OutputToString()).To(Not(ContainSubstring(session2.OutputToString())))
result = podmanTest.Podman([]string{ result = podmanTest.Podman([]string{
"container", "container",

View File

@ -204,8 +204,7 @@ var _ = Describe("Podman commit", func() {
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
image := inspect.InspectImageJSON() image := inspect.InspectImageJSON()
_, ok := image[0].Config.Volumes["/foo"] Expect(image[0].Config.Volumes).To(Not(HaveKey("/foo")))
Expect(ok).To(BeFalse())
}) })
It("podman commit with volume mounts and --include-volumes", func() { It("podman commit with volume mounts and --include-volumes", func() {
@ -224,8 +223,7 @@ var _ = Describe("Podman commit", func() {
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0)) Expect(inspect).Should(Exit(0))
image := inspect.InspectImageJSON() image := inspect.InspectImageJSON()
_, ok := image[0].Config.Volumes["/foo"] Expect(image[0].Config.Volumes).To(HaveKey("/foo"))
Expect(ok).To(BeTrue(), ".Config.Volumes[/foo]")
r := podmanTest.Podman([]string{"run", "newimage"}) r := podmanTest.Podman([]string{"run", "newimage"})
r.WaitWithDefaultTimeout() r.WaitWithDefaultTimeout()
@ -250,7 +248,7 @@ var _ = Describe("Podman commit", func() {
for _, v := range image[0].Config.Env { for _, v := range image[0].Config.Env {
envMap[v] = true envMap[v] = true
} }
Expect(envMap["TEST=1=1-01=9.01"]).To(BeTrue(), "envMap[TEST=1=1-01=9.01]") Expect(envMap).To(HaveKey("TEST=1=1-01=9.01"))
}) })
It("podman commit container and print id to external file", func() { It("podman commit container and print id to external file", func() {

View File

@ -245,7 +245,7 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"}) session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputStartsWith("search")).To(BeFalse()) Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("search"))))
}) })
It("podman run use containers.conf search domain", func() { It("podman run use containers.conf search domain", func() {

View File

@ -107,9 +107,7 @@ var _ = Describe("Podman create", func() {
check := podmanTest.Podman([]string{"inspect", "annotate_test"}) check := podmanTest.Podman([]string{"inspect", "annotate_test"})
check.WaitWithDefaultTimeout() check.WaitWithDefaultTimeout()
data := check.InspectContainerToJSON() data := check.InspectContainerToJSON()
value, ok := data[0].Config.Annotations["HELLO"] Expect(data[0].Config.Annotations).To(HaveKeyWithValue("HELLO", "WORLD"))
Expect(ok).To(BeTrue(), ".Config.Annotations[HELLO]")
Expect(value).To(Equal("WORLD"))
}) })
It("podman create --entrypoint command", func() { It("podman create --entrypoint command", func() {
@ -386,10 +384,8 @@ var _ = Describe("Podman create", func() {
data := inspect.InspectContainerToJSON() data := inspect.InspectContainerToJSON()
Expect(len(data)).To(Equal(1), "len(InspectContainerToJSON)") Expect(len(data)).To(Equal(1), "len(InspectContainerToJSON)")
Expect(len(data[0].Config.Labels)).To(Equal(2)) Expect(len(data[0].Config.Labels)).To(Equal(2))
_, ok1 := data[0].Config.Labels["TESTKEY1"] Expect(data[0].Config.Labels).To(HaveKey("TESTKEY1"))
Expect(ok1).To(BeTrue(), ".Config.Labels[TESTKEY1]") Expect(data[0].Config.Labels).To(HaveKey("TESTKEY2"))
_, ok2 := data[0].Config.Labels["TESTKEY2"]
Expect(ok2).To(BeTrue(), ".Config.Labels[TESTKEY2]")
}) })
It("podman create with set label", func() { It("podman create with set label", func() {
@ -404,12 +400,8 @@ var _ = Describe("Podman create", func() {
data := inspect.InspectContainerToJSON() data := inspect.InspectContainerToJSON()
Expect(len(data)).To(Equal(1)) Expect(len(data)).To(Equal(1))
Expect(len(data[0].Config.Labels)).To(Equal(2)) Expect(len(data[0].Config.Labels)).To(Equal(2))
val1, ok1 := data[0].Config.Labels["TESTKEY1"] Expect(data[0].Config.Labels).To(HaveKeyWithValue("TESTKEY1", "value1"))
Expect(ok1).To(BeTrue(), ".Config.Labels[TESTKEY1]") Expect(data[0].Config.Labels).To(HaveKeyWithValue("TESTKEY2", "bar"))
Expect(val1).To(Equal("value1"))
val2, ok2 := data[0].Config.Labels["TESTKEY2"]
Expect(ok2).To(BeTrue(), ".Config.Labels[TESTKEY2]")
Expect(val2).To(Equal("bar"))
}) })
It("podman create with --restart=on-failure:5 parses correctly", func() { It("podman create with --restart=on-failure:5 parses correctly", func() {

View File

@ -606,9 +606,7 @@ var _ = Describe("Podman generate kube", func() {
pod := new(v1.Pod) pod := new(v1.Pod)
err = yaml.Unmarshal(b, pod) err = yaml.Unmarshal(b, pod)
Expect(err).To(BeNil()) Expect(err).To(BeNil())
val, found := pod.Annotations[define.BindMountPrefix+vol1] Expect(pod.Annotations).To(HaveKeyWithValue(define.BindMountPrefix+vol1, HaveSuffix("z")))
Expect(found).To(BeTrue(), "pod.Annotations["+vol1+"]")
Expect(val).To(HaveSuffix("z"))
rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"}) rm := podmanTest.Podman([]string{"pod", "rm", "-t", "0", "-f", "test1"})
rm.WaitWithDefaultTimeout() rm.WaitWithDefaultTimeout()
@ -1071,9 +1069,7 @@ USER test1`
err := yaml.Unmarshal(kube.Out.Contents(), pod) err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil()) Expect(err).To(BeNil())
v, ok := pod.GetAnnotations()["io.containers.autoupdate/top"] Expect(pod.GetAnnotations()).To(HaveKeyWithValue("io.containers.autoupdate/top", "local"))
Expect(ok).To(Equal(true))
Expect(v).To(Equal("local"))
}) })
It("podman generate kube on pod with auto update labels in all containers", func() { It("podman generate kube on pod with auto update labels in all containers", func() {
@ -1100,13 +1096,8 @@ USER test1`
Expect(pod.Spec.Containers[1].WorkingDir).To(Equal("/root")) Expect(pod.Spec.Containers[1].WorkingDir).To(Equal("/root"))
for _, ctr := range []string{"top1", "top2"} { for _, ctr := range []string{"top1", "top2"} {
v, ok := pod.GetAnnotations()["io.containers.autoupdate/"+ctr] Expect(pod.GetAnnotations()).To(HaveKeyWithValue("io.containers.autoupdate/"+ctr, "registry"))
Expect(ok).To(Equal(true)) Expect(pod.GetAnnotations()).To(HaveKeyWithValue("io.containers.autoupdate.authfile/"+ctr, "/some/authfile.json"))
Expect(v).To(Equal("registry"))
v, ok = pod.GetAnnotations()["io.containers.autoupdate.authfile/"+ctr]
Expect(ok).To(Equal(true))
Expect(v).To(Equal("/some/authfile.json"))
} }
}) })
}) })

View File

@ -229,11 +229,10 @@ WORKDIR /test
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0)) Expect(result).Should(Exit(0))
found, _ := result.GrepString("<none>")
if noneTag { if noneTag {
Expect(found).To(BeTrue()) Expect(result.OutputToString()).To(ContainSubstring("<none>"))
} else { } else {
Expect(found).To(BeFalse()) Expect(result.OutputToString()).To(Not(ContainSubstring("<none>")))
} }
} }
// No "<none>" tag as tagged alpine instances should be present. // No "<none>" tag as tagged alpine instances should be present.

View File

@ -160,8 +160,7 @@ var _ = Describe("Podman load", func() {
Expect(result).Should(Exit(125)) Expect(result).Should(Exit(125))
errMsg := fmt.Sprintf("remote client supports archives only but %q is a directory", podmanTest.TempDir) errMsg := fmt.Sprintf("remote client supports archives only but %q is a directory", podmanTest.TempDir)
found, _ := result.ErrorGrepString(errMsg) Expect(result.ErrorToString()).To(ContainSubstring(errMsg))
Expect(found).Should(BeTrue())
}) })
It("podman load bogus file", func() { It("podman load bogus file", func() {

View File

@ -140,7 +140,7 @@ var _ = Describe("Podman network", func() {
session := podmanTest.Podman([]string{"network", "ls", "--filter", "label=abc"}) session := podmanTest.Podman([]string{"network", "ls", "--filter", "label=abc"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains(name)).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring(name)))
}) })
It("podman network ID test", func() { It("podman network ID test", func() {
@ -208,7 +208,7 @@ var _ = Describe("Podman network", func() {
results := podmanTest.Podman([]string{"network", "ls", "--quiet"}) results := podmanTest.Podman([]string{"network", "ls", "--quiet"})
results.WaitWithDefaultTimeout() results.WaitWithDefaultTimeout()
Expect(results).Should(Exit(0)) Expect(results).Should(Exit(0))
Expect(results.LineInOutputContains(name)).To(BeFalse()) Expect(results.OutputToString()).To(Not(ContainSubstring(name)))
}) })
} }

View File

@ -98,8 +98,7 @@ var _ = Describe("Podman prune", func() {
session := podmanTest.Podman([]string{"images", "-a"}) session := podmanTest.Podman([]string{"images", "-a"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
hasNone, _ := session.GrepString("<none>") Expect(session.OutputToString()).To(Not(ContainSubstring("<none>")))
Expect(hasNone).To(BeFalse())
numImages := len(session.OutputToStringArray()) numImages := len(session.OutputToStringArray())
// Since there's no dangling image, none should be removed. // Since there's no dangling image, none should be removed.
@ -125,8 +124,7 @@ var _ = Describe("Podman prune", func() {
session = podmanTest.Podman([]string{"images", "-a"}) session = podmanTest.Podman([]string{"images", "-a"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
hasNone, _ = session.GrepString("<none>") Expect(session.OutputToString()).To(ContainSubstring("<none>"))
Expect(hasNone).To(BeTrue()) // ! we have dangling ones
numImages = len(session.OutputToStringArray()) numImages = len(session.OutputToStringArray())
// Since there's at least one dangling image, prune should // Since there's at least one dangling image, prune should
@ -135,7 +133,7 @@ var _ = Describe("Podman prune", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
numPrunedImages := len(session.OutputToStringArray()) numPrunedImages := len(session.OutputToStringArray())
Expect(numPrunedImages >= 1).To(BeTrue()) Expect(numPrunedImages).To(BeNumerically(">=", 1), "numPrunedImages")
// Now make sure that exactly the number of pruned images has // Now make sure that exactly the number of pruned images has
// been removed. // been removed.
@ -189,11 +187,11 @@ var _ = Describe("Podman prune", func() {
after := podmanTest.Podman([]string{"images", "-a"}) after := podmanTest.Podman([]string{"images", "-a"})
after.WaitWithDefaultTimeout() after.WaitWithDefaultTimeout()
Expect(none).Should(Exit(0)) Expect(after).Should(Exit(0))
hasNoneAfter, result := none.GrepString("<none>") hasNoneAfter, result := after.GrepString("<none>")
Expect(hasNoneAfter).To(BeTrue()) Expect(hasNoneAfter).To(BeTrue())
Expect(len(after.OutputToStringArray()) > 1).To(BeTrue()) Expect(len(after.OutputToStringArray())).To(BeNumerically(">", 1))
Expect(len(result) > 0).To(BeTrue()) Expect(len(result)).To(BeNumerically(">", 0))
}) })
It("podman image prune unused images", func() { It("podman image prune unused images", func() {

View File

@ -154,8 +154,8 @@ var _ = Describe("Podman restart", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
timeSince := time.Since(startTime) timeSince := time.Since(startTime)
Expect(timeSince < 10*time.Second).To(BeTrue()) Expect(timeSince).To(BeNumerically("<", 10*time.Second))
Expect(timeSince > 2*time.Second).To(BeTrue()) Expect(timeSince).To(BeNumerically(">", 2*time.Second))
}) })
It("Podman restart --all", func() { It("Podman restart --all", func() {

View File

@ -276,8 +276,7 @@ RUN find $LOCAL
session := podmanTest.Podman([]string{"image", "rm"}) session := podmanTest.Podman([]string{"image", "rm"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125)) Expect(session).Should(Exit(125))
match, _ := session.ErrorGrepString("image name or ID must be specified") Expect(session.ErrorToString()).To(ContainSubstring("image name or ID must be specified"))
Expect(match).To(BeTrue())
}) })
It("podman image rm - concurrent with shared layers", func() { It("podman image rm - concurrent with shared layers", func() {

View File

@ -44,7 +44,7 @@ var _ = Describe("Podman run dns", func() {
session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"}) session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputStartsWith("search")).To(BeFalse()) Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("search"))))
}) })
It("podman run add bad dns server", func() { It("podman run add bad dns server", func() {

View File

@ -129,6 +129,6 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest", "-r"}) session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest", "-r"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputStartsWith("Linux")).To(BeFalse()) Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("Linux"))))
}) })
}) })

View File

@ -551,8 +551,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "HOSTNAME"}) session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "HOSTNAME"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
match, _ := session.GrepString(hostname) Expect(session.OutputToString()).To(Not(ContainSubstring(hostname)))
Expect(match).Should(BeFalse())
}) })
It("podman run --net host hostname test", func() { It("podman run --net host hostname test", func() {
@ -866,7 +865,6 @@ EXPOSE 2004-2005/tcp`, ALPINE)
inspectOut := podmanTest.InspectContainer(ctrName) inspectOut := podmanTest.InspectContainer(ctrName)
Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Networks)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Networks)).To(Equal(1))
_, ok := inspectOut[0].NetworkSettings.Networks["podman"] Expect(inspectOut[0].NetworkSettings.Networks).To(HaveKey("podman"))
Expect(ok).To(BeTrue())
}) })
}) })

View File

@ -38,20 +38,20 @@ var _ = Describe("Podman run passwd", func() {
session := podmanTest.Podman([]string{"run", "--read-only", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--read-only", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("passwd")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("passwd")))
}) })
It("podman run user specified in container", func() { It("podman run user specified in container", func() {
session := podmanTest.Podman([]string{"run", "--read-only", "-u", "bin", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--read-only", "-u", "bin", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("passwd")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("passwd")))
}) })
It("podman run UID specified in container", func() { It("podman run UID specified in container", func() {
session := podmanTest.Podman([]string{"run", "--read-only", "-u", "2:1", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--read-only", "-u", "2:1", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("passwd")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("passwd")))
}) })
It("podman run UID not specified in container", func() { It("podman run UID not specified in container", func() {
@ -77,14 +77,14 @@ USER 1000`, ALPINE)
session := podmanTest.Podman([]string{"run", "--read-only", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--read-only", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("/etc/group")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("/etc/group")))
}) })
It("podman run group specified in container", func() { It("podman run group specified in container", func() {
session := podmanTest.Podman([]string{"run", "--read-only", "-u", "root:bin", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--read-only", "-u", "root:bin", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("/etc/group")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("/etc/group")))
}) })
It("podman run non-numeric group not specified in container", func() { It("podman run non-numeric group not specified in container", func() {
@ -97,7 +97,7 @@ USER 1000`, ALPINE)
session := podmanTest.Podman([]string{"run", "--read-only", "-u", "root:11", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--read-only", "-u", "root:11", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("/etc/group")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("/etc/group")))
}) })
It("podman run numeric group not specified in container", func() { It("podman run numeric group not specified in container", func() {

View File

@ -63,9 +63,7 @@ var _ = Describe("Podman privileged container tests", func() {
session := podmanTest.Podman([]string{"run", "--privileged", BB, "mount"}) session := podmanTest.Podman([]string{"run", "--privileged", BB, "mount"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
ok, lines := session.GrepString("sysfs") Expect(session.OutputToString()).To(ContainSubstring("sysfs (rw,"))
Expect(ok).To(BeTrue())
Expect(lines[0]).To(ContainSubstring("sysfs (rw,"))
}) })
It("podman privileged CapEff", func() { It("podman privileged CapEff", func() {

View File

@ -116,8 +116,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
} }
session, pid := podmanTest.PodmanPID([]string{"run", "--name", "test2", "--sig-proxy=false", fedoraMinimal, "bash", "-c", sigCatch2}) session, pid := podmanTest.PodmanPID([]string{"run", "--name", "test2", "--sig-proxy=false", fedoraMinimal, "bash", "-c", sigCatch2})
ok := WaitForContainer(podmanTest) Expect(WaitForContainer(podmanTest)).To(BeTrue(), "WaitForContainer()")
Expect(ok).To(BeTrue())
// Kill with given signal // Kill with given signal
// Should be no output, SIGPOLL is usually ignored // Should be no output, SIGPOLL is usually ignored
@ -132,8 +131,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError()) Expect(session).To(ExitWithError())
ok, _ = session.GrepString("Received") Expect(session.OutputToString()).To(Not(ContainSubstring("Received")))
Expect(ok).To(BeFalse())
}) })
}) })

View File

@ -871,7 +871,7 @@ USER bin`, BB)
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"}) session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "id"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.LineInOutputContains("27(video),777,65533(nogroup)")).To(BeFalse()) Expect(session.OutputToString()).To(Not(ContainSubstring("27(video),777,65533(nogroup)")))
}) })
It("podman run with group-add", func() { It("podman run with group-add", func() {
@ -1151,8 +1151,7 @@ USER mail`, BB)
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"}) session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
match, _ := session.GrepString("shared") Expect(session.OutputToString()).To(Not(ContainSubstring("shared")))
Expect(match).Should(BeFalse())
}) })
It("podman run findmnt shared", func() { It("podman run findmnt shared", func() {

View File

@ -103,10 +103,8 @@ var _ = Describe("Podman run with volumes", func() {
session = podmanTest.Podman([]string{"run", "--rm", "--mount", mount + ",consistency=delegated,shared", ALPINE, "grep", dest, "/proc/self/mountinfo"}) session = podmanTest.Podman([]string{"run", "--rm", "--mount", mount + ",consistency=delegated,shared", ALPINE, "grep", dest, "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
found, matches := session.GrepString(dest) Expect(session.OutputToString()).To(ContainSubstring("rw"))
Expect(found).Should(BeTrue()) Expect(session.OutputToString()).To(ContainSubstring("shared"))
Expect(matches[0]).To(ContainSubstring("rw"))
Expect(matches[0]).To(ContainSubstring("shared"))
session = podmanTest.Podman([]string{"run", "--rm", "--mount", "type=tmpfs,target=" + dest, ALPINE, "grep", dest, "/proc/self/mountinfo"}) session = podmanTest.Podman([]string{"run", "--rm", "--mount", "type=tmpfs,target=" + dest, ALPINE, "grep", dest, "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
@ -195,20 +193,18 @@ var _ = Describe("Podman run with volumes", func() {
session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":" + dest + ":suid,dev,exec", ALPINE, "grep", dest, "/proc/self/mountinfo"}) session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":" + dest + ":suid,dev,exec", ALPINE, "grep", dest, "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
found, matches := session.GrepString(dest) output := session.OutputToString()
Expect(found).Should(BeTrue()) Expect(output).To(Not(ContainSubstring("noexec")))
Expect(matches[0]).To(Not(ContainSubstring("noexec"))) Expect(output).To(Not(ContainSubstring("nodev")))
Expect(matches[0]).To(Not(ContainSubstring("nodev"))) Expect(output).To(Not(ContainSubstring("nosuid")))
Expect(matches[0]).To(Not(ContainSubstring("nosuid")))
session = podmanTest.Podman([]string{"run", "--rm", "--tmpfs", dest + ":suid,dev,exec", ALPINE, "grep", dest, "/proc/self/mountinfo"}) session = podmanTest.Podman([]string{"run", "--rm", "--tmpfs", dest + ":suid,dev,exec", ALPINE, "grep", dest, "/proc/self/mountinfo"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
found, matches = session.GrepString(dest) output = session.OutputToString()
Expect(found).Should(BeTrue()) Expect(output).To(Not(ContainSubstring("noexec")))
Expect(matches[0]).To(Not(ContainSubstring("noexec"))) Expect(output).To(Not(ContainSubstring("nodev")))
Expect(matches[0]).To(Not(ContainSubstring("nodev"))) Expect(output).To(Not(ContainSubstring("nosuid")))
Expect(matches[0]).To(Not(ContainSubstring("nosuid")))
}) })
// Container should start when workdir is overlay volume // Container should start when workdir is overlay volume

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"regexp"
"strconv" "strconv"
"text/template" "text/template"
@ -107,10 +106,8 @@ registries = ['{{.Host}}:{{.Port}}']`
search.WaitWithDefaultTimeout() search.WaitWithDefaultTimeout()
Expect(search).Should(Exit(0)) Expect(search).Should(Exit(0))
output := string(search.Out.Contents()) output := string(search.Out.Contents())
match, _ := regexp.MatchString(`(?m)NAME\s+DESCRIPTION$`, output) Expect(output).To(MatchRegexp(`(?m)NAME\s+DESCRIPTION$`))
Expect(match).To(BeTrue()) Expect(output).To(MatchRegexp(`(?m)quay.io/libpod/whalesay\s+Static image used for automated testing.+$`))
match, _ = regexp.MatchString(`(?m)quay.io/libpod/whalesay\s+Static image used for automated testing.+$`, output)
Expect(match).To(BeTrue())
}) })
It("podman search image with --compatible", func() { It("podman search image with --compatible", func() {
@ -118,8 +115,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search.WaitWithDefaultTimeout() search.WaitWithDefaultTimeout()
Expect(search).Should(Exit(0)) Expect(search).Should(Exit(0))
output := string(search.Out.Contents()) output := string(search.Out.Contents())
match, _ := regexp.MatchString(`(?m)NAME\s+DESCRIPTION\s+STARS\s+OFFICIAL\s+AUTOMATED$`, output) Expect(output).To(MatchRegexp(`(?m)NAME\s+DESCRIPTION\s+STARS\s+OFFICIAL\s+AUTOMATED$`))
Expect(match).To(BeTrue())
}) })
It("podman search format flag", func() { It("podman search format flag", func() {
@ -354,8 +350,7 @@ registries = ['{{.Host}}:{{.Port}}']`
Expect(search).Should(Exit(125)) Expect(search).Should(Exit(125))
Expect(search.OutputToString()).Should(BeEmpty()) Expect(search.OutputToString()).Should(BeEmpty())
match, _ := search.ErrorGrepString("error") Expect(search.ErrorToString()).To(ContainSubstring("error"))
Expect(match).Should(BeTrue())
// cleanup // cleanup
resetRegistriesConfigEnv() resetRegistriesConfigEnv()
@ -397,8 +392,7 @@ registries = ['{{.Host}}:{{.Port}}']`
Expect(search).Should(Exit(125)) Expect(search).Should(Exit(125))
Expect(search.OutputToString()).Should(BeEmpty()) Expect(search.OutputToString()).Should(BeEmpty())
match, _ := search.ErrorGrepString("error") Expect(search.ErrorToString()).To(ContainSubstring("error"))
Expect(match).Should(BeTrue())
// cleanup // cleanup
resetRegistriesConfigEnv() resetRegistriesConfigEnv()
@ -451,8 +445,7 @@ registries = ['{{.Host}}:{{.Port}}']`
Expect(search).Should(Exit(125)) Expect(search).Should(Exit(125))
Expect(search.OutputToString()).Should(BeEmpty()) Expect(search.OutputToString()).Should(BeEmpty())
match, _ := search.ErrorGrepString("error") Expect(search.ErrorToString()).To(ContainSubstring("error"))
Expect(match).Should(BeTrue())
// cleanup // cleanup
resetRegistriesConfigEnv() resetRegistriesConfigEnv()
@ -474,7 +467,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search = podmanTest.Podman([]string{"search", "registry.redhat.io/*openshift*"}) search = podmanTest.Podman([]string{"search", "registry.redhat.io/*openshift*"})
search.WaitWithDefaultTimeout() search.WaitWithDefaultTimeout()
Expect(search).Should(Exit(0)) Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray()) > 1).To(BeTrue()) Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
}) })
It("podman search repository tags", func() { It("podman search repository tags", func() {
@ -494,7 +487,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search = podmanTest.Podman([]string{"search", "--list-tags", "docker.io/library/"}) search = podmanTest.Podman([]string{"search", "--list-tags", "docker.io/library/"})
search.WaitWithDefaultTimeout() search.WaitWithDefaultTimeout()
Expect(len(search.OutputToStringArray()) == 0).To(BeTrue()) Expect(search.OutputToStringArray()).To(BeEmpty())
}) })
It("podman search with limit over 100", func() { It("podman search with limit over 100", func() {

View File

@ -127,6 +127,6 @@ var _ = Describe("Podman volume rm", func() {
session = podmanTest.Podman([]string{"volume", "ls"}) session = podmanTest.Podman([]string{"volume", "ls"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(len(session.OutputToStringArray()) >= 2).To(BeTrue()) Expect(len(session.OutputToStringArray())).To(BeNumerically(">=", 2))
}) })
}) })