Merge pull request #19923 from edsantiago/e2e_check_stderr__cleanup

e2e: use ExitCleanly() in cleanup_test.go
This commit is contained in:
OpenShift Merge Robot 2023-09-11 21:04:53 +02:00 committed by GitHub
commit 22003cbb8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 25 deletions

View File

@ -1,6 +1,7 @@
package integration
import (
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@ -22,45 +23,45 @@ var _ = Describe("Podman container cleanup", func() {
It("podman cleanup container by id", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
session = podmanTest.Podman([]string{"container", "cleanup", cid})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(cid))
})
It("podman cleanup container by short id", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
shortID := cid[0:10]
session = podmanTest.Podman([]string{"container", "cleanup", shortID})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(shortID))
})
It("podman cleanup container by name", func() {
session := podmanTest.Podman([]string{"create", "--name", "foo", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "cleanup", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal("foo"))
})
It("podman cleanup all containers", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
session = podmanTest.Podman([]string{"container", "cleanup", "--all"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(cid))
})
@ -68,23 +69,23 @@ var _ = Describe("Podman container cleanup", func() {
SkipIfRemote("--latest flag n/a")
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
cid := session.OutputToString()
session = podmanTest.Podman([]string{"container", "cleanup", "--latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(Equal(cid))
})
It("podman cleanup running container", func() {
session := podmanTest.RunTopContainer("running")
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "cleanup", "running"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
@ -95,10 +96,10 @@ var _ = Describe("Podman container cleanup", func() {
SkipIfRootlessCgroupsV1("Pause is not supported in cgroups v1")
session := podmanTest.RunTopContainer("paused")
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"pause", "paused"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"container", "cleanup", "paused"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
@ -108,6 +109,6 @@ var _ = Describe("Podman container cleanup", func() {
// otherwise it fails with container state improper
session = podmanTest.Podman([]string{"unpause", "paused"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session).Should(ExitCleanly())
})
})

View File

@ -198,16 +198,25 @@ func (matcher *exitCleanlyMatcher) Match(actual interface{}) (success bool, err
return false, nil
}
// FIXME: #19809, "failed to connect to syslog" warnings on f38
// FIXME: so, until that is fixed, don't check stderr if containerized
if !Containerized() {
info := GetHostDistributionInfo()
if info.Distribution == "fedora" {
if stderr != "" {
matcher.msg = fmt.Sprintf("Unexpected warnings seen on stderr: %q", stderr)
return false, nil
}
}
// Exit status is 0. Now check for anything on stderr... except:
if Containerized() {
// FIXME: #19809, "failed to connect to syslog" warnings on f38
// FIXME: so, until that is fixed, don't check stderr if containerized
return true, nil
}
info := GetHostDistributionInfo()
if info.Distribution != "fedora" {
// runc on debian:
// FIXME: #11784 - lstat /sys/fs/.../*.scope: ENOENT
// FIXME: #11785 - cannot toggle freezer: cgroups not configured
return true, nil
}
if stderr != "" {
matcher.msg = fmt.Sprintf("Unexpected warnings seen on stderr: %q", stderr)
return false, nil
}
return true, nil