summaryrefslogtreecommitdiff
path: root/test/e2e/common_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-30 21:56:26 +0200
committerGitHub <noreply@github.com>2019-05-30 21:56:26 +0200
commitb5b461ac28629c95795f0dee3fc6c804f2a47186 (patch)
tree21dd4ab48159d6f77570d2ac8e11acec35bc67cb /test/e2e/common_test.go
parent2dcfd3df0b58463b050385c0ccd7929c540bce21 (diff)
parentf610a485c1bca7a78d3b2f70e2005b79668fab2f (diff)
downloadpodman-b5b461ac28629c95795f0dee3fc6c804f2a47186.tar.gz
podman-b5b461ac28629c95795f0dee3fc6c804f2a47186.tar.bz2
podman-b5b461ac28629c95795f0dee3fc6c804f2a47186.zip
Merge pull request #3147 from baude/testimagecache
use imagecaches for local tests
Diffstat (limited to 'test/e2e/common_test.go')
-rw-r--r--test/e2e/common_test.go109
1 files changed, 54 insertions, 55 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 3c7675b35..0a388dc42 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -100,12 +100,23 @@ var _ = SynchronizedBeforeSuite(func() []byte {
}
}
+ // make cache dir
+ if err := os.MkdirAll(ImageCacheDir, 0777); err != nil {
+ fmt.Printf("%q\n", err)
+ os.Exit(1)
+ }
+
for _, image := range CACHE_IMAGES {
if err := podman.CreateArtifact(image); err != nil {
fmt.Printf("%q\n", err)
os.Exit(1)
}
}
+
+ // If running localized tests, the cache dir is created and populated. if the
+ // tests are remote, this is a no-op
+ populateCache(podman)
+
host := GetHostDistributionInfo()
if host.Distribution == "rhel" && strings.HasPrefix(host.Version, "7") {
f, err := os.OpenFile("/proc/sys/user/max_user_namespaces", os.O_WRONLY, 0644)
@@ -136,53 +147,29 @@ func (p *PodmanTestIntegration) Setup() {
p.ArtifactPath = ARTIFACT_DIR
}
-// var _ = BeforeSuite(func() {
-// cwd, _ := os.Getwd()
-// INTEGRATION_ROOT = filepath.Join(cwd, "../../")
-// podman := PodmanTestCreate("/tmp")
-// podman.ArtifactPath = ARTIFACT_DIR
-// if _, err := os.Stat(ARTIFACT_DIR); os.IsNotExist(err) {
-// if err = os.Mkdir(ARTIFACT_DIR, 0777); err != nil {
-// fmt.Printf("%q\n", err)
-// os.Exit(1)
-// }
-// }
-// })
-// for _, image := range CACHE_IMAGES {
-// if err := podman.CreateArtifact(image); err != nil {
-// fmt.Printf("%q\n", err)
-// os.Exit(1)
-// }
-// }
-// host := GetHostDistributionInfo()
-// if host.Distribution == "rhel" && strings.HasPrefix(host.Version, "7") {
-// f, err := os.OpenFile("/proc/sys/user/max_user_namespaces", os.O_WRONLY, 0644)
-// if err != nil {
-// fmt.Println("Unable to enable userspace on RHEL 7")
-// os.Exit(1)
-// }
-// _, err = f.WriteString("15000")
-// if err != nil {
-// fmt.Println("Unable to enable userspace on RHEL 7")
-// os.Exit(1)
-// }
-// f.Close()
-// }
-// path, err := ioutil.TempDir("", "libpodlock")
-// if err != nil {
-// fmt.Println(err)
-// os.Exit(1)
-// }
-// LockTmpDir = path
-// })
-
-var _ = AfterSuite(func() {
- sort.Sort(testResultsSortedLength{testResults})
- fmt.Println("integration timing results")
- for _, result := range testResults {
- fmt.Printf("%s\t\t%f\n", result.name, result.length)
- }
-})
+var _ = SynchronizedAfterSuite(func() {},
+ func() {
+ sort.Sort(testResultsSortedLength{testResults})
+ fmt.Println("integration timing results")
+ for _, result := range testResults {
+ fmt.Printf("%s\t\t%f\n", result.name, result.length)
+ }
+
+ // previous crio-run
+ tempdir, err := CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest := PodmanTestCreate(tempdir)
+
+ if err := os.RemoveAll(podmanTest.CrioRoot); err != nil {
+ fmt.Printf("%q\n", err)
+ }
+
+ // for localized tests, this removes the image cache dir and for remote tests
+ // this is a no-op
+ removeCache()
+ })
// PodmanTestCreate creates a PodmanTestIntegration instance for the tests
func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
@@ -244,12 +231,18 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
os.Setenv("DISABLE_HC_SYSTEMD", "true")
CNIConfigDir := "/etc/cni/net.d"
+ storageFs := STORAGE_FS
+ if rootless.IsRootless() {
+ storageFs = ROOTLESS_STORAGE_FS
+ }
p := &PodmanTestIntegration{
PodmanTest: PodmanTest{
- PodmanBinary: podmanBinary,
- ArtifactPath: ARTIFACT_DIR,
- TempDir: tempDir,
- RemoteTest: remote,
+ PodmanBinary: podmanBinary,
+ ArtifactPath: ARTIFACT_DIR,
+ TempDir: tempDir,
+ RemoteTest: remote,
+ ImageCacheFS: storageFs,
+ ImageCacheDir: ImageCacheDir,
},
ConmonBinary: conmonBinary,
CrioRoot: filepath.Join(tempDir, "crio"),
@@ -304,10 +297,10 @@ func (p *PodmanTestIntegration) CreateArtifact(image string) error {
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
if _, err := os.Stat(destName); os.IsNotExist(err) {
- pull := p.Podman([]string{"pull", image})
+ pull := p.PodmanNoCache([]string{"pull", image})
pull.Wait(90)
- save := p.Podman([]string{"save", "-o", destName, image})
+ save := p.PodmanNoCache([]string{"save", "-o", destName, image})
save.Wait(90)
fmt.Printf("\n")
} else {
@@ -390,7 +383,7 @@ func (p *PodmanTestIntegration) BuildImage(dockerfile, imageName string, layers
dockerfilePath := filepath.Join(p.TempDir, "Dockerfile")
err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
Expect(err).To(BeNil())
- session := p.Podman([]string{"build", "--layers=" + layers, "-t", imageName, "--file", dockerfilePath, p.TempDir})
+ session := p.PodmanNoCache([]string{"build", "--layers=" + layers, "-t", imageName, "--file", dockerfilePath, p.TempDir})
session.Wait(120)
Expect(session.ExitCode()).To(Equal(0))
}
@@ -465,7 +458,7 @@ func (p *PodmanTestIntegration) PullImages(images []string) error {
// PullImage pulls a single image
// TODO should the timeout be configurable?
func (p *PodmanTestIntegration) PullImage(image string) error {
- session := p.Podman([]string{"pull", image})
+ session := p.PodmanNoCache([]string{"pull", image})
session.Wait(60)
Expect(session.ExitCode()).To(Equal(0))
return nil
@@ -508,3 +501,9 @@ func (p *PodmanTestIntegration) RunTopContainerInPod(name, pod string) *PodmanSe
podmanArgs = append(podmanArgs, "-d", ALPINE, "top")
return p.Podman(podmanArgs)
}
+
+func (p *PodmanTestIntegration) ImageExistsInMainStore(idOrName string) bool {
+ results := p.PodmanNoCache([]string{"image", "exists", idOrName})
+ results.WaitWithDefaultTimeout()
+ return Expect(results.ExitCode()).To(Equal(0))
+}