Skip to content

Commit

Permalink
test/e2e: fix CleanupVolume/Secrets()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Luap99 committed May 2, 2023
1 parent bc1ed07 commit c5922cc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
18 changes: 8 additions & 10 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 0 additions & 8 deletions test/e2e/volume_prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -188,7 +182,5 @@ var _ = Describe("Podman volume prune", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToStringArray()).To(BeEmpty())

podmanTest.Cleanup()
})
})
2 changes: 0 additions & 2 deletions test/e2e/volume_rm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c5922cc

Please sign in to comment.