Skip to content

Commit

Permalink
test/e2e: fix Cleanup()
Browse files Browse the repository at this point in the history
Only check exit codes last, othwerwise in case of errors it will return
early and miss other commands.
Also explicitly stop before rm, rm is not working in all cases (containers#18180).

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
  • Loading branch information
Luap99 committed Apr 13, 2023
1 parent 4c2b091 commit 6dbb60f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/e2e/common_test.go
Expand Up @@ -561,6 +561,11 @@ func (p *PodmanTestIntegration) Quadlet(args []string, sourceDir string) *Podman

// Cleanup cleans up the temporary store
func (p *PodmanTestIntegration) Cleanup() {
// first stop everything, rm -fa is unreliable
// https://github.com/containers/podman/issues/18180
stop := p.Podman([]string{"stop", "--all", "-t", "0"})
stop.WaitWithDefaultTimeout()

// Remove all pods...
podrm := p.Podman([]string{"pod", "rm", "-fa", "-t", "0"})
podrm.WaitWithDefaultTimeout()
Expand All @@ -569,10 +574,6 @@ func (p *PodmanTestIntegration) Cleanup() {
rmall := p.Podman([]string{"rm", "-fa", "-t", "0"})
rmall.WaitWithDefaultTimeout()

// make sure to only check exit code after both commands ran otherwise we leak when pod rm fails
Expect(podrm).To(Exit(0))
Expect(rmall).To(Exit(0))

p.StopRemoteService()

// FIXME: something is causing errors in rootless netns cleanup
Expand All @@ -599,6 +600,12 @@ func (p *PodmanTestIntegration) Cleanup() {

// Clean up the registries configuration file ENV variable set in Create
resetRegistriesConfigEnv()

// Make sure to only check exit codes after all cleanup is done.
// An error would cause it to stop and return early otherwise.
Expect(stop).To(Exit(0))
Expect(podrm).To(Exit(0))
Expect(rmall).To(Exit(0))
}

// CleanupVolume cleans up the temporary store
Expand Down

0 comments on commit 6dbb60f

Please sign in to comment.