From cfd9f74a2a539cf7d1f5fe3022fdf80e281098f0 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 13 Apr 2023 10:55:52 +0200 Subject: [PATCH] test/e2e: fix Cleanup() 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 (#18180). Signed-off-by: Paul Holzinger --- test/e2e/common_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index b056c263ad..53ff69292c 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -560,6 +560,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() @@ -568,16 +573,18 @@ 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() // Nuke tempdir p.removeCache(p.TempDir) // 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), "command: %v", stop.Command.Args) + Expect(podrm).To(Exit(0), "command: %v", podrm.Command.Args) + Expect(rmall).To(Exit(0), "command: %v", rmall.Command.Args) } // CleanupVolume cleans up the temporary store