Merge pull request from sstosh/e2e-imagecachedir

e2e: Avoid hard-coding ImageCacheDir
This commit is contained in:
OpenShift Merge Robot
2023-01-30 07:04:00 -05:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

@ -103,7 +103,8 @@ func TestLibpod(t *testing.T) {
var _ = SynchronizedBeforeSuite(func() []byte {
// make cache dir
if err := os.MkdirAll(ImageCacheDir, 0777); err != nil {
ImageCacheDir = filepath.Join(os.TempDir(), "imagecachedir")
if err := os.MkdirAll(ImageCacheDir, 0700); err != nil {
fmt.Printf("%q\n", err)
os.Exit(1)
}
@ -192,7 +193,7 @@ var _ = SynchronizedAfterSuite(func() {},
}
// for localized tests, this removes the image cache dir and for remote tests
// this is a no-op
podmanTest.removeCache(ImageCacheDir)
podmanTest.removeCache(podmanTest.ImageCacheDir)
// LockTmpDir can already be removed
os.RemoveAll(LockTmpDir)
@ -278,6 +279,9 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
storageFs = os.Getenv("STORAGE_FS")
storageOptions = "--storage-driver " + storageFs
}
ImageCacheDir = filepath.Join(os.TempDir(), "imagecachedir")
p := &PodmanTestIntegration{
PodmanTest: PodmanTest{
PodmanBinary: podmanBinary,

@ -13,7 +13,6 @@ var (
INFRA_IMAGE = "k8s.gcr.io/pause:3.2" //nolint:revive,stylecheck
BB = "quay.io/libpod/busybox:latest"
HEALTHCHECK_IMAGE = "quay.io/libpod/alpine_healthcheck:latest" //nolint:revive,stylecheck
ImageCacheDir = "/tmp/podman/imagecachedir"
fedoraToolbox = "registry.fedoraproject.org/fedora-toolbox:36"
volumeTest = "quay.io/libpod/volume-plugin-test-img:20220623"
@ -25,4 +24,10 @@ var (
// This image has a bogus/invalid seccomp profile which should
// yield a json error when being read.
alpineBogusSeccomp = "quay.io/libpod/alpine-with-bogus-seccomp:label"
// ImageCacheDir is initialized at runtime.
// e.g., filepath.Join(os.TempDir(), "imagecachedir")
// This directory should be used by per-user.
// Note: "ImageCacheDir" has nothing to do with "PODMAN_TEST_IMAGE_CACHE_DIR".
ImageCacheDir = ""
)