Skip to content

Commit

Permalink
In a concurrent removal test, don't remove concurrently with builds
Browse files Browse the repository at this point in the history
This test is intended to test concurrent removals, so don't
risk a removal breaking a build.

Fixes containers#18659 .

(The sitaution that removals can break a build WIP is a real
problem that should be fixed, but that's not a target of this test.)

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed May 23, 2023
1 parent c894a12 commit fb8a124
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions test/e2e/rmi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,33 @@ RUN find $LOCAL
podmanTest.AddImageToRWStore(CIRROS_IMAGE)
var wg sync.WaitGroup

buildAndRemove := func(i int) {
defer GinkgoRecover()
defer wg.Done()
imageName := fmt.Sprintf("rmtest:%d", i)
containerfile := fmt.Sprintf(`FROM %s
RUN touch %s`, CIRROS_IMAGE, imageName)

podmanTest.BuildImage(containerfile, imageName, "false")
session := podmanTest.Podman([]string{"rmi", "-f", imageName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
// Prepare images
wg.Add(10)
for i := 0; i < 10; i++ {
go func(i int) {
defer GinkgoRecover()
defer wg.Done()
imageName := fmt.Sprintf("rmtest:%d", i)
containerfile := fmt.Sprintf(`FROM %s
RUN touch %s`, CIRROS_IMAGE, imageName)

podmanTest.BuildImage(containerfile, imageName, "false")
}(i)
}
wg.Wait()

// A herd of concurrent removals
wg.Add(10)
for i := 0; i < 10; i++ {
go buildAndRemove(i)
go func(i int) {
defer GinkgoRecover()
defer wg.Done()

imageName := fmt.Sprintf("rmtest:%d", i)
session := podmanTest.Podman([]string{"rmi", "-f", imageName})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
}(i)
}
wg.Wait()
})
Expand Down

0 comments on commit fb8a124

Please sign in to comment.