diff options
-rw-r--r-- | test/e2e/commit_test.go | 6 | ||||
-rw-r--r-- | test/e2e/events_test.go | 19 | ||||
-rw-r--r-- | test/e2e/generate_kube_test.go | 16 | ||||
-rw-r--r-- | test/e2e/inspect_test.go | 5 | ||||
-rw-r--r-- | test/e2e/pod_create_test.go | 6 | ||||
-rw-r--r-- | test/e2e/ps_test.go | 10 | ||||
-rw-r--r-- | test/e2e/run_volume_test.go | 70 | ||||
-rw-r--r-- | test/e2e/save_test.go | 2 | ||||
-rw-r--r-- | test/e2e/tag_test.go | 12 |
9 files changed, 65 insertions, 81 deletions
diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index d40faf54b..20e1360de 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -47,7 +47,7 @@ var _ = Describe("Podman commit", func() { check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() - Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue()) + Expect(data[0].RepoTags).To(ContainElement("foobar.com/test1-image:latest")) }) It("podman commit single letter container", func() { @@ -62,7 +62,7 @@ var _ = Describe("Podman commit", func() { check := podmanTest.Podman([]string{"inspect", "localhost/a:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() - Expect(StringInSlice("localhost/a:latest", data[0].RepoTags)).To(BeTrue()) + Expect(data[0].RepoTags).To(ContainElement("localhost/a:latest")) }) It("podman container commit container", func() { @@ -77,7 +77,7 @@ var _ = Describe("Podman commit", func() { check := podmanTest.Podman([]string{"image", "inspect", "foobar.com/test1-image:latest"}) check.WaitWithDefaultTimeout() data := check.InspectImageJSON() - Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue()) + Expect(data[0].RepoTags).To(ContainElement("foobar.com/test1-image:latest")) }) It("podman commit container with message", func() { diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index ee0b8761a..2b9b0f575 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "os" - "strings" "sync" "time" @@ -62,12 +61,10 @@ var _ = Describe("Podman events", func() { result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(len(result.OutputToStringArray()) >= 1) + Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1), "Number of events") }) It("podman events with an event filter and container=cid", func() { - Skip("Does not work on v2") - SkipIfNotFedora() _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) _, ec2, cid2 := podmanTest.RunLsContainer("") @@ -76,8 +73,10 @@ var _ = Describe("Podman events", func() { result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start", "--filter", fmt.Sprintf("container=%s", cid)}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(len(result.OutputToStringArray())).To(Equal(1)) - Expect(!strings.Contains(result.OutputToString(), cid2)) + events := result.OutputToStringArray() + Expect(len(events)).To(Equal(1), "number of events") + Expect(events[0]).To(ContainSubstring(cid), "event log includes CID") + Expect(events[0]).To(Not(ContainSubstring(cid2)), "event log does not include second CID") }) It("podman events with a type and filter container=id", func() { @@ -101,8 +100,12 @@ var _ = Describe("Podman events", func() { result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", "pod=foobarpod"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - fmt.Println(result.OutputToStringArray()) - Expect(len(result.OutputToStringArray()) >= 2) + events := result.OutputToStringArray() + fmt.Println(events) + Expect(len(events)).To(BeNumerically(">=", 2), "Number of events") + Expect(events).To(ContainElement(ContainSubstring(" pod create "))) + Expect(events).To(ContainElement(ContainSubstring(" pod stop "))) + Expect(events).To(ContainElement(ContainSubstring("name=foobarpod"))) }) It("podman events --since", func() { diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index d95555068..a148025e5 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -775,8 +775,8 @@ var _ = Describe("Podman generate kube", func() { err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(StringInSlice("8.8.8.8", pod.Spec.DNSConfig.Nameservers)).To(BeTrue()) - Expect(StringInSlice("foobar.com", pod.Spec.DNSConfig.Searches)).To(BeTrue()) + Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) + Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) Expect(len(pod.Spec.DNSConfig.Options)).To(BeNumerically(">", 0)) Expect(pod.Spec.DNSConfig.Options[0].Name).To(Equal("color")) Expect(*pod.Spec.DNSConfig.Options[0].Value).To(Equal("blue")) @@ -799,10 +799,10 @@ var _ = Describe("Podman generate kube", func() { err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(StringInSlice("8.8.8.8", pod.Spec.DNSConfig.Nameservers)).To(BeTrue()) - Expect(StringInSlice("8.7.7.7", pod.Spec.DNSConfig.Nameservers)).To(BeTrue()) - Expect(StringInSlice("foobar.com", pod.Spec.DNSConfig.Searches)).To(BeTrue()) - Expect(StringInSlice("homer.com", pod.Spec.DNSConfig.Searches)).To(BeTrue()) + Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) + Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.7.7.7")) + Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) + Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("homer.com")) }) It("podman generate kube on a pod with dns options", func() { @@ -818,8 +818,8 @@ var _ = Describe("Podman generate kube", func() { err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) - Expect(StringInSlice("8.8.8.8", pod.Spec.DNSConfig.Nameservers)).To(BeTrue()) - Expect(StringInSlice("foobar.com", pod.Spec.DNSConfig.Searches)).To(BeTrue()) + Expect(pod.Spec.DNSConfig.Nameservers).To(ContainElement("8.8.8.8")) + Expect(pod.Spec.DNSConfig.Searches).To(ContainElement("foobar.com")) Expect(len(pod.Spec.DNSConfig.Options)).To(BeNumerically(">", 0)) Expect(pod.Spec.DNSConfig.Options[0].Name).To(Equal("color")) Expect(*pod.Spec.DNSConfig.Options[0].Value).To(Equal("blue")) diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index 63a54a5ca..52726015c 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -2,7 +2,6 @@ package integration import ( "os" - "strings" . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" @@ -61,7 +60,7 @@ var _ = Describe("Podman inspect", func() { Expect(inspect).Should(Exit(0)) // output should not be empty // test validates fix for https://github.com/containers/podman/issues/8785 - Expect(strings.Contains(inspect.OutputToString(), "TEST")) + Expect(inspect.OutputToString()).To(ContainSubstring("TEST="), ".Config.Env") session = podmanTest.Podman([]string{"rmi", "envwithtab"}) session.WaitWithDefaultTimeout() @@ -76,7 +75,7 @@ var _ = Describe("Podman inspect", func() { result := podmanTest.Podman([]string{"images", "-q", "--no-trunc", ALPINE}) result.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(strings.Contains(result.OutputToString(), session.OutputToString())) + Expect(result.OutputToStringArray()).To(ContainElement("sha256:"+session.OutputToString()), "'podman images -q --no-truncate' includes 'podman inspect --format .ID'") }) It("podman inspect specified type", func() { diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 820b13a17..a3dde3650 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -756,7 +756,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("500") + Expect(session.OutputToString()).To(ContainSubstring("500")) podName = "testPod-1" podCreate = podmanTest.Podman([]string{"pod", "create", "--userns=auto:size=3000", "--name", podName}) @@ -765,9 +765,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("3000") - - Expect(ok).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("3000")) }) It("podman pod create --userns=auto:uidmapping=", func() { diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 0afd74bcb..666b70b09 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -792,29 +792,29 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(StringInSlice(pod1.OutputToString(), session.OutputToStringArray())) + Expect(session.OutputToStringArray()).To(ContainElement(con1.OutputToString())) // filter by full pod id session = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--filter", "pod=" + pod1.OutputToString()}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(StringInSlice(pod1.OutputToString(), session.OutputToStringArray())) + Expect(session.OutputToStringArray()).To(ContainElement(con1.OutputToString())) // filter by partial pod id session = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--filter", "pod=" + pod1.OutputToString()[0:12]}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - Expect(StringInSlice(pod1.OutputToString(), session.OutputToStringArray())) + Expect(session.OutputToStringArray()).To(ContainElement(con1.OutputToString())) // filter by multiple pods is inclusive session = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--filter", "pod=pod1", "--filter", "pod=pod2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(4)) - Expect(StringInSlice(pod1.OutputToString(), session.OutputToStringArray())) - Expect(StringInSlice(pod2.OutputToString(), session.OutputToStringArray())) + Expect(session.OutputToStringArray()).To(ContainElement(con1.OutputToString())) + Expect(session.OutputToStringArray()).To(ContainElement(con2.OutputToString())) }) diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index 0de2dbd65..967cf4a7c 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -43,50 +43,38 @@ var _ = Describe("Podman run with volumes", func() { processTestResult(f) }) + // Returns the /proc/self/mountinfo line for a given mount point + getMountInfo := func(volume string) []string { + containerDir := strings.SplitN(volume, ":", 3)[1] + session := podmanTest.Podman([]string{"run", "--rm", "-v", volume, ALPINE, "awk", fmt.Sprintf(`$5 == "%s" { print }`, containerDir), "/proc/self/mountinfo"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + Expect(session.OutputToString()).To(ContainSubstring(containerDir), "mount point not found in /proc/self/mountinfo") + return strings.Fields(session.OutputToString()) + } + It("podman run with volume flag", func() { mountPath := filepath.Join(podmanTest.TempDir, "secrets") os.Mkdir(mountPath, 0755) vol := mountPath + ":" + dest - session := podmanTest.Podman([]string{"run", "--rm", "-v", vol, ALPINE, "grep", dest, "/proc/self/mountinfo"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - found, matches := session.GrepString(dest) - Expect(found).Should(BeTrue()) - Expect(matches[0]).To(ContainSubstring("rw")) + // [5] is flags + Expect(getMountInfo(vol)[5]).To(ContainSubstring("rw")) + Expect(getMountInfo(vol + ":ro")[5]).To(ContainSubstring("ro")) - session = podmanTest.Podman([]string{"run", "--rm", "-v", vol + ":ro", ALPINE, "grep", dest, "/proc/self/mountinfo"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - found, matches = session.GrepString(dest) - Expect(found).Should(BeTrue()) - Expect(matches[0]).To(ContainSubstring("ro")) - - session = podmanTest.Podman([]string{"run", "--rm", "-v", vol + ":shared", ALPINE, "grep", dest, "/proc/self/mountinfo"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - found, matches = session.GrepString(dest) - Expect(found).Should(BeTrue()) - Expect(matches[0]).To(ContainSubstring("rw")) - Expect(matches[0]).To(ContainSubstring("shared")) + mountinfo := getMountInfo(vol + ":shared") + Expect(mountinfo[5]).To(ContainSubstring("rw")) + Expect(mountinfo[6]).To(ContainSubstring("shared")) // Cached is ignored - session = podmanTest.Podman([]string{"run", "--rm", "-v", vol + ":cached", ALPINE, "grep", dest, "/proc/self/mountinfo"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - found, matches = session.GrepString(dest) - Expect(found).Should(BeTrue()) - Expect(matches[0]).To(ContainSubstring("rw")) - Expect(matches[0]).To(Not(ContainSubstring("cached"))) + mountinfo = getMountInfo(vol + ":cached") + Expect(mountinfo[5]).To(ContainSubstring("rw")) + Expect(mountinfo).To(Not(ContainElement(ContainSubstring("cached")))) // Delegated is ignored - session = podmanTest.Podman([]string{"run", "--rm", "-v", vol + ":delegated", ALPINE, "grep", dest, "/proc/self/mountinfo"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - found, matches = session.GrepString(dest) - Expect(found).Should(BeTrue()) - Expect(matches[0]).To(ContainSubstring("rw")) - Expect(matches[0]).To(Not(ContainSubstring("delegated"))) + mountinfo = getMountInfo(vol + ":delegated") + Expect(mountinfo[5]).To(ContainSubstring("rw")) + Expect(mountinfo).To(Not(ContainElement(ContainSubstring("delegated")))) }) It("podman run with --mount flag", func() { @@ -554,7 +542,7 @@ VOLUME /test/`, ALPINE) Skip("Overlay mounts not supported when running in a container") } if rootless.IsRootless() { - if _, err := exec.LookPath("fuse_overlay"); err != nil { + if _, err := exec.LookPath("fuse-overlayfs"); err != nil { Skip("Fuse-Overlayfs required for rootless overlay mount test") } } @@ -565,20 +553,16 @@ VOLUME /test/`, ALPINE) f.Close() // Make sure host directory gets mounted in to container as overlay - session := podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - found, matches := session.GrepString("/run/test") - Expect(found).Should(BeTrue()) - Expect(matches[0]).To(ContainSubstring("overlay")) + volumeFlag := fmt.Sprintf("%s:/run/test:O", mountPath) + Expect(getMountInfo(volumeFlag)[7]).To(Equal("overlay")) // Make sure host files show up in the container - session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "ls", "/run/test/test1"}) + session := podmanTest.Podman([]string{"run", "--rm", "-v", volumeFlag, ALPINE, "ls", "/run/test/test1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) // Make sure modifications in container do not show up on host - session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "touch", "/run/test/container"}) + session = podmanTest.Podman([]string{"run", "--rm", "-v", volumeFlag, ALPINE, "touch", "/run/test/container"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) _, err = os.Stat(filepath.Join(mountPath, "container")) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index a8fb6c7b3..d17566e8f 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -230,7 +230,7 @@ default-docker: Expect(session).Should(Exit(0)) ids := session.OutputToStringArray() - Expect(len(RESTORE_IMAGES), len(ids)) + Expect(len(ids)).To(BeNumerically(">", 1), "We need to have *some* images to save") multiImageSave(podmanTest, ids) }) }) diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go index b835d3776..743f58ea2 100644 --- a/test/e2e/tag_test.go +++ b/test/e2e/tag_test.go @@ -42,8 +42,8 @@ var _ = Describe("Podman tag", func() { results.WaitWithDefaultTimeout() Expect(results).Should(Exit(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) - Expect(StringInSlice("localhost/foobar:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(inspectData[0].RepoTags).To(ContainElement("quay.io/libpod/alpine:latest")) + Expect(inspectData[0].RepoTags).To(ContainElement("localhost/foobar:latest")) }) It("podman tag shortname", func() { @@ -55,8 +55,8 @@ var _ = Describe("Podman tag", func() { results.WaitWithDefaultTimeout() Expect(results).Should(Exit(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) - Expect(StringInSlice("localhost/foobar:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(inspectData[0].RepoTags).To(ContainElement("quay.io/libpod/alpine:latest")) + Expect(inspectData[0].RepoTags).To(ContainElement("localhost/foobar:latest")) }) It("podman tag shortname:tag", func() { @@ -68,8 +68,8 @@ var _ = Describe("Podman tag", func() { results.WaitWithDefaultTimeout() Expect(results).Should(Exit(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) - Expect(StringInSlice("localhost/foobar:new", inspectData[0].RepoTags)).To(BeTrue()) + Expect(inspectData[0].RepoTags).To(ContainElement("quay.io/libpod/alpine:latest")) + Expect(inspectData[0].RepoTags).To(ContainElement("localhost/foobar:new")) }) It("podman tag shortname image no tag", func() { |