From fb8a124905a347a37b85de014a713f6721f6e714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 23 May 2023 18:14:33 +0200 Subject: [PATCH] In a concurrent removal test, don't remove concurrently with builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test is intended to test concurrent removals, so don't risk a removal breaking a build. Fixes #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č --- test/e2e/rmi_test.go | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 10e9f496f3..535d458ec6 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -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 buildAndRemove(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 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() })