Skip to content

Commit

Permalink
test: disable artifacts cache with composefs
Browse files Browse the repository at this point in the history
layers restored from a tarball won't be converted to composefs so
disable the cache when using composefs.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jul 24, 2024
1 parent 8403f4c commit fef125c
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") != "" {
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit fef125c

Please sign in to comment.