diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index dcdd5f231c..53872b1818 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -16,7 +16,7 @@ var _ = Describe("Podman restart", func() { It("podman restart bogus container", func() { session := podmanTest.Podman([]string{"start", "123"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, `no container with name or ID "123" found: no such container`)) }) It("podman restart stopped container by name", func() { @@ -283,20 +283,19 @@ var _ = Describe("Podman restart", func() { SkipIfRemote("--latest flag n/a") result := podmanTest.Podman([]string{"restart", "--cidfile", "foobar", "--latest"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together")) + result = podmanTest.Podman([]string{"restart", "--cidfile", "foobar", "--all"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together")) + result = podmanTest.Podman([]string{"restart", "--cidfile", "foobar", "--all", "--latest"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together")) + result = podmanTest.Podman([]string{"restart", "--latest", "--all"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all and --latest cannot be used together")) }) It("podman restart --filter", func() { @@ -318,7 +317,7 @@ var _ = Describe("Podman restart", func() { session1 = podmanTest.Podman([]string{"restart", cid1, "-f", "status=test"}) session1.WaitWithDefaultTimeout() - Expect(session1).Should(Exit(125)) + Expect(session1).Should(ExitWithError(125, "--filter takes no arguments")) session1 = podmanTest.Podman([]string{"restart", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 68bd6c7f10..7a734c9285 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -7,7 +7,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 rm", func() { @@ -29,8 +28,7 @@ var _ = Describe("Podman rm", func() { result := podmanTest.Podman([]string{"rm", cid}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(2)) - Expect(result.ErrorToString()).To(ContainSubstring("containers cannot be removed without force")) + Expect(result).Should(ExitWithError(2, "containers cannot be removed without force")) }) It("podman rm created container", func() { @@ -169,23 +167,19 @@ var _ = Describe("Podman rm", func() { result := podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--latest"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("--all, --latest, and --cidfile cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together")) result = podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--all"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("--all, --latest, and --cidfile cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together")) result = podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--all", "--latest"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("--all, --latest, and --cidfile cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together")) result = podmanTest.Podman([]string{"rm", "--latest", "--all"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(125)) - Expect(result.ErrorToString()).To(ContainSubstring("--all and --latest cannot be used together")) + Expect(result).Should(ExitWithError(125, "--all and --latest cannot be used together")) }) It("podman rm --all", func() { @@ -214,8 +208,7 @@ var _ = Describe("Podman rm", func() { session = podmanTest.Podman([]string{"rm", "bogus", cid}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) - Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container")) + Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`)) if IsRemote() { Expect(session.OutputToString()).To(BeEquivalentTo(cid)) } @@ -232,8 +225,7 @@ var _ = Describe("Podman rm", func() { It("podman rm bogus container", func() { session := podmanTest.Podman([]string{"rm", "bogus"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) - Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container")) + Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`)) }) It("podman rm bogus container and a running container", func() { @@ -243,13 +235,11 @@ var _ = Describe("Podman rm", func() { session = podmanTest.Podman([]string{"rm", "bogus", "test1"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) - Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container")) + Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`)) session = podmanTest.Podman([]string{"rm", "test1", "bogus"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) - Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container")) + Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`)) }) It("podman rm --ignore bogus container and a running container", func() { @@ -259,8 +249,7 @@ var _ = Describe("Podman rm", func() { session = podmanTest.Podman([]string{"rm", "--ignore", "test1", "bogus"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(2)) - Expect(session.ErrorToString()).To(ContainSubstring("containers cannot be removed without force")) + Expect(session).Should(ExitWithError(2, "containers cannot be removed without force")) session = podmanTest.Podman([]string{"rm", "-t", "0", "--force", "--ignore", "bogus", "test1"}) session.WaitWithDefaultTimeout() @@ -292,8 +281,7 @@ var _ = Describe("Podman rm", func() { session1 = podmanTest.Podman([]string{"rm", cid1, "-f", "--filter", "status=running"}) session1.WaitWithDefaultTimeout() - Expect(session1).Should(Exit(125)) - Expect(session1.ErrorToString()).To(ContainSubstring("--filter takes no arguments")) + Expect(session1).Should(ExitWithError(125, "--filter takes no arguments")) session1 = podmanTest.Podman([]string{"rm", "-a", "-f", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go index 7144051021..ef6fe8b486 100644 --- a/test/e2e/run_device_test.go +++ b/test/e2e/run_device_test.go @@ -9,7 +9,6 @@ import ( . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) func createContainersConfFileWithDevices(pTest *PodmanTestIntegration, devices string) { @@ -95,7 +94,7 @@ var _ = Describe("Podman run device", func() { // verify --privileged is required session2 := podmanTest.Podman([]string{"run", ALPINE, "test", "-c", "/dev/kmsg"}) session2.WaitWithDefaultTimeout() - Expect(session2).Should(Exit(1)) + Expect(session2).Should(ExitWithError(1, "")) Expect(session2.OutputToString()).To(BeEmpty()) }) diff --git a/test/e2e/run_env_test.go b/test/e2e/run_env_test.go index e3989fad53..bc459b7475 100644 --- a/test/e2e/run_env_test.go +++ b/test/e2e/run_env_test.go @@ -6,7 +6,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 run", func() { @@ -54,7 +53,7 @@ var _ = Describe("Podman run", func() { session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(BeEmpty()) - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, "")) session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv"}) session.WaitWithDefaultTimeout() @@ -90,8 +89,7 @@ ENV hello=world session.WaitWithDefaultTimeout() if IsRemote() { // podman-remote does not support --env-host - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("unknown flag: --env-host")) + Expect(session).Should(ExitWithError(125, "unknown flag: --env-host")) return } Expect(session).Should(ExitCleanly()) @@ -125,7 +123,7 @@ ENV hello=world session = podmanTest.Podman([]string{"run", "--http-proxy=false", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1, "")) Expect(session.OutputToString()).To(Equal("")) session = podmanTest.Podman([]string{"run", "--env", "http_proxy=5.6.7.8", ALPINE, "printenv", "http_proxy"}) diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go index e31a1a6e75..b300567ce5 100644 --- a/test/e2e/run_exit_test.go +++ b/test/e2e/run_exit_test.go @@ -7,7 +7,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 run exit", func() { @@ -15,19 +14,19 @@ var _ = Describe("Podman run exit", func() { It("podman run exit define.ExecErrorCodeGeneric", func() { result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(define.ExecErrorCodeGeneric)) + Expect(result).Should(ExitWithError(define.ExecErrorCodeGeneric, "unknown flag: --foobar")) }) It("podman run exit ExecErrorCodeCannotInvoke", func() { result := podmanTest.Podman([]string{"run", ALPINE, "/etc"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(define.ExecErrorCodeCannotInvoke)) + Expect(result).Should(ExitWithError(define.ExecErrorCodeCannotInvoke, "open executable: Operation not permitted: OCI permission denied")) }) It("podman run exit ExecErrorCodeNotFound", func() { result := podmanTest.Podman([]string{"run", ALPINE, "foobar"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(define.ExecErrorCodeNotFound)) + Expect(result).Should(ExitWithError(define.ExecErrorCodeNotFound, "executable file `foobar` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found")) }) It("podman run exit 0", func() { @@ -39,12 +38,12 @@ var _ = Describe("Podman run exit", func() { It("podman run exit 50", func() { result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(50)) + Expect(result).Should(ExitWithError(50, "")) }) It("podman run exit 125", func() { result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", fmt.Sprintf("exit %d", define.ExecErrorCodeGeneric)}) result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(define.ExecErrorCodeGeneric)) + Expect(result).Should(ExitWithError(define.ExecErrorCodeGeneric, "")) }) }) diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go index 66a8374681..50ac5b58ca 100644 --- a/test/e2e/run_selinux_test.go +++ b/test/e2e/run_selinux_test.go @@ -7,7 +7,6 @@ import ( . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" "github.com/opencontainers/selinux/go-selinux" ) @@ -124,7 +123,7 @@ var _ = Describe("Podman run", func() { session = podmanTest.Podman([]string{"run", "--security-opt", "label=type:spc_t", "--security-opt", "label=filetype:foobar", fedoraMinimal, "ls", "-Z", "/dev"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(126)) + Expect(session).Should(ExitWithError(126, "invalid argument")) }) It("podman exec selinux check", func() { diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 811f0a4620..ffb0ef11d8 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -12,7 +12,6 @@ import ( "github.com/containers/storage" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) func createContainersConfFileWithCustomUserns(pTest *PodmanTestIntegration, userns string) { @@ -371,13 +370,11 @@ var _ = Describe("Podman UserNS support", func() { It("podman --userns= conflicts with ui[dg]map and sub[ug]idname", func() { session := podmanTest.Podman([]string{"run", "--userns=host", "--uidmap=0:1:500", "alpine", "true"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive")) + Expect(session).Should(ExitWithError(125, "--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive")) session = podmanTest.Podman([]string{"run", "--userns=host", "--gidmap=0:200:5000", "alpine", "true"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(ContainSubstring("--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive")) + Expect(session).Should(ExitWithError(125, "--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive")) // with sub[ug]idname we don't check for the error output since the error message could be different, depending on the // system configuration since the specified user could not be defined and cause a different earlier error. diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index c9cf658163..f8dc22b1ed 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -132,7 +132,7 @@ var _ = Describe("Podman run with volumes", func() { Expect(err).ToNot(HaveOccurred()) session := podmanTest.Podman([]string{"run", "-v", mountPath + ":" + dest, "-v", "/tmp" + ":" + dest, ALPINE, "ls"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, fmt.Sprintf("%s: duplicate mount destination", dest))) }) It("podman run with conflict between image volume and user mount succeeds", func() { @@ -430,7 +430,7 @@ var _ = Describe("Podman run with volumes", func() { noCopySession := podmanTest.Podman([]string{"run", "--rm", "-v", "testvol4:/etc/apk:nocopy", ALPINE, "stat", "-c", "%h", "/etc/apk/arch"}) noCopySession.WaitWithDefaultTimeout() - Expect(noCopySession).Should(Exit(1)) + Expect(noCopySession).Should(ExitWithError(1, "stat: can't stat '/etc/apk/arch': No such file or directory")) }) It("podman named volume copyup symlink", func() { diff --git a/test/e2e/run_working_dir_test.go b/test/e2e/run_working_dir_test.go index 9f06df9313..bc5deaff64 100644 --- a/test/e2e/run_working_dir_test.go +++ b/test/e2e/run_working_dir_test.go @@ -8,7 +8,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 run", func() { @@ -23,7 +22,7 @@ var _ = Describe("Podman run", func() { It("podman run a container using non existing --workdir", func() { session := podmanTest.Podman([]string{"run", "--workdir", "/home/foobar", ALPINE, "pwd"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(126)) + Expect(session).Should(ExitWithError(126, `workdir "/home/foobar" does not exist on container `)) }) It("podman run a container using a --workdir under a bind mount", func() {