diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 4e52f38fe4..a29619f2a9 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -121,7 +121,7 @@ var _ = Describe("Podman build", func() { It("podman build context directory a file", func() { session := podmanTest.Podman([]string{"build", "--pull=never", "build/context_dir_a_file"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "context must be a directory:")) }) // Check that builds with different values for the squash options @@ -314,8 +314,7 @@ RUN printenv http_proxy`, CITEST_IMAGE) // this tries to use the cache so we explicitly disable it session = podmanTest.Podman([]string{"build", "--no-cache", "--pull-never", "--http-proxy=false", "--file", dockerfilePath, podmanTest.TempDir}) session.Wait(120) - Expect(session).Should(Exit(1)) - Expect(session.ErrorToString()).To(ContainSubstring(`Error: building at STEP "RUN printenv http_proxy"`)) + Expect(session).Should(ExitWithError(1, `Error: building at STEP "RUN printenv http_proxy"`)) }) It("podman build relay exit code to process", func() { @@ -332,7 +331,7 @@ RUN exit 5`, CITEST_IMAGE) Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"build", "-t", "error-test", "--file", dockerfilePath, podmanTest.TempDir}) session.Wait(120) - Expect(session).Should(Exit(5)) + Expect(session).Should(ExitWithError(5, `building at STEP "RUN exit 5": while running runtime: exit status 5`)) }) It("podman build and check identity", func() { @@ -398,8 +397,7 @@ COPY /emptydir/* /dir`, CITEST_IMAGE) // NOTE: Docker and buildah both should error when `COPY /* /dir` is done on emptydir // as context. However buildkit simply ignores this so when buildah also starts ignoring // for such case edit this test to return 0 and check that no `/dir` should be in the result. - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("can't make relative to")) + Expect(session).Should(ExitWithError(125, "can't make relative to")) }) It("podman remote test container/docker file is not inside context dir", func() { @@ -757,7 +755,7 @@ RUN grep CapEff /proc/self/status` }) session.WaitWithDefaultTimeout() // Then - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, `unrecognized isolation type "bogus"`)) }) It("podman build --timestamp flag", func() { @@ -841,7 +839,7 @@ RUN ls /dev/fuse`, CITEST_IMAGE) Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, `building at STEP "RUN ls /dev/fuse": while running runtime: exit status 1`)) session = podmanTest.Podman([]string{"build", "--pull-never", "--device", "/dev/fuse", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -857,7 +855,7 @@ RUN ls /dev/test1`, CITEST_IMAGE) Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, `building at STEP "RUN ls /dev/test1": while running runtime: exit status 1`)) session = podmanTest.Podman([]string{"build", "--pull-never", "--device", "/dev/zero:/dev/test1", "-t", "test", "--file", containerfilePath, podmanTest.TempDir}) session.WaitWithDefaultTimeout() @@ -896,6 +894,6 @@ RUN ls /dev/test1`, CITEST_IMAGE) session = podmanTest.Podman([]string{"build", "--pull-never", "--file", "build/cache/Dockerfilecacheread", "build/cache/"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, `building at STEP "RUN --mount=type=cache,target=/test,z cat /test/world": while running runtime: exit status 1`)) }) }) diff --git a/test/e2e/cleanup_test.go b/test/e2e/cleanup_test.go index d43e6405ab..10bdd9d92c 100644 --- a/test/e2e/cleanup_test.go +++ b/test/e2e/cleanup_test.go @@ -4,7 +4,6 @@ import ( . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman container cleanup", func() { @@ -16,8 +15,7 @@ var _ = Describe("Podman container cleanup", func() { It("podman cleanup bogus container", func() { session := podmanTest.Podman([]string{"container", "cleanup", "foobar"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("no such container")) + Expect(session).Should(ExitWithError(125, `no container with name or ID "foobar" found: no such container`)) }) It("podman cleanup container by id", func() { @@ -88,8 +86,7 @@ var _ = Describe("Podman container cleanup", func() { Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"container", "cleanup", "running"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("container state improper")) + Expect(session).Should(ExitWithError(125, "is running or paused, refusing to clean up: container state improper")) }) It("podman cleanup paused container", func() { @@ -102,8 +99,7 @@ var _ = Describe("Podman container cleanup", func() { Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"container", "cleanup", "paused"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("container state improper")) + Expect(session).Should(ExitWithError(125, "is running or paused, refusing to clean up: container state improper")) // unpause so that the cleanup can stop the container, // otherwise it fails with container state improper diff --git a/test/e2e/create_staticmac_test.go b/test/e2e/create_staticmac_test.go index 35b1f7cbe6..d020e16530 100644 --- a/test/e2e/create_staticmac_test.go +++ b/test/e2e/create_staticmac_test.go @@ -5,7 +5,6 @@ import ( "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman run with --mac-address flag", func() { @@ -14,7 +13,7 @@ var _ = Describe("Podman run with --mac-address flag", func() { result := podmanTest.Podman([]string{"run", "--mac-address", "92:d0:c6:0a:29:34", ALPINE, "ip", "addr"}) result.WaitWithDefaultTimeout() if isRootless() { - Expect(result).Should(Exit(125)) + Expect(result).Should(ExitWithError(125, "invalid config provided: networks and static ip/mac address can only be used with Bridge mode networking")) } else { Expect(result).Should(ExitCleanly()) Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:0a:29:34")) diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index 1db506c840..6df5a85540 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -8,7 +8,6 @@ import ( "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman diff", func() { @@ -23,7 +22,7 @@ var _ = Describe("Podman diff", func() { It("podman diff bogus image", func() { session := podmanTest.Podman([]string{"diff", "1234"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "1234 not found: layer not known")) }) It("podman diff image with json output", func() { @@ -119,7 +118,7 @@ RUN echo test It("podman image diff bogus image", func() { session := podmanTest.Podman([]string{"image", "diff", "1234", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "1234 not found: 1234: image not known")) }) It("podman image diff of the same image", func() { diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index c290fa3981..dcb7ff23f8 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -95,7 +95,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "test1", "sh", "-c", "exit 100"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(100)) + Expect(session).Should(ExitWithError(100, "")) }) It("podman exec in keep-id container drops privileges", func() { diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go index c86ca5f5fd..3da48b8088 100644 --- a/test/e2e/exists_test.go +++ b/test/e2e/exists_test.go @@ -4,7 +4,6 @@ import ( . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman image|container exists", func() { @@ -22,7 +21,7 @@ var _ = Describe("Podman image|container exists", func() { It("podman image does not exist in local storage", func() { session := podmanTest.Podman([]string{"image", "exists", "alpine9999"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, "")) }) It("podman container exists in local storage by name", func() { setup := podmanTest.RunTopContainer("foobar") @@ -56,7 +55,7 @@ var _ = Describe("Podman image|container exists", func() { It("podman container does not exist in local storage", func() { session := podmanTest.Podman([]string{"container", "exists", "foobar"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, "")) }) It("podman pod exists in local storage by name", func() { @@ -90,6 +89,6 @@ var _ = Describe("Podman image|container exists", func() { // The exit code for non-existing pod is incorrect (125 vs 1) session := podmanTest.Podman([]string{"pod", "exists", "foobar"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, "")) }) }) diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 3c62d09674..81483223f5 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -218,13 +218,11 @@ var _ = Describe("Podman generate systemd", func() { // Fail for the pod session = podmanTest.Podman([]string{"generate", "systemd", "foo"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("cannot generate systemd units for init containers")) + Expect(session).Should(ExitWithError(125, "cannot generate systemd units for init containers")) // Fail for the init container session = podmanTest.Podman([]string{"generate", "systemd", "foo-init"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("cannot generate systemd units for init containers")) + Expect(session).Should(ExitWithError(125, "cannot generate systemd units for init containers")) }) It("podman generate systemd pod --name --files", func() { diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 63a029f197..ddde5a27bc 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -217,8 +217,8 @@ WORKDIR /test podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") result := podmanTest.Podman([]string{"images", "-q", "-f", "dangling=true"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0), "dangling image output: %q", result.OutputToString()) - Expect(result.OutputToStringArray()).Should(BeEmpty(), "dangling image output: %q", result.OutputToString()) + Expect(result).Should(ExitCleanly()) + Expect(result.OutputToStringArray()).Should(BeEmpty(), "dangling image output") }) It("podman images filter intermediate", func() { diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go index 56b58aab50..5bf028a207 100644 --- a/test/e2e/info_test.go +++ b/test/e2e/info_test.go @@ -224,8 +224,7 @@ var _ = Describe("Podman Info", func() { // make sure we get an error for bogus values session := podmanTest.Podman([]string{"--db-backend", "bogus", "info", "--format", "{{.Host.DatabaseBackend}}"}) session.WaitWithDefaultTimeout() - Expect(session).To(Exit(125)) - Expect(session.ErrorToString()).To(Equal("Error: unsupported database backend: \"bogus\"")) + Expect(session).To(ExitWithError(125, `Error: unsupported database backend: "bogus"`)) }) It("Podman info: check desired storage driver", func() { diff --git a/test/e2e/init_test.go b/test/e2e/init_test.go index 5c8cb14f34..dae57b6c88 100644 --- a/test/e2e/init_test.go +++ b/test/e2e/init_test.go @@ -1,10 +1,11 @@ package integration import ( + "fmt" + . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman init", func() { @@ -12,13 +13,13 @@ var _ = Describe("Podman init", func() { It("podman init bogus container", func() { session := podmanTest.Podman([]string{"start", "123456"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, `Error: no container with name or ID "123456" found: no such container`)) }) It("podman init with no arguments", func() { session := podmanTest.Podman([]string{"start"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "Error: start requires at least one argument")) }) It("podman init single container by ID", func() { @@ -110,8 +111,10 @@ var _ = Describe("Podman init", func() { session := podmanTest.Podman([]string{"run", "--name", "init_test", "-d", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) + cid := session.OutputToString() + init := podmanTest.Podman([]string{"init", "init_test"}) init.WaitWithDefaultTimeout() - Expect(init).Should(Exit(125)) + Expect(init).Should(ExitWithError(125, fmt.Sprintf("Error: container %s has already been created in runtime: container state improper", cid))) }) })