diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index c0a465362b..7e7cdcb406 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -62,7 +62,7 @@ var _ = Describe("Podman save", func() { save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "FOOBAR"}) save.WaitWithDefaultTimeout() - Expect(save).To(ExitWithError()) + Expect(save).To(ExitWithError(125, "repository name must be lowercase")) }) It("podman save to directory with oci format", func() { @@ -102,13 +102,11 @@ var _ = Describe("Podman save", func() { save := podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "docker-archive", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() - // should not be 0 - Expect(save).To(ExitWithError()) + Expect(save).To(ExitWithError(125, "--compress can only be set when --format is 'docker-dir'")) save = podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "oci-archive", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() - // should not be 0 - Expect(save).To(ExitWithError()) + Expect(save).To(ExitWithError(125, "--compress can only be set when --format is 'docker-dir'")) }) @@ -117,7 +115,7 @@ var _ = Describe("Podman save", func() { save := podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() - Expect(save).To(ExitWithError()) + Expect(save).To(ExitWithError(125, fmt.Sprintf(`invalid filename (should not contain ':') "%s"`, outdir))) }) It("podman save remove signature", func() { @@ -199,7 +197,7 @@ default-docker: outfile := filepath.Join(podmanTest.TempDir, "temp.tar") save := podmanTest.Podman([]string{"save", "-q", "remove-signatures=true", "-o", outfile, pushedImage}) save.WaitWithDefaultTimeout() - Expect(save).To(ExitWithError()) + Expect(save).To(ExitWithError(125, "invalid reference format")) } }) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 568c1bf222..16bbe87a52 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -12,7 +12,6 @@ import ( . "github.com/containers/podman/v5/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" ) type endpoint struct { @@ -314,9 +313,8 @@ registries = []` search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"}) search.WaitWithDefaultTimeout() - Expect(search).Should(Exit(125)) + Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port))) Expect(search.OutputToString()).Should(BeEmpty()) - Expect(search.ErrorToString()).To(ContainSubstring("http: server gave HTTP response to HTTPS client")) // cleanup resetRegistriesConfigEnv() @@ -359,9 +357,8 @@ registries = []` search := podmanTest.Podman([]string{"search", image}) search.WaitWithDefaultTimeout() - Expect(search).Should(Exit(125)) + Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port))) Expect(search.OutputToString()).Should(BeEmpty()) - Expect(search.ErrorToString()).To(ContainSubstring("http: server gave HTTP response to HTTPS client")) // cleanup resetRegistriesConfigEnv() @@ -371,7 +368,7 @@ registries = []` It("podman search fail with nonexistent --authfile", func() { search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexistent", ALPINE}) search.WaitWithDefaultTimeout() - Expect(search).To(ExitWithError()) + Expect(search).To(ExitWithError(125, "credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory")) }) // Registry is unreliable (#18484), this is another super-common flake @@ -395,22 +392,19 @@ registries = []` search = podmanTest.Podman([]string{"search", "--filter=is-official", "--list-tags", "quay.io/podman/stable"}) search.WaitWithDefaultTimeout() - Expect(search).To(Exit(125)) - Expect(search.ErrorToString()).To(ContainSubstring("filters are not applicable to list tags result")) + Expect(search).To(ExitWithError(125, "filters are not applicable to list tags result")) // With trailing slash search = podmanTest.Podman([]string{"search", "--list-tags", "quay.io/podman/"}) search.WaitWithDefaultTimeout() - Expect(search).To(Exit(125)) + Expect(search).To(ExitWithError(125, `reference "podman/" must be a docker reference`)) Expect(search.OutputToStringArray()).To(BeEmpty()) - Expect(search.ErrorToString()).To(ContainSubstring("must be a docker reference")) // No trailing slash search = podmanTest.Podman([]string{"search", "--list-tags", "quay.io/podman"}) search.WaitWithDefaultTimeout() - Expect(search).To(Exit(125)) + Expect(search).To(ExitWithError(125, "getting repository tags: fetching tags list: StatusCode: 404")) Expect(search.OutputToStringArray()).To(BeEmpty()) - Expect(search.ErrorToString()).To(ContainSubstring("fetching tags list: StatusCode: 404")) }) It("podman search with limit over 100", func() { diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go index ceffb527d6..1f5cee9463 100644 --- a/test/e2e/secret_test.go +++ b/test/e2e/secret_test.go @@ -39,8 +39,7 @@ var _ = Describe("Podman secret", func() { session = podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val1", "a", secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) - Expect(session.ErrorToString()).To(Equal("Error: a: secret name in use")) + Expect(session).Should(ExitWithError(125, "Error: a: secret name in use")) session = podmanTest.Podman([]string{"secret", "create", "-d", "file", "--driver-opts", "opt1=val1", "--replace", "a", secretFilePath}) session.WaitWithDefaultTimeout() @@ -49,8 +48,7 @@ var _ = Describe("Podman secret", func() { inspect = podmanTest.Podman([]string{"secret", "inspect", "-f", "{{.Spec.Driver.Options}}", secrID}) inspect.WaitWithDefaultTimeout() - Expect(inspect).To(ExitWithError()) - Expect(inspect.ErrorToString()).To(ContainSubstring(fmt.Sprintf("Error: inspecting secret: no secret with name or id %q: no such secret", secrID))) + Expect(inspect).To(ExitWithError(125, fmt.Sprintf("Error: inspecting secret: no secret with name or id %q: no such secret", secrID))) inspect = podmanTest.Podman([]string{"secret", "inspect", "-f", "{{.Spec.Driver.Options}}", "a"}) inspect.WaitWithDefaultTimeout() @@ -66,14 +64,12 @@ var _ = Describe("Podman secret", func() { badName := "foo/bar" session := podmanTest.Podman([]string{"secret", "create", badName, secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) - Expect(session.ErrorToString()).To(Equal(fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName))) + Expect(session).To(ExitWithError(125, fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName))) badName = "foo=bar" session = podmanTest.Podman([]string{"secret", "create", badName, secretFilePath}) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) - Expect(session.ErrorToString()).To(Equal(fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName))) + Expect(session).To(ExitWithError(125, fmt.Sprintf("Error: secret name %q can not include '=', '/', ',', or the '\\0' (NULL) and be between 1 and 253 characters: invalid secret name", badName))) }) It("podman secret inspect", func() { @@ -164,7 +160,7 @@ var _ = Describe("Podman secret", func() { inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"}) inspect.WaitWithDefaultTimeout() - Expect(inspect).To(ExitWithError()) + Expect(inspect).To(ExitWithError(125, `inspecting secret: no secret with name or id "bogus": no such secret`)) }) It("podman secret ls", func() { @@ -352,7 +348,7 @@ var _ = Describe("Podman secret", func() { // no env variable set, should fail session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"}) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) + Expect(session).To(ExitWithError(125, "cannot create store secret data: environment variable MYENVVAR is not set")) os.Setenv("MYENVVAR", "somedata") if IsRemote() { diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index 887121a030..12ad669083 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -10,7 +10,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 start", func() { @@ -18,7 +17,7 @@ var _ = Describe("Podman start", func() { It("podman start 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 start single container by id", func() { @@ -37,10 +36,10 @@ var _ = Describe("Podman start", func() { Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"start", "test"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "not found in $PATH")) session = podmanTest.Podman([]string{"container", "exists", "test"}) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) + Expect(session).To(ExitWithError(1)) }) It("podman start --rm --attach removed on failure", func() { @@ -50,10 +49,10 @@ var _ = Describe("Podman start", func() { cid := session.OutputToString() session = podmanTest.Podman([]string{"start", "--attach", cid}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "not found in $PATH")) session = podmanTest.Podman([]string{"container", "exists", cid}) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) + Expect(session).To(ExitWithError(1)) }) It("podman container start single container by id", func() { @@ -98,7 +97,7 @@ var _ = Describe("Podman start", func() { session = podmanTest.Podman([]string{"start", "--attach", cid}) session.WaitWithDefaultTimeout() // It should forward the signal - Expect(session).Should(Exit(1)) + Expect(session).Should(ExitWithError(1)) }) It("podman start multiple containers", func() { @@ -119,7 +118,7 @@ var _ = Describe("Podman start", func() { cid1 := session.OutputToString() session = podmanTest.Podman([]string{"start", cid1, "doesnotexist"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, `no container with name or ID "doesnotexist" found: no such container`)) }) It("podman multiple containers -- attach should fail", func() { @@ -131,7 +130,7 @@ var _ = Describe("Podman start", func() { Expect(session).Should(ExitCleanly()) session = podmanTest.Podman([]string{"start", "-a", "foobar1", "foobar2"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "you cannot start and attach multiple containers at once")) }) It("podman failed to start with --rm should delete the container", func() { @@ -144,7 +143,7 @@ var _ = Describe("Podman start", func() { wait := podmanTest.Podman([]string{"wait", "test1"}) wait.WaitWithDefaultTimeout() - Expect(wait).To(ExitWithError()) + Expect(wait).To(ExitWithError(125, `no container with name or ID "test1" found: no such container`)) Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(BeZero()) }) @@ -156,19 +155,19 @@ var _ = Describe("Podman start", func() { start := podmanTest.Podman([]string{"start", session.OutputToString()}) start.WaitWithDefaultTimeout() - Expect(start).To(ExitWithError()) + Expect(start).To(ExitWithError(125, "not found in $PATH")) Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(Equal(1)) }) It("podman start --sig-proxy should not work without --attach", func() { - session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", "sigproxyneedsattach", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"start", "-l", "--sig-proxy"}) + session = podmanTest.Podman([]string{"start", "--sig-proxy", "sigproxyneedsattach"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + Expect(session).Should(ExitWithError(125, "you cannot use sig-proxy without --attach: invalid argument")) }) It("podman start container with special pidfile", func() { diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index 5aa1d0d84c..3ab2ea3ed7 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_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" ) // TODO: we need to check the output. Currently, we only check the exit codes @@ -25,7 +24,12 @@ var _ = Describe("Podman stats", func() { It("podman stats with bogus container", func() { session := podmanTest.Podman([]string{"stats", "--no-stream", "123"}) session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(125)) + expect := `unable to get list of containers: unable to look up container 123: no container with name or ID "123" found: no such container` + // FIXME: #22612 + if IsRemote() { + expect = "types.ContainerStatsReport.Error: decode non empty interface: can not unmarshal into nil, error found in #9 byte" + } + Expect(session).Should(ExitWithError(125, expect)) }) It("podman stats on a running container", func() { @@ -81,7 +85,7 @@ var _ = Describe("Podman stats", func() { Expect(session).Should(ExitCleanly()) stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--format", "\"table {{.ID}} {{.NoSuchField}} \""}) stats.WaitWithDefaultTimeout() - Expect(stats).To(ExitWithError()) + Expect(stats).To(ExitWithError(125, `template: stats:1:28: executing "stats" at <.NoSuchField>: can't evaluate field NoSuchField in type containers.containerStats`)) }) It("podman stats with negative interval", func() { @@ -90,7 +94,7 @@ var _ = Describe("Podman stats", func() { Expect(session).Should(ExitCleanly()) stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=-1"}) stats.WaitWithDefaultTimeout() - Expect(stats).To(ExitWithError()) + Expect(stats).To(ExitWithError(125, "invalid interval, must be a positive number greater zero")) }) It("podman stats with zero interval", func() { @@ -99,7 +103,7 @@ var _ = Describe("Podman stats", func() { Expect(session).Should(ExitCleanly()) stats := podmanTest.Podman([]string{"stats", "-a", "--no-reset", "--no-stream", "--interval=0"}) stats.WaitWithDefaultTimeout() - Expect(stats).To(ExitWithError()) + Expect(stats).To(ExitWithError(125, "invalid interval, must be a positive number greater zero")) }) It("podman stats with interval", func() { diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go index 5fad53c510..45945f605b 100644 --- a/test/e2e/system_df_test.go +++ b/test/e2e/system_df_test.go @@ -95,8 +95,7 @@ var _ = Describe("podman system df", func() { It("podman system df --format with --verbose", func() { session := podmanTest.Podman([]string{"system", "df", "--format", "json", "--verbose"}) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) - Expect(session.ErrorToString()).To(Equal("Error: cannot combine --format and --verbose flags")) + Expect(session).To(ExitWithError(125, "Error: cannot combine --format and --verbose flags")) }) It("podman system df --format json", func() {