test/e2e: fix CleanupVolume/Secrets()

Just like Cleanup() they should check the error codes.
While doing this it was clear that some volume tests were calling
Cleanup() twice so remove this.

Instead make sure they call Cleanup() themselves so callers only need to
do one call. This is required because we cannot use Expect().To() before
doing all the cleanup. An error causes panic does results in an early
return thus missing potentially important cleanup.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-04-14 11:47:41 +02:00
parent bc1ed07b56
commit c5922cc6f0
4 changed files with 8 additions and 22 deletions

View File

@ -602,28 +602,26 @@ func (p *PodmanTestIntegration) Cleanup() {
Expect(rmall).To(Exit(0), "command: %v\nstdout: %s\nstderr: %s", rmall.Command.Args, rmall.OutputToString(), rmall.ErrorToString())
}
// CleanupVolume cleans up the temporary store
// CleanupVolume cleans up the volumes and containers.
// This already calls Cleanup() internally.
func (p *PodmanTestIntegration) CleanupVolume() {
// Remove all containers
session := p.Podman([]string{"volume", "rm", "-fa"})
session.Wait(90)
session.WaitWithDefaultTimeout()
p.Cleanup()
Expect(session).To(Exit(0), "command: %v\nstdout: %s\nstderr: %s", session.Command.Args, session.OutputToString(), session.ErrorToString())
}
// CleanupSecret cleans up the temporary store
// CleanupSecret cleans up the secrets and containers.
// This already calls Cleanup() internally.
func (p *PodmanTestIntegration) CleanupSecrets() {
// Remove all containers
session := p.Podman([]string{"secret", "rm", "-a"})
session.Wait(90)
// Stop remove service on secret cleanup
p.StopRemoteService()
// Nuke tempdir
if err := os.RemoveAll(p.TempDir); err != nil {
GinkgoWriter.Printf("%q\n", err)
}
p.Cleanup()
Expect(session).To(Exit(0), "command: %v\nstdout: %s\nstderr: %s", session.Command.Args, session.OutputToString(), session.ErrorToString())
}
// InspectContainerToJSON takes the session output of an inspect

View File

@ -521,8 +521,6 @@ var _ = Describe("Podman prune", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(HaveLen(3))
podmanTest.Cleanup()
})
It("podman system prune --all --external fails", func() {

View File

@ -58,8 +58,6 @@ var _ = Describe("Podman volume prune", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(HaveLen(2))
podmanTest.Cleanup()
})
It("podman prune volume --filter until", func() {
@ -89,8 +87,6 @@ var _ = Describe("Podman volume prune", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(BeEmpty())
podmanTest.Cleanup()
})
It("podman prune volume --filter", func() {
@ -157,8 +153,6 @@ var _ = Describe("Podman volume prune", func() {
session = podmanTest.Podman([]string{"volume", "prune", "--force", "--filter", "label!=testlabel"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
podmanTest.Cleanup()
})
It("podman system prune --volume", func() {
@ -188,7 +182,5 @@ var _ = Describe("Podman volume prune", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(BeEmpty())
podmanTest.Cleanup()
})
})

View File

@ -66,8 +66,6 @@ var _ = Describe("Podman volume rm", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(BeEmpty())
podmanTest.Cleanup()
})
It("podman volume remove bogus", func() {