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 <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2024-07-16 10:07:05 +02:00
parent 8403f4c33f
commit fef125c7b1
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
1 changed files with 33 additions and 14 deletions

View File

@ -400,16 +400,17 @@ func imageTarPath(image string) string {
return filepath.Join(cacheDir, imageCacheName) return filepath.Join(cacheDir, imageCacheName)
} }
// createArtifact creates a cached image tarball in a local directory func (p *PodmanTestIntegration) pullImage(image string, toCache bool) {
func (p *PodmanTestIntegration) createArtifact(image string) { if toCache {
if os.Getenv("NO_TEST_CACHE") != "" { oldRoot := p.Root
return p.Root = p.ImageCacheDir
defer func() {
p.Root = oldRoot
}()
} }
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++ { for try := 0; try < 3; try++ {
pull := p.PodmanNoCache([]string{"pull", image}) podmanSession := p.PodmanBase([]string{"pull", image}, toCache, true)
pull := PodmanSessionIntegration{podmanSession}
pull.Wait(440) pull.Wait(440)
if pull.ExitCode() == 0 { if pull.ExitCode() == 0 {
break break
@ -421,6 +422,18 @@ func (p *PodmanTestIntegration) createArtifact(image string) {
GinkgoWriter.Println("Will wait and retry") GinkgoWriter.Println("Will wait and retry")
time.Sleep(time.Duration(try+1) * 5 * time.Second) 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") != "" {
return
}
destName := imageTarPath(image)
if _, err := os.Stat(destName); os.IsNotExist(err) {
GinkgoWriter.Printf("Caching %s at %s...\n", image, destName)
p.pullImage(image, false)
save := p.PodmanNoCache([]string{"save", "-o", destName, image}) save := p.PodmanNoCache([]string{"save", "-o", destName, image})
save.Wait(90) save.Wait(90)
@ -1036,9 +1049,15 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
func populateCache(podman *PodmanTestIntegration) { func populateCache(podman *PodmanTestIntegration) {
for _, image := range CACHE_IMAGES { for _, image := range CACHE_IMAGES {
// 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) err := podman.RestoreArtifactToCache(image)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }
}
// logformatter uses this to recognize the first test // logformatter uses this to recognize the first test
GinkgoWriter.Printf("-----------------------------\n") GinkgoWriter.Printf("-----------------------------\n")
} }