diff options
Diffstat (limited to 'test')
44 files changed, 416 insertions, 269 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 6b9a96e9f..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"}) @@ -1377,4 +1377,177 @@ var _ = Describe("Podman checkpoint", func() { Expect(result).Should(Exit(0)) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) }) + + It("podman checkpoint container with export and verify runtime", func() { + SkipIfRemote("podman-remote does not support --runtime flag") + localRunString := getRunString([]string{ + "--rm", + ALPINE, + "top", + }) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + + session = podmanTest.Podman([]string{ + "inspect", + "--format", + "{{.OCIRuntime}}", + cid, + }) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + runtime := session.OutputToString() + + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + result := podmanTest.Podman([]string{ + "container", + "checkpoint", + cid, "-e", + fileName, + }) + result.WaitWithDefaultTimeout() + + // As the container has been started with '--rm' it will be completely + // cleaned up after checkpointing. + Expect(result).Should(Exit(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + result = podmanTest.Podman([]string{ + "container", + "restore", + "-i", + fileName, + }) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + // The restored container should have the same runtime as the original container + result = podmanTest.Podman([]string{ + "inspect", + "--format", + "{{.OCIRuntime}}", + cid, + }) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + Expect(session.OutputToString()).To(Equal(runtime)) + + // Remove exported checkpoint + os.Remove(fileName) + }) + + It("podman checkpoint container with export and try to change the runtime", func() { + SkipIfRemote("podman-remote does not support --runtime flag") + // This test will only run if runc and crun both exist + if !strings.Contains(podmanTest.OCIRuntime, "crun") { + Skip("Test requires crun and runc") + } + cmd := exec.Command("runc") + if err := cmd.Start(); err != nil { + Skip("Test requires crun and runc") + } + if err := cmd.Wait(); err != nil { + Skip("Test requires crun and runc") + } + localRunString := getRunString([]string{ + "--rm", + ALPINE, + "top", + }) + // Let's start a container with runc and try to restore it with crun (expected to fail) + localRunString = append( + []string{ + "--runtime", + "runc", + }, + localRunString..., + ) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + + session = podmanTest.Podman([]string{ + "inspect", + "--format", + "{{.OCIRuntime}}", + cid, + }) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + runtime := session.OutputToString() + + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + result := podmanTest.Podman([]string{ + "container", + "checkpoint", + cid, "-e", + fileName, + }) + result.WaitWithDefaultTimeout() + + // As the container has been started with '--rm' it will be completely + // cleaned up after checkpointing. + Expect(result).Should(Exit(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + // This should fail as the container was checkpointed with runc + result = podmanTest.Podman([]string{ + "--runtime", + "crun", + "container", + "restore", + "-i", + fileName, + }) + result.WaitWithDefaultTimeout() + + Expect(result).Should(Exit(125)) + Expect(result.ErrorToString()).To( + ContainSubstring("and cannot be restored with runtime"), + ) + + result = podmanTest.Podman([]string{ + "--runtime", + "runc", + "container", + "restore", + "-i", + fileName, + }) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + + result = podmanTest.Podman([]string{ + "inspect", + "--format", + "{{.OCIRuntime}}", + cid, + }) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + Expect(result.OutputToString()).To(Equal(runtime)) + + result = podmanTest.Podman([]string{ + "--runtime", + "runc", + "rm", + "-fa", + }) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + // Remove exported checkpoint + os.Remove(fileName) + }) }) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 200faae2d..6180343a7 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -320,7 +320,7 @@ func (p *PodmanTestIntegration) createArtifact(image string) { } dest := strings.Split(image, "/") destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1)) - fmt.Printf("Caching %s at %s...", image, destName) + fmt.Printf("Caching %s at %s...\n", image, destName) if _, err := os.Stat(destName); os.IsNotExist(err) { pull := p.PodmanNoCache([]string{"pull", image}) pull.Wait(440) @@ -466,6 +466,9 @@ func (p *PodmanTestIntegration) BuildImageWithLabel(dockerfile, imageName string // PodmanPID execs podman and returns its PID func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegration, int) { podmanOptions := p.MakeOptions(args, false, false) + if p.RemoteTest { + podmanOptions = append([]string{"--remote", "--url", p.RemoteSocket}, podmanOptions...) + } fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " ")) command := exec.Command(p.PodmanBinary, podmanOptions...) session, err := Start(command, GinkgoWriter, GinkgoWriter) 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 e6e8dcdb1..216432216 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/generate_kube_test.go b/test/e2e/generate_kube_test.go index cd382eba9..d95555068 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -71,6 +71,7 @@ var _ = Describe("Podman generate kube", func() { Expect(pod.Spec.DNSConfig).To(BeNil()) Expect(pod.Spec.Containers[0].WorkingDir).To(Equal("")) Expect(pod.Spec.Containers[0].Env).To(BeNil()) + Expect(pod.Name).To(Equal("top_pod")) numContainers := 0 for range pod.Spec.Containers { diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 121f09a11..e93482535 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -147,6 +147,15 @@ var _ = Describe("Podman generate systemd", func() { session := podmanTest.Podman([]string{"generate", "systemd", "--time", "5", "nginx"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) + Expect(session.OutputToString()).To(ContainSubstring("TimeoutStopSec=65")) + Expect(session.OutputToString()).ToNot(ContainSubstring("TimeoutStartSec=")) + Expect(session.OutputToString()).To(ContainSubstring("podman stop -t 5")) + + session = podmanTest.Podman([]string{"generate", "systemd", "--stop-timeout", "5", "--start-timeout", "123", "nginx"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + Expect(session.OutputToString()).To(ContainSubstring("TimeoutStartSec=123")) + Expect(session.OutputToString()).To(ContainSubstring("TimeoutStopSec=65")) Expect(session.OutputToString()).To(ContainSubstring("podman stop -t 5")) }) 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 d5b9efaf7..e1c89753e 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -18,7 +18,6 @@ var _ = Describe("Podman import", func() { ) BeforeEach(func() { - SkipIfRemote("FIXME: These look like it is supposed to work in remote") tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) @@ -88,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() { @@ -156,6 +155,8 @@ var _ = Describe("Podman import", func() { }) It("podman import with signature", func() { + SkipIfRemote("FIXME: remote ignores --signature-policy, #12357") + outfile := filepath.Join(podmanTest.TempDir, "container.tar") _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index 3cf24037e..030e9f80b 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -222,7 +222,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() { @@ -247,7 +247,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() { @@ -273,7 +273,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() { @@ -298,7 +298,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/logs_test.go b/test/e2e/logs_test.go index 3beabec4b..d901dde5c 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -214,7 +214,7 @@ var _ = Describe("Podman logs", func() { It("two containers showing short container IDs: "+log, func() { skipIfJournaldInContainer() - SkipIfRemote("FIXME: podman-remote logs does not support showing two containers at the same time") + SkipIfRemote("podman-remote logs does not support showing two containers at the same time") log1 := podmanTest.Podman([]string{"run", "--log-driver", log, "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) log1.WaitWithDefaultTimeout() 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/pull_test.go b/test/e2e/pull_test.go index c377f158d..fdb1b0c57 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -48,7 +48,7 @@ var _ = Describe("Podman pull", func() { found, _ := session.ErrorGrepString(expectedError) Expect(found).To(Equal(true)) - session = podmanTest.Podman([]string{"rmi", "busybox", "alpine", "testdigest_v2s2", "quay.io/libpod/cirros"}) + session = podmanTest.Podman([]string{"rmi", "busybox:musl", "alpine", "quay.io/libpod/cirros", "testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) @@ -104,8 +104,13 @@ var _ = Describe("Podman pull", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) + // Without a tag/digest the input is normalized with the "latest" tag, see #11964 session = podmanTest.Podman([]string{"rmi", "testdigest_v2s2"}) session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(1)) + + session = podmanTest.Podman([]string{"rmi", "testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"}) + session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 7b35acd35..7038a09e8 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -95,7 +95,7 @@ var _ = Describe("Podman push", func() { }) It("podman push to local registry with authorization", func() { - SkipIfRootless("FIXME: Creating content in certs.d we use directories in homedir") + SkipIfRootless("volume-mounting a certs.d file N/A over remote") if podmanTest.Host.Arch == "ppc64le" { Skip("No registry image for ppc64le") } 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_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go index e0e1d4b1d..6bdc6af08 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -48,21 +48,22 @@ var _ = Describe("Podman run with --cgroup-parent", func() { run := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroup-parent", cgroup, fedoraMinimal, "cat", "/proc/self/cgroup"}) run.WaitWithDefaultTimeout() Expect(run).Should(Exit(0)) - ok, _ := run.GrepString(cgroup) - Expect(ok).To(BeTrue()) + Expect(run.OutputToString()).To(ContainSubstring(cgroup)) }) Specify("no --cgroup-parent", func() { - SkipIfRootless("FIXME This seems to be broken in rootless mode") cgroup := "/libpod_parent" if !Containerized() && podmanTest.CgroupManager != "cgroupfs" { - cgroup = "/machine.slice" + if isRootless() { + cgroup = "/user.slice" + } else { + cgroup = "/machine.slice" + } } run := podmanTest.Podman([]string{"run", "--cgroupns=host", fedoraMinimal, "cat", "/proc/self/cgroup"}) run.WaitWithDefaultTimeout() Expect(run).Should(Exit(0)) - ok, _ := run.GrepString(cgroup) - Expect(ok).To(BeTrue()) + Expect(run.OutputToString()).To(ContainSubstring(cgroup)) }) Specify("always honor --cgroup-parent", func() { @@ -114,7 +115,6 @@ var _ = Describe("Podman run with --cgroup-parent", func() { run := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroup-parent", cgroup, fedoraMinimal, "cat", "/proc/1/cgroup"}) run.WaitWithDefaultTimeout() Expect(run).Should(Exit(0)) - ok, _ := run.GrepString(cgroup) - Expect(ok).To(BeTrue()) + Expect(run.OutputToString()).To(ContainSubstring(cgroup)) }) }) diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index 6753fcf12..cc4e66751 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -35,7 +35,7 @@ var _ = Describe("Podman run exit", func() { It("podman run -d mount cleanup test", func() { SkipIfRemote("podman-remote does not support mount") - SkipIfRootless("FIXME podman mount requires podman unshare first") + SkipIfRootless("TODO rootless podman mount requires podman unshare first") result := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"}) result.WaitWithDefaultTimeout() 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 c64cfd2d5..e2004c8e0 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -283,6 +283,42 @@ var _ = Describe("Podman run networking", func() { Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) }) + It("podman run --publish-all with EXPOSE port ranges in Dockerfile", func() { + // Test port ranges, range with protocol and with an overlapping port + podmanTest.AddImageToRWStore(ALPINE) + dockerfile := fmt.Sprintf(`FROM %s +EXPOSE 2002 +EXPOSE 2001-2003 +EXPOSE 2004-2005/tcp`, ALPINE) + imageName := "testimg" + podmanTest.BuildImage(dockerfile, imageName, "false") + + // Verify that the buildah is just passing through the EXPOSE keys + inspect := podmanTest.Podman([]string{"inspect", imageName}) + inspect.WaitWithDefaultTimeout() + image := inspect.InspectImageJSON() + Expect(len(image)).To(Equal(1)) + Expect(len(image[0].Config.ExposedPorts)).To(Equal(3)) + Expect(image[0].Config.ExposedPorts).To(HaveKey("2002/tcp")) + Expect(image[0].Config.ExposedPorts).To(HaveKey("2001-2003/tcp")) + Expect(image[0].Config.ExposedPorts).To(HaveKey("2004-2005/tcp")) + + containerName := "testcontainer" + session := podmanTest.Podman([]string{"create", "--name", containerName, imageName, "true"}) + session.WaitWithDefaultTimeout() + inspectOut := podmanTest.InspectContainer(containerName) + Expect(len(inspectOut)).To(Equal(1)) + + // Inspect the network settings with available ports to be mapped to the host + // Don't need to verity HostConfig.PortBindings since we used --publish-all + Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(5)) + Expect(inspectOut[0].NetworkSettings.Ports).To(HaveKey("2001/tcp")) + Expect(inspectOut[0].NetworkSettings.Ports).To(HaveKey("2002/tcp")) + Expect(inspectOut[0].NetworkSettings.Ports).To(HaveKey("2003/tcp")) + Expect(inspectOut[0].NetworkSettings.Ports).To(HaveKey("2004/tcp")) + Expect(inspectOut[0].NetworkSettings.Ports).To(HaveKey("2005/tcp")) + }) + It("podman run -p 127.0.0.1::8980/udp", func() { name := "testctr" session := podmanTest.Podman([]string{"create", "-t", "-p", "127.0.0.1::8980/udp", "--name", name, ALPINE, "/bin/sh"}) @@ -523,38 +559,33 @@ var _ = Describe("Podman run networking", func() { 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_privileged_test.go b/test/e2e/run_privileged_test.go index 3e4262cfb..d793a01f8 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -128,7 +128,6 @@ var _ = Describe("Podman privileged container tests", func() { }) It("podman privileged should inherit host devices", func() { - SkipIfRootless("FIXME: This seems to be broken for rootless mode, /dev/ is close to the same") session := podmanTest.Podman([]string{"run", "--privileged", ALPINE, "ls", "-l", "/dev"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) 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_signal_test.go b/test/e2e/run_signal_test.go index e9c073a6c..49f456366 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -45,7 +45,6 @@ var _ = Describe("Podman run with --sig-proxy", func() { }) Specify("signals are forwarded to container using sig-proxy", func() { - SkipIfRemote("FIXME: This looks like it is supposed to work in remote") if podmanTest.Host.Arch == "ppc64le" { Skip("Doesn't work on ppc64le") } @@ -111,7 +110,6 @@ var _ = Describe("Podman run with --sig-proxy", func() { }) Specify("signals are not forwarded to container with sig-proxy false", func() { - SkipIfRemote("FIXME: This looks like it is supposed to work in remote") signal := syscall.SIGFPE if rootless.IsRootless() { podmanTest.RestoreArtifact(fedoraMinimal) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index d3e64c6f7..aa9037e56 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -156,8 +156,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() { @@ -166,10 +165,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() { @@ -425,16 +422,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() { @@ -685,7 +680,7 @@ USER bin`, BB) }) It("podman run device-read-bps test", func() { - SkipIfRootless("FIXME: Missing /sys/fs/cgroup/user.slice/user-14467.slice/user@14467.service/cgroup.subtree_control") + SkipIfRootless("FIXME: requested cgroup controller `io` is not available") SkipIfRootlessCgroupsV1("Setting device-read-bps not supported on cgroupv1 for rootless users") var session *PodmanSessionIntegration @@ -704,7 +699,7 @@ USER bin`, BB) }) It("podman run device-write-bps test", func() { - SkipIfRootless("FIXME /sys/fs/cgroup/user.slice/user-14467.slice/user@14467.service/cgroup.subtree_control does not exist") + SkipIfRootless("FIXME: requested cgroup controller `io` is not available") SkipIfRootlessCgroupsV1("Setting device-write-bps not supported on cgroupv1 for rootless users") var session *PodmanSessionIntegration @@ -722,7 +717,7 @@ USER bin`, BB) }) It("podman run device-read-iops test", func() { - SkipIfRootless("FIXME /sys/fs/cgroup/user.slice/user-14467.slice/user@14467.service/cgroup.subtree_control does not exist") + SkipIfRootless("FIXME: requested cgroup controller `io` is not available") SkipIfRootlessCgroupsV1("Setting device-read-iops not supported on cgroupv1 for rootless users") var session *PodmanSessionIntegration @@ -740,7 +735,7 @@ USER bin`, BB) }) It("podman run device-write-iops test", func() { - SkipIfRootless("FIXME /sys/fs/cgroup/user.slice/user-14467.slice/user@14467.service/cgroup.subtree_control does not exist") + SkipIfRootless("FIXME: requested cgroup controller `io` is not available") SkipIfRootlessCgroupsV1("Setting device-write-iops not supported on cgroupv1 for rootless users") var session *PodmanSessionIntegration @@ -883,14 +878,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() { @@ -904,14 +899,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() { @@ -943,7 +938,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() { @@ -1221,8 +1216,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 634a498b9..0de2dbd65 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -282,8 +282,8 @@ var _ = Describe("Podman run with volumes", func() { }) It("podman run with tmpfs named volume mounts and unmounts", func() { - SkipIfRootless("FIXME: rootless podman mount requires you to be in a user namespace") - SkipIfRemote("podman-remote does not support --volumes this test could be simplified to be tested on Remote.") + SkipIfRootless("rootless podman mount requires you to be in a user namespace") + SkipIfRemote("podman-remote does not support --volumes. This test could be simplified to be tested on Remote.") volName := "testvol" mkVolume := podmanTest.Podman([]string{"volume", "create", "--opt", "type=tmpfs", "--opt", "device=tmpfs", "--opt", "o=nodev", "testvol"}) mkVolume.WaitWithDefaultTimeout() @@ -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 cdc5e7f1e..a8fb6c7b3 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -255,8 +255,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)) }) diff --git a/test/system/030-run.bats b/test/system/030-run.bats index ba21cd21d..5937d38f8 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -236,7 +236,7 @@ echo $rand | 0 | $rand } @test "podman run docker-archive" { - skip_if_remote "podman-remote does not support docker-archive (#7116)" + skip_if_remote "podman-remote does not support docker-archive" # Create an image that, when run, outputs a random magic string expect=$(random_string 20) diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index e997ab6f9..4757f7643 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -138,7 +138,7 @@ function service_cleanup() { } # Regression test for #11438 -@test "podman generate systemd - restart policy" { +@test "podman generate systemd - restart policy & timeouts" { cname=$(random_string) run_podman create --restart=always --name $cname $IMAGE run_podman generate systemd --new $cname diff --git a/test/system/400-unprivileged-access.bats b/test/system/400-unprivileged-access.bats index f26c97d1e..cf0d0e6bf 100644 --- a/test/system/400-unprivileged-access.bats +++ b/test/system/400-unprivileged-access.bats @@ -101,11 +101,6 @@ EOF # #6957 - mask out /proc/acpi, /sys/dev, and other sensitive system files @test "sensitive mount points are masked without --privileged" { - # Weird error, maybe a flake? - # can only attach to created or running containers: container state improper - # https://github.com/containers/podman/pull/7111#issuecomment-666858715 - skip_if_remote "FIXME: Weird flake" - # FIXME: this should match the list in pkg/specgen/generate/config_linux.go local -a mps=( /proc/acpi diff --git a/test/utils/utils.go b/test/utils/utils.go index 8d1edb23a..4a57d9ce7 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -121,6 +121,7 @@ func (p *PodmanTest) WaitForContainer() bool { } time.Sleep(1 * time.Second) } + fmt.Printf("WaitForContainer(): timed out\n") return false } |