From df011f4377cc8d5b0d485bbd4b60ff4d872fedcd Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 12 Sep 2023 17:26:25 -0600 Subject: [PATCH] e2e: more ExitCleanly(): manual test fixes Commit 2 of 2: manual fixes to get tests to pass. Mostly adding "-q", but in some cases reverting back to Exit(0) with progress-message checks. Plus, fix a typo in an error message Signed-off-by: Ed Santiago --- cmd/podman/farm/remove.go | 2 +- test/e2e/exec_test.go | 7 ++++--- test/e2e/farm_test.go | 4 +++- test/e2e/healthcheck_run_test.go | 4 ++-- test/e2e/images_test.go | 4 ++-- test/e2e/import_test.go | 28 ++++++++++++++++++---------- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cmd/podman/farm/remove.go b/cmd/podman/farm/remove.go index a0f48e80f6..c801e407ff 100644 --- a/cmd/podman/farm/remove.go +++ b/cmd/podman/farm/remove.go @@ -67,7 +67,7 @@ func rm(cmd *cobra.Command, args []string) error { deletedFarms := []string{} for _, k := range args { if _, ok := cfg.Farms.List[k]; !ok { - logrus.Warnf("farm %q doesn't exists; nothing to remove", k) + logrus.Warnf("farm %q doesn't exist; nothing to remove", k) continue } delete(cfg.Farms.List, k) diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 637fbd90fb..da47c192ce 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -312,7 +312,8 @@ var _ = Describe("Podman exec", func() { It("podman exec terminal doesn't hang", FlakeAttempts(3), func() { setup := podmanTest.Podman([]string{"run", "-dti", "--name", "test1", fedoraMinimal, "sleep", "+Inf"}) setup.WaitWithDefaultTimeout() - Expect(setup).Should(ExitCleanly()) + Expect(setup).Should(Exit(0)) + Expect(setup.ErrorToString()).To(ContainSubstring("The input device is not a TTY. The --tty and --interactive flags might not work properly")) for i := 0; i < 5; i++ { session := podmanTest.Podman([]string{"exec", "-ti", "test1", "true"}) @@ -453,7 +454,7 @@ var _ = Describe("Podman exec", func() { Expect(ctr1).Should(ExitCleanly()) imgName := "img1" - commit := podmanTest.Podman([]string{"commit", ctrName1, imgName}) + commit := podmanTest.Podman([]string{"commit", "-q", ctrName1, imgName}) commit.WaitWithDefaultTimeout() Expect(commit).Should(ExitCleanly()) @@ -541,7 +542,7 @@ RUN useradd -u 1000 auser`, fedoraMinimal) Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(secretsString)) - session = podmanTest.Podman([]string{"commit", "secr", "foobar.com/test1-image:latest"}) + session = podmanTest.Podman([]string{"commit", "-q", "secr", "foobar.com/test1-image:latest"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) diff --git a/test/e2e/farm_test.go b/test/e2e/farm_test.go index fc41632b90..9b5b92f4e6 100644 --- a/test/e2e/farm_test.go +++ b/test/e2e/farm_test.go @@ -8,6 +8,7 @@ import ( . "github.com/containers/podman/v4/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" ) func setupContainersConfWithSystemConnections() { @@ -181,8 +182,9 @@ var _ = Describe("podman farm", func() { cmd = []string{"farm", "rm", "farm1", "nonexistent-farm"} session = podmanTest.Podman(cmd) session.WaitWithDefaultTimeout() - Expect(session).Should(ExitCleanly()) + Expect(session).Should(Exit(0)) Expect(session.Out.Contents()).Should(ContainSubstring("Farm \"farm1\" deleted")) + Expect(session.ErrorToString()).Should(ContainSubstring("doesn't exist; nothing to remove")) cfg, err = config.ReadCustomConfig() Expect(err).ShouldNot(HaveOccurred()) diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 083ced7eee..52ce570285 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -65,7 +65,7 @@ var _ = Describe("Podman healthcheck run", func() { It("podman healthcheck from image's config (not container config)", func() { // Regression test for #12226: a health check may be defined in // the container or the container-config of an image. - session := podmanTest.Podman([]string{"create", "--name", "hc", "quay.io/libpod/healthcheck:config-only", "ls"}) + session := podmanTest.Podman([]string{"create", "-q", "--name", "hc", "quay.io/libpod/healthcheck:config-only", "ls"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) hc := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Healthcheck}}", "hc"}) @@ -110,7 +110,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck that should fail", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "quay.io/libpod/badhealthcheck:latest"}) + session := podmanTest.Podman([]string{"run", "-q", "-dt", "--name", "hc", "quay.io/libpod/badhealthcheck:latest"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index dab8c03bc6..7dd3472af5 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -199,7 +199,7 @@ WORKDIR /test // Prevent regressing on issue #7651: error parsing name that includes a digest // component as if were a name that includes tag component. digestPullAndList := func(noneTag bool) { - session := podmanTest.Podman([]string{"pull", ALPINEAMD64DIGEST}) + session := podmanTest.Podman([]string{"pull", "-q", ALPINEAMD64DIGEST}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -217,7 +217,7 @@ WORKDIR /test // the additional image store we're using. Pull the same image by another name to // copy an entry for the image into read-write storage so that the name can be // attached to it. - session := podmanTest.Podman([]string{"pull", ALPINELISTTAG}) + session := podmanTest.Podman([]string{"pull", "-q", ALPINELISTTAG}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) digestPullAndList(false) diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index 066086da1f..bd4e954d05 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -6,6 +6,7 @@ import ( . "github.com/containers/podman/v4/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" ) var _ = Describe("Podman import", func() { @@ -21,7 +22,14 @@ var _ = Describe("Podman import", func() { importImage := podmanTest.Podman([]string{"import", outfile, "foobar.com/imported-image:latest"}) importImage.WaitWithDefaultTimeout() - Expect(importImage).Should(ExitCleanly()) + Expect(importImage).Should(Exit(0)) + if !IsRemote() { + messages := importImage.ErrorToString() + Expect(messages).Should(ContainSubstring("Getting image source signatures")) + Expect(messages).Should(ContainSubstring("Copying blob")) + Expect(messages).Should(ContainSubstring("Writing manifest to image destination")) + Expect(messages).Should(Not(ContainSubstring("level=")), "Unexpected logrus messages in stderr") + } results := podmanTest.Podman([]string{"inspect", "--type", "image", "foobar.com/imported-image:latest"}) results.WaitWithDefaultTimeout() @@ -37,7 +45,7 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", "--os", "testos", "--arch", "testarch", outfile, "foobar.com/imported-image:latest"}) + importImage := podmanTest.Podman([]string{"import", "-q", "--os", "testos", "--arch", "testarch", outfile, "foobar.com/imported-image:latest"}) importImage.WaitWithDefaultTimeout() Expect(importImage).Should(ExitCleanly()) @@ -57,7 +65,7 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", outfile}) + importImage := podmanTest.Podman([]string{"import", "-q", outfile}) importImage.WaitWithDefaultTimeout() Expect(importImage).Should(ExitCleanly()) @@ -76,7 +84,7 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", "--message", "importing container test message", outfile, "imported-image"}) + importImage := podmanTest.Podman([]string{"import", "-q", "--message", "importing container test message", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() Expect(importImage).Should(ExitCleanly()) @@ -95,7 +103,7 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", "--change", "CMD=/bin/bash", outfile, "imported-image"}) + importImage := podmanTest.Podman([]string{"import", "-q", "--change", "CMD=/bin/bash", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() Expect(importImage).Should(ExitCleanly()) @@ -117,7 +125,7 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", "--change", "CMD /bin/sh", outfile, "imported-image"}) + importImage := podmanTest.Podman([]string{"import", "-q", "--change", "CMD /bin/sh", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() Expect(importImage).Should(ExitCleanly()) @@ -139,7 +147,7 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", "--change", "CMD [\"/bin/bash\"]", outfile, "imported-image"}) + importImage := podmanTest.Podman([]string{"import", "-q", "--change", "CMD [\"/bin/bash\"]", outfile, "imported-image"}) importImage.WaitWithDefaultTimeout() Expect(importImage).Should(ExitCleanly()) @@ -161,16 +169,16 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export).Should(ExitCleanly()) - importImage := podmanTest.Podman([]string{"import", "--signature-policy", "/no/such/file", outfile}) + importImage := podmanTest.Podman([]string{"import", "-q", "--signature-policy", "/no/such/file", outfile}) importImage.WaitWithDefaultTimeout() Expect(importImage).To(ExitWithError()) - result := podmanTest.Podman([]string{"import", "--signature-policy", "/etc/containers/policy.json", outfile}) + result := podmanTest.Podman([]string{"import", "-q", "--signature-policy", "/etc/containers/policy.json", outfile}) result.WaitWithDefaultTimeout() if IsRemote() { Expect(result).To(ExitWithError()) Expect(result.ErrorToString()).To(ContainSubstring("unknown flag")) - result := podmanTest.Podman([]string{"import", outfile}) + result := podmanTest.Podman([]string{"import", "-q", outfile}) result.WaitWithDefaultTimeout() } Expect(result).Should(ExitCleanly())