From fef125c7b1f31dfa6be6751849f08f080bb7c293 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 16 Jul 2024 10:07:05 +0200 Subject: [PATCH] test: disable artifacts cache with composefs layers restored from a tarball won't be converted to composefs so disable the cache when using composefs. Signed-off-by: Giuseppe Scrivano --- test/e2e/common_test.go | 47 +++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 5e0d1df72b..865af505e9 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -400,6 +400,30 @@ func imageTarPath(image string) string { return filepath.Join(cacheDir, imageCacheName) } +func (p *PodmanTestIntegration) pullImage(image string, toCache bool) { + if toCache { + oldRoot := p.Root + p.Root = p.ImageCacheDir + defer func() { + p.Root = oldRoot + }() + } + for try := 0; try < 3; try++ { + podmanSession := p.PodmanBase([]string{"pull", image}, toCache, true) + pull := PodmanSessionIntegration{podmanSession} + pull.Wait(440) + if pull.ExitCode() == 0 { + break + } + if try == 2 { + Expect(pull).Should(Exit(0), "Failed after many retries") + } + + GinkgoWriter.Println("Will wait and retry") + time.Sleep(time.Duration(try+1) * 5 * time.Second) + } +} + // createArtifact creates a cached image tarball in a local directory func (p *PodmanTestIntegration) createArtifact(image string) { if os.Getenv("NO_TEST_CACHE") != "" { @@ -408,19 +432,8 @@ func (p *PodmanTestIntegration) createArtifact(image string) { destName := imageTarPath(image) if _, err := os.Stat(destName); os.IsNotExist(err) { GinkgoWriter.Printf("Caching %s at %s...\n", image, destName) - for try := 0; try < 3; try++ { - pull := p.PodmanNoCache([]string{"pull", image}) - pull.Wait(440) - if pull.ExitCode() == 0 { - break - } - if try == 2 { - Expect(pull).Should(Exit(0), "Failed after many retries") - } - GinkgoWriter.Println("Will wait and retry") - time.Sleep(time.Duration(try+1) * 5 * time.Second) - } + p.pullImage(image, false) save := p.PodmanNoCache([]string{"save", "-o", destName, image}) save.Wait(90) @@ -1036,8 +1049,14 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error { func populateCache(podman *PodmanTestIntegration) { for _, image := range CACHE_IMAGES { - err := podman.RestoreArtifactToCache(image) - Expect(err).ToNot(HaveOccurred()) + // FIXME: Remove this hack once composefs can be used with images + // pulled from sources other than a registry. + if strings.Contains(podman.StorageOptions, "overlay.use_composefs=true") { + podman.pullImage(image, true) + } else { + err := podman.RestoreArtifactToCache(image) + Expect(err).ToNot(HaveOccurred()) + } } // logformatter uses this to recognize the first test GinkgoWriter.Printf("-----------------------------\n")