Skip to content

Commit

Permalink
test: new option to control load from artifacts
Browse files Browse the repository at this point in the history
add a new env variable NO_TEST_ARTIFACTS to control whether images are
preloaded from the saved artifacts or pulled from the registry.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Jul 16, 2024
1 parent cd85e7b commit 018e86b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,13 @@ func (p *PodmanTestIntegration) pullImage(image string) {
}
}

func canSaveLoadArtifacts() bool {
return os.Getenv("NO_TEST_ARTIFACTS") == ""
}

// createArtifact creates a cached image tarball in a local directory
func (p *PodmanTestIntegration) createArtifact(image string) {
if os.Getenv("NO_TEST_CACHE") != "" {
if os.Getenv("NO_TEST_CACHE") != "" || !canSaveLoadArtifacts() {
return
}
destName := imageTarPath(image)
Expand Down Expand Up @@ -1041,8 +1045,12 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {

func populateCache(podman *PodmanTestIntegration) {
for _, image := range CACHE_IMAGES {
err := podman.RestoreArtifactToCache(image)
Expect(err).ToNot(HaveOccurred())
if canSaveLoadArtifacts() {
err := podman.RestoreArtifactToCache(image)
Expect(err).ToNot(HaveOccurred())
} else {
podman.pullImage(image)
}
}
// logformatter uses this to recognize the first test
GinkgoWriter.Printf("-----------------------------\n")
Expand Down

0 comments on commit 018e86b

Please sign in to comment.