diff options
Diffstat (limited to 'test/e2e')
93 files changed, 1489 insertions, 487 deletions
diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index a843fe7ff..7233d169c 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -26,7 +26,7 @@ var _ = Describe("Podman attach", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index c2f5a592c..b77c48c8e 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -3,9 +3,12 @@ package integration import ( + "math/rand" "net" "os" "os/exec" + "strconv" + "time" "github.com/containers/libpod/pkg/criu" . "github.com/containers/libpod/test/utils" @@ -13,6 +16,16 @@ import ( . "github.com/onsi/gomega" ) +func getRunString(input []string) []string { + // To avoid IP collisions of initialize random seed for random IP addresses + rand.Seed(time.Now().UnixNano()) + ip3 := strconv.Itoa(rand.Intn(230) + GinkgoParallelNode()) + ip4 := strconv.Itoa(rand.Intn(230) + GinkgoParallelNode()) + // CRIU does not work with seccomp correctly on RHEL7 : seccomp=unconfined + runString := []string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", "--ip", "10.88." + ip3 + "." + ip4} + return append(runString, input...) +} + var _ = Describe("Podman checkpoint", func() { var ( tempdir string @@ -28,7 +41,7 @@ var _ = Describe("Podman checkpoint", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() // Check if the runtime implements checkpointing. Currently only // runc's checkpoint/restore implementation is supported. cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "-h") @@ -49,7 +62,6 @@ var _ = Describe("Podman checkpoint", func() { if hostInfo.Distribution == "fedora" && hostInfo.Version < "29" { Skip("Checkpoint/Restore with SELinux only works on Fedora >= 29") } - }) AfterEach(func() { @@ -72,8 +84,8 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint a running container by id", func() { - // CRIU does not work with seccomp correctly on RHEL7 - session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{ALPINE, "top"}) + session := podmanTest.Podman(localRunString) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -94,7 +106,8 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint a running container by name", func() { - session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "test_name", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{"--name", "test_name", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -114,7 +127,8 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman pause a checkpointed container by id", func() { - session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{ALPINE, "top"}) + session := podmanTest.Podman(localRunString) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -151,11 +165,13 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint latest running container", func() { - session1 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "first", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{"--name", "first", ALPINE, "top"}) + session1 := podmanTest.Podman(localRunString) session1.WaitWithDefaultTimeout() Expect(session1.ExitCode()).To(Equal(0)) - session2 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "second", "-d", ALPINE, "top"}) + localRunString = getRunString([]string{"--name", "second", ALPINE, "top"}) + session2 := podmanTest.Podman(localRunString) session2.WaitWithDefaultTimeout() Expect(session2.ExitCode()).To(Equal(0)) @@ -186,11 +202,13 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint all running container", func() { - session1 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "first", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{"--name", "first", ALPINE, "top"}) + session1 := podmanTest.Podman(localRunString) session1.WaitWithDefaultTimeout() Expect(session1.ExitCode()).To(Equal(0)) - session2 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "second", "-d", ALPINE, "top"}) + localRunString = getRunString([]string{"--name", "second", ALPINE, "top"}) + session2 := podmanTest.Podman(localRunString) session2.WaitWithDefaultTimeout() Expect(session2.ExitCode()).To(Equal(0)) @@ -221,8 +239,8 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint container with established tcp connections", func() { - podmanTest.RestoreArtifact(redis) - session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", redis}) + localRunString := getRunString([]string{redis}) + session := podmanTest.Podman(localRunString) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -276,7 +294,8 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint with --leave-running", func() { - session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{ALPINE, "top"}) + session := podmanTest.Podman(localRunString) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -313,7 +332,8 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint and restore container with same IP", func() { - session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "test_name", "-d", ALPINE, "top"}) + localRunString := getRunString([]string{"--name", "test_name", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -348,4 +368,216 @@ var _ = Describe("Podman checkpoint", func() { Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) }) + // This test does the same steps which are necessary for migrating + // a container from one host to another + It("podman checkpoint container with export (migration)", func() { + // CRIU does not work with seccomp correctly on RHEL7 + session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + result := podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited")) + + // Remove all containers to simulate migration + result = podmanTest.Podman([]string{"rm", "-fa"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + + result = podmanTest.Podman([]string{"container", "restore", "-i", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + // Restore container a second time with different name + result = podmanTest.Podman([]string{"container", "restore", "-i", fileName, "-n", "restore_again"}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + result = podmanTest.Podman([]string{"rm", "-fa"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + + // Remove exported checkpoint + os.Remove(fileName) + }) + + It("podman checkpoint and restore container with root file-system changes", func() { + // Start the container + localRunString := getRunString([]string{"--rm", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + // Change the container's root file-system + result := podmanTest.Podman([]string{"exec", "-l", "/bin/sh", "-c", "echo test" + cid + "test > /test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + // Checkpoint the container + result = podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + // Restore the container + result = podmanTest.Podman([]string{"container", "restore", "-i", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.NumberOfContainers()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + // Verify the changes to the container's root file-system + result = podmanTest.Podman([]string{"exec", "-l", "cat", "/test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(ContainSubstring("test" + cid + "test")) + + // Remove exported checkpoint + os.Remove(fileName) + }) + It("podman checkpoint and restore container with root file-system changes using --ignore-rootfs during restore", func() { + // Start the container + localRunString := getRunString([]string{"--rm", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + // Change the container's root file-system + result := podmanTest.Podman([]string{"exec", "-l", "/bin/sh", "-c", "echo test" + cid + "test > /test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + // Checkpoint the container + result = podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + // Restore the container + result = podmanTest.Podman([]string{"container", "restore", "--ignore-rootfs", "-i", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.NumberOfContainers()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + // Verify the changes to the container's root file-system + result = podmanTest.Podman([]string{"exec", "-l", "cat", "/test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(1)) + Expect(result.ErrorToString()).To(ContainSubstring("cat: can't open '/test.output': No such file or directory")) + + // Remove exported checkpoint + os.Remove(fileName) + }) + It("podman checkpoint and restore container with root file-system changes using --ignore-rootfs during checkpoint", func() { + // Start the container + localRunString := getRunString([]string{"--rm", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + // Change the container's root file-system + result := podmanTest.Podman([]string{"exec", "-l", "/bin/sh", "-c", "echo test" + cid + "test > /test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + // Checkpoint the container + result = podmanTest.Podman([]string{"container", "checkpoint", "--ignore-rootfs", "-l", "-e", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + // Restore the container + result = podmanTest.Podman([]string{"container", "restore", "-i", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.NumberOfContainers()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + // Verify the changes to the container's root file-system + result = podmanTest.Podman([]string{"exec", "-l", "cat", "/test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(1)) + Expect(result.ErrorToString()).To(ContainSubstring("cat: can't open '/test.output': No such file or directory")) + + // Remove exported checkpoint + os.Remove(fileName) + }) + + It("podman checkpoint and run exec in restored container", func() { + // Start the container + localRunString := getRunString([]string{"--rm", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + cid := session.OutputToString() + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + // Checkpoint the container + result := podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + // Restore the container + result = podmanTest.Podman([]string{"container", "restore", "-i", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.NumberOfContainers()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + // Exec in the container + result = podmanTest.Podman([]string{"exec", "-l", "/bin/sh", "-c", "echo " + cid + " > /test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + result = podmanTest.Podman([]string{"exec", "-l", "cat", "/test.output"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(ContainSubstring(cid)) + + // Remove exported checkpoint + os.Remove(fileName) + }) }) diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index bf20ac999..e9d274649 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -1,5 +1,3 @@ -// +build !remoteclient - package integration import ( @@ -24,7 +22,7 @@ var _ = Describe("Podman commit", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -174,6 +172,9 @@ var _ = Describe("Podman commit", func() { }) It("podman commit with volume mounts and --include-volumes", func() { + // We need to figure out how volumes are going to work correctly with the remote + // client. This does not currently work. + SkipIfRemote() s := podmanTest.Podman([]string{"run", "--name", "test1", "-v", "/tmp:/foo", "alpine", "date"}) s.WaitWithDefaultTimeout() Expect(s.ExitCode()).To(Equal(0)) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 3c7675b35..7e14f9e06 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -10,6 +10,7 @@ import ( "sort" "strings" "testing" + "time" "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/inspect" @@ -21,6 +22,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" + "github.com/pkg/errors" ) var ( @@ -100,12 +102,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 +149,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 { @@ -205,7 +194,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration { } } conmonBinary := filepath.Join("/usr/libexec/podman/conmon") - altConmonBinary := "/usr/libexec/crio/conmon" + altConmonBinary := "/usr/bin/conmon" if _, err := os.Stat(conmonBinary); os.IsNotExist(err) { conmonBinary = altConmonBinary } @@ -225,11 +214,6 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration { cgroupManager = os.Getenv("CGROUP_MANAGER") } - // Ubuntu doesn't use systemd cgroups - if host.Distribution == "ubuntu" { - cgroupManager = "cgroupfs" - } - ociRuntime := os.Getenv("OCI_RUNTIME") if ociRuntime == "" { var err error @@ -244,12 +228,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 +294,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 { @@ -326,7 +316,7 @@ func (s *PodmanSessionIntegration) InspectImageJSON() []inspect.ImageData { } // InspectContainer returns a container's inspect data in JSON format -func (p *PodmanTestIntegration) InspectContainer(name string) []inspect.ContainerData { +func (p *PodmanTestIntegration) InspectContainer(name string) []libpod.InspectContainerData { cmd := []string{"inspect", name} session := p.Podman(cmd) session.WaitWithDefaultTimeout() @@ -373,6 +363,18 @@ func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionInteg return session, session.ExitCode(), session.OutputToString() } +// RunNginxWithHealthCheck runs the alpine nginx container with an optional name and adds a healthcheck into it +func (p *PodmanTestIntegration) RunNginxWithHealthCheck(name string) (*PodmanSessionIntegration, string) { + var podmanArgs = []string{"run"} + if name != "" { + podmanArgs = append(podmanArgs, "--name", name) + } + podmanArgs = append(podmanArgs, "-dt", "-P", "--health-cmd", "curl http://localhost/", nginx) + session := p.Podman(podmanArgs) + session.WaitWithDefaultTimeout() + return session, session.OutputToString() +} + func (p *PodmanTestIntegration) RunLsContainerInPod(name, pod string) (*PodmanSessionIntegration, int, string) { var podmanArgs = []string{"run", "--pod", pod} if name != "" { @@ -390,7 +392,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 +467,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 @@ -473,8 +475,8 @@ func (p *PodmanTestIntegration) PullImage(image string) error { // InspectContainerToJSON takes the session output of an inspect // container and returns json -func (s *PodmanSessionIntegration) InspectContainerToJSON() []inspect.ContainerData { - var i []inspect.ContainerData +func (s *PodmanSessionIntegration) InspectContainerToJSON() []libpod.InspectContainerData { + var i []libpod.InspectContainerData err := json.Unmarshal(s.Out.Contents(), &i) Expect(err).To(BeNil()) return i @@ -508,3 +510,35 @@ 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)) +} + +func (p *PodmanTestIntegration) RunHealthCheck(cid string) error { + for i := 0; i < 10; i++ { + hc := p.Podman([]string{"healthcheck", "run", cid}) + hc.WaitWithDefaultTimeout() + if hc.ExitCode() == 0 { + return nil + } + // Restart container if it's not running + ps := p.Podman([]string{"ps", "--no-trunc", "--q", "--filter", fmt.Sprintf("id=%s", cid)}) + ps.WaitWithDefaultTimeout() + if ps.ExitCode() == 0 { + if !strings.Contains(ps.OutputToString(), cid) { + fmt.Printf("Container %s is not running, restarting", cid) + restart := p.Podman([]string{"restart", cid}) + restart.WaitWithDefaultTimeout() + if restart.ExitCode() != 0 { + return errors.Errorf("unable to restart %s", cid) + } + } + } + fmt.Printf("Waiting for %s to pass healthcheck\n", cid) + time.Sleep(1 * time.Second) + } + return errors.Errorf("unable to detect %s as running", cid) +} diff --git a/test/e2e/config.go b/test/e2e/config.go index 3fdb9e116..5e0000e09 100644 --- a/test/e2e/config.go +++ b/test/e2e/config.go @@ -7,4 +7,5 @@ var ( infra = "k8s.gcr.io/pause:3.1" BB = "docker.io/library/busybox:latest" healthcheck = "docker.io/libpod/alpine_healthcheck:latest" + ImageCacheDir = "/tmp/podman/imagecachedir" ) diff --git a/test/e2e/config_amd64.go b/test/e2e/config_amd64.go index d02de7a6e..01aa8445a 100644 --- a/test/e2e/config_amd64.go +++ b/test/e2e/config_amd64.go @@ -1,7 +1,9 @@ package integration var ( + STORAGE_FS = "vfs" STORAGE_OPTIONS = "--storage-driver vfs" + ROOTLESS_STORAGE_FS = "vfs" ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs" CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck} nginx = "quay.io/libpod/alpine_nginx:latest" diff --git a/test/e2e/config_ppc64le.go b/test/e2e/config_ppc64le.go index d1737fa6f..569a34efb 100644 --- a/test/e2e/config_ppc64le.go +++ b/test/e2e/config_ppc64le.go @@ -1,7 +1,9 @@ package integration var ( + STORAGE_FS = "overlay" STORAGE_OPTIONS = "--storage-driver overlay" + ROOTLESS_STORAGE_FS = "vfs" ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs" CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, infra, labels} nginx = "quay.io/libpod/alpine_nginx-ppc64le:latest" diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index f8df5d3d0..5e98e73eb 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -28,7 +28,7 @@ var _ = Describe("Podman cp", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -42,14 +42,15 @@ var _ = Describe("Podman cp", func() { srcPath := filepath.Join(podmanTest.RunRoot, "cp_test.txt") dstPath := filepath.Join(podmanTest.RunRoot, "cp_from_container") fromHostToContainer := []byte("copy from host to container") - err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644) - Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"create", ALPINE, "cat", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) name := session.OutputToString() + err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644) + Expect(err).To(BeNil()) + session = podmanTest.Podman([]string{"cp", srcPath, name + ":foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -57,22 +58,27 @@ var _ = Describe("Podman cp", func() { session = podmanTest.Podman([]string{"cp", name + ":foo", dstPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"start", name}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) }) It("podman cp file to dir", func() { srcPath := filepath.Join(podmanTest.RunRoot, "cp_test.txt") dstDir := filepath.Join(podmanTest.RunRoot, "receive") fromHostToContainer := []byte("copy from host to container directory") - err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644) - Expect(err).To(BeNil()) - err = os.Mkdir(dstDir, 0755) - Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foodir/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) name := session.OutputToString() + err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644) + Expect(err).To(BeNil()) + err = os.Mkdir(dstDir, 0755) + Expect(err).To(BeNil()) + session = podmanTest.Podman([]string{"cp", srcPath, name + ":foodir/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -87,14 +93,15 @@ var _ = Describe("Podman cp", func() { It("podman cp dir to dir", func() { testDirPath := filepath.Join(podmanTest.RunRoot, "TestDir") - err := os.Mkdir(testDirPath, 0755) - Expect(err).To(BeNil()) session := podmanTest.Podman([]string{"create", ALPINE, "ls", "/foodir"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) name := session.OutputToString() + err := os.Mkdir(testDirPath, 0755) + Expect(err).To(BeNil()) + session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -105,6 +112,11 @@ var _ = Describe("Podman cp", func() { }) It("podman cp stdin/stdout", func() { + session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + name := session.OutputToString() + testDirPath := filepath.Join(podmanTest.RunRoot, "TestDir") err := os.Mkdir(testDirPath, 0755) Expect(err).To(BeNil()) @@ -112,11 +124,6 @@ var _ = Describe("Podman cp", func() { _, err = cmd.Output() Expect(err).To(BeNil()) - session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foo"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - name := session.OutputToString() - data, err := ioutil.ReadFile("foo.tar.gz") reader := strings.NewReader(string(data)) cmd.Stdin = reader @@ -133,6 +140,10 @@ var _ = Describe("Podman cp", func() { }) It("podman cp tar", func() { + session := podmanTest.Podman([]string{"create", "--name", "testctr", ALPINE, "ls", "-l", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + path, err := os.Getwd() Expect(err).To(BeNil()) testDirPath := filepath.Join(path, "TestDir") @@ -142,10 +153,6 @@ var _ = Describe("Podman cp", func() { _, err = cmd.Output() Expect(err).To(BeNil()) - session := podmanTest.Podman([]string{"create", "--name", "testctr", ALPINE, "ls", "-l", "foo"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"cp", "file.tar", "testctr:/foo/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -158,4 +165,48 @@ var _ = Describe("Podman cp", func() { os.Remove("file.tar") os.RemoveAll(testDirPath) }) + + It("podman cp symlink", func() { + session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + name := session.OutputToString() + + srcPath := filepath.Join(podmanTest.RunRoot, "cp_test.txt") + fromHostToContainer := []byte("copy from host to container") + err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644) + Expect(err).To(BeNil()) + + session = podmanTest.Podman([]string{"exec", name, "ln", "-s", "/tmp", "/test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"cp", "--pause=false", srcPath, name + ":/test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + _, err = os.Stat("/tmp/cp_test.txt") + Expect(err).To(Not(BeNil())) + }) + It("podman cp volume", func() { + session := podmanTest.Podman([]string{"volume", "create", "data"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"create", "-v", "data:/data", "--name", "container1", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + err = ioutil.WriteFile("cp_vol", []byte("copy to the volume"), 0644) + if err != nil { + os.Exit(1) + } + session = podmanTest.Podman([]string{"cp", "cp_vol", "container1" + ":/data/cp_vol1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"cp", "container1" + ":/data/cp_vol1", "cp_vol2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go index 6c4ca1cb8..11301856b 100644 --- a/test/e2e/create_staticip_test.go +++ b/test/e2e/create_staticip_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman create with --ip flag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() // Cleanup the CNI networks used by the tests os.RemoveAll("/var/lib/cni/networks/podman") }) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index f3367337e..e2b4a7cf4 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index 920b920c0..d273f9463 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman diff", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -80,4 +80,18 @@ var _ = Describe("Podman diff", func() { sort.Strings(imageDiff) Expect(imageDiff).To(Equal(containerDiff)) }) + + It("podman diff latest container", func() { + SkipIfRemote() + session := podmanTest.Podman([]string{"run", "--name=diff-test", ALPINE, "touch", "/tmp/diff-test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"diff", "-l"}) + session.WaitWithDefaultTimeout() + containerDiff := session.OutputToStringArray() + sort.Strings(containerDiff) + Expect(session.LineInOutputContains("C /tmp")).To(BeTrue()) + Expect(session.LineInOutputContains("A /tmp/diff-test")).To(BeTrue()) + Expect(session.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index 5ac5c9860..c5eedda3c 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman events", func() { os.Exit(1) } podmanTest = PodmanTestCreate(tempdir) - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 2a10e52b1..6cf78a25c 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -1,5 +1,3 @@ -// +build !remoteclient - package integration import ( @@ -24,7 +22,7 @@ var _ = Describe("Podman exec", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -67,6 +65,8 @@ var _ = Describe("Podman exec", func() { }) It("podman exec simple command using latest", func() { + // the remote client doesn't use latest + SkipIfRemote() setup := podmanTest.RunTopContainer("test1") setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -81,27 +81,35 @@ var _ = Describe("Podman exec", func() { setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"exec", "-l", "--env", "FOO=BAR", "printenv", "FOO"}) + session := podmanTest.Podman([]string{"exec", "--env", "FOO=BAR", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) match, _ := session.GrepString("BAR") Expect(match).Should(BeTrue()) - session = podmanTest.Podman([]string{"exec", "-l", "--env", "PATH=/bin", "printenv", "PATH"}) + session = podmanTest.Podman([]string{"exec", "--env", "PATH=/bin", "test1", "printenv", "PATH"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) match, _ = session.GrepString("/bin") Expect(match).Should(BeTrue()) + }) + + It("podman exec os.Setenv env", func() { + // remote doesn't properly interpret os.Setenv + SkipIfRemote() + setup := podmanTest.RunTopContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) os.Setenv("FOO", "BAR") - session = podmanTest.Podman([]string{"exec", "-l", "--env", "FOO", "printenv", "FOO"}) + session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ = session.GrepString("BAR") + match, _ := session.GrepString("BAR") Expect(match).Should(BeTrue()) os.Unsetenv("FOO") - }) + It("podman exec exit code", func() { setup := podmanTest.RunTopContainer("test1") setup.WaitWithDefaultTimeout() @@ -123,7 +131,6 @@ var _ = Describe("Podman exec", func() { }) It("podman exec with user only in container", func() { - podmanTest.RestoreArtifact(fedoraMinimal) testUser := "test123" setup := podmanTest.Podman([]string{"run", "--name", "test1", "-d", fedoraMinimal, "sleep", "60"}) setup.WaitWithDefaultTimeout() @@ -144,13 +151,13 @@ var _ = Describe("Podman exec", func() { setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"exec", "-l", "--workdir", "/tmp", "pwd"}) + session := podmanTest.Podman([]string{"exec", "--workdir", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) match, _ := session.GrepString("/tmp") Expect(match).Should(BeTrue()) - session = podmanTest.Podman([]string{"exec", "-l", "-w", "/tmp", "pwd"}) + session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) match, _ = session.GrepString("/tmp") @@ -162,12 +169,32 @@ var _ = Describe("Podman exec", func() { setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"exec", "-l", "--workdir", "/missing", "pwd"}) + session := podmanTest.Podman([]string{"exec", "--workdir", "/missing", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(1)) - session = podmanTest.Podman([]string{"exec", "-l", "-w", "/missing", "pwd"}) + session = podmanTest.Podman([]string{"exec", "-w", "/missing", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(1)) }) + + It("podman exec cannot be invoked", func() { + setup := podmanTest.RunTopContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", "test1", "/etc"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(126)) + }) + + It("podman exec command not found", func() { + setup := podmanTest.RunTopContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", "test1", "notthere"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(127)) + }) }) diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go index 71c6c1820..1486427c5 100644 --- a/test/e2e/exists_test.go +++ b/test/e2e/exists_test.go @@ -48,7 +48,6 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(1)) }) It("podman container exists in local storage by name", func() { - SkipIfRemote() setup := podmanTest.RunTopContainer("foobar") setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -58,7 +57,6 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(0)) }) It("podman container exists in local storage by container ID", func() { - SkipIfRemote() setup := podmanTest.RunTopContainer("") setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -69,7 +67,6 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(0)) }) It("podman container exists in local storage by short container ID", func() { - SkipIfRemote() setup := podmanTest.RunTopContainer("") setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -80,14 +77,12 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(0)) }) It("podman container does not exist in local storage", func() { - SkipIfRemote() session := podmanTest.Podman([]string{"container", "exists", "foobar"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(1)) }) It("podman pod exists in local storage by name", func() { - SkipIfRemote() setup, rc, _ := podmanTest.CreatePod("foobar") setup.WaitWithDefaultTimeout() Expect(rc).To(Equal(0)) @@ -97,7 +92,6 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(0)) }) It("podman pod exists in local storage by container ID", func() { - SkipIfRemote() setup, rc, podID := podmanTest.CreatePod("") setup.WaitWithDefaultTimeout() Expect(rc).To(Equal(0)) @@ -107,7 +101,6 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(0)) }) It("podman pod exists in local storage by short container ID", func() { - SkipIfRemote() setup, rc, podID := podmanTest.CreatePod("") setup.WaitWithDefaultTimeout() Expect(rc).To(Equal(0)) @@ -117,6 +110,7 @@ var _ = Describe("Podman image|container exists", func() { Expect(session.ExitCode()).To(Equal(0)) }) It("podman pod does not exist in local storage", func() { + // The exit code for non-existing pod is incorrect (125 vs 1) SkipIfRemote() session := podmanTest.Podman([]string{"pod", "exists", "foobar"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go index 71ddb518a..8406b0e73 100644 --- a/test/e2e/export_test.go +++ b/test/e2e/export_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman export", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index 2f0af7e5f..49d2c12a8 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -4,11 +4,13 @@ package integration import ( "os" + "path/filepath" . "github.com/containers/libpod/test/utils" "github.com/ghodss/yaml" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "k8s.io/api/core/v1" ) var _ = Describe("Podman generate kube", func() { @@ -25,7 +27,7 @@ var _ = Describe("Podman generate kube", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -56,8 +58,15 @@ var _ = Describe("Podman generate kube", func() { kube.WaitWithDefaultTimeout() Expect(kube.ExitCode()).To(Equal(0)) - _, err := yaml.Marshal(kube.OutputToString()) + pod := new(v1.Pod) + err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) + + numContainers := 0 + for range pod.Spec.Containers { + numContainers = numContainers + 1 + } + Expect(numContainers).To(Equal(1)) }) It("podman generate service kube on container", func() { @@ -69,8 +78,11 @@ var _ = Describe("Podman generate kube", func() { kube.WaitWithDefaultTimeout() Expect(kube.ExitCode()).To(Equal(0)) - _, err := yaml.Marshal(kube.OutputToString()) - Expect(err).To(BeNil()) + // TODO - test generated YAML - service produces multiple + // structs. + // pod := new(v1.Pod) + // err := yaml.Unmarshal([]byte(kube.OutputToString()), pod) + // Expect(err).To(BeNil()) }) It("podman generate kube on pod", func() { @@ -85,8 +97,15 @@ var _ = Describe("Podman generate kube", func() { kube.WaitWithDefaultTimeout() Expect(kube.ExitCode()).To(Equal(0)) - _, err := yaml.Marshal(kube.OutputToString()) + pod := new(v1.Pod) + err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) + + numContainers := 0 + for range pod.Spec.Containers { + numContainers = numContainers + 1 + } + Expect(numContainers).To(Equal(1)) }) It("podman generate service kube on pod", func() { @@ -101,7 +120,122 @@ var _ = Describe("Podman generate kube", func() { kube.WaitWithDefaultTimeout() Expect(kube.ExitCode()).To(Equal(0)) - _, err := yaml.Marshal(kube.OutputToString()) + // TODO: How do we test unmarshal with a service? We have two + // structs that need to be unmarshalled... + // _, err := yaml.Marshal(kube.OutputToString()) + // Expect(err).To(BeNil()) + }) + + It("podman generate kube on pod with ports", func() { + podName := "test" + podSession := podmanTest.Podman([]string{"pod", "create", "--name", podName, "-p", "4000:4000", "-p", "5000:5000"}) + podSession.WaitWithDefaultTimeout() + Expect(podSession.ExitCode()).To(Equal(0)) + + ctr1Name := "ctr1" + ctr1Session := podmanTest.Podman([]string{"create", "--name", ctr1Name, "--pod", podName, ALPINE, "top"}) + ctr1Session.WaitWithDefaultTimeout() + Expect(ctr1Session.ExitCode()).To(Equal(0)) + + ctr2Name := "ctr2" + ctr2Session := podmanTest.Podman([]string{"create", "--name", ctr2Name, "--pod", podName, ALPINE, "top"}) + ctr2Session.WaitWithDefaultTimeout() + Expect(ctr2Session.ExitCode()).To(Equal(0)) + + kube := podmanTest.Podman([]string{"generate", "kube", podName}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + pod := new(v1.Pod) + err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) + + foundPort4000 := 0 + foundPort5000 := 0 + foundOtherPort := 0 + for _, ctr := range pod.Spec.Containers { + for _, port := range ctr.Ports { + if port.HostPort == 4000 { + foundPort4000 = foundPort4000 + 1 + } else if port.HostPort == 5000 { + foundPort5000 = foundPort5000 + 1 + } else { + foundOtherPort = foundOtherPort + 1 + } + } + } + Expect(foundPort4000).To(Equal(1)) + Expect(foundPort5000).To(Equal(1)) + Expect(foundOtherPort).To(Equal(0)) + }) + + It("podman generate and reimport kube on pod", func() { + podName := "toppod" + _, rc, _ := podmanTest.CreatePod(podName) + Expect(rc).To(Equal(0)) + + session := podmanTest.Podman([]string{"create", "--pod", podName, "--name", "test1", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session2 := podmanTest.Podman([]string{"create", "--pod", podName, "--name", "test2", ALPINE, "top"}) + session2.WaitWithDefaultTimeout() + Expect(session2.ExitCode()).To(Equal(0)) + + outputFile := filepath.Join(podmanTest.RunRoot, "pod.yaml") + kube := podmanTest.Podman([]string{"generate", "kube", "-f", outputFile, podName}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + session3 := podmanTest.Podman([]string{"pod", "rm", "-af"}) + session3.WaitWithDefaultTimeout() + Expect(session3.ExitCode()).To(Equal(0)) + + session4 := podmanTest.Podman([]string{"play", "kube", outputFile}) + session4.WaitWithDefaultTimeout() + Expect(session4.ExitCode()).To(Equal(0)) + + session5 := podmanTest.Podman([]string{"pod", "ps"}) + session5.WaitWithDefaultTimeout() + Expect(session5.ExitCode()).To(Equal(0)) + Expect(session5.OutputToString()).To(ContainSubstring(podName)) + + session6 := podmanTest.Podman([]string{"ps", "-a"}) + session6.WaitWithDefaultTimeout() + Expect(session6.ExitCode()).To(Equal(0)) + psOut := session6.OutputToString() + Expect(psOut).To(ContainSubstring("test1")) + Expect(psOut).To(ContainSubstring("test2")) + }) + + It("podman generate kube with volume", func() { + vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") + err := os.MkdirAll(vol1, 0755) + Expect(err).To(BeNil()) + + // we need a container name because IDs don't persist after rm/play + ctrName := "test-ctr" + + session1 := podmanTest.Podman([]string{"run", "-d", "--pod", "new:test1", "--name", ctrName, "-v", vol1 + ":/volume/:z", "alpine", "top"}) + session1.WaitWithDefaultTimeout() + Expect(session1.ExitCode()).To(Equal(0)) + + outputFile := filepath.Join(podmanTest.RunRoot, "pod.yaml") + kube := podmanTest.Podman([]string{"generate", "kube", "test1", "-f", outputFile}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + rm := podmanTest.Podman([]string{"pod", "rm", "-f", "test1"}) + rm.WaitWithDefaultTimeout() + Expect(rm.ExitCode()).To(Equal(0)) + + play := podmanTest.Podman([]string{"play", "kube", outputFile}) + play.WaitWithDefaultTimeout() + Expect(play.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.OutputToString()).To(ContainSubstring(vol1)) }) }) diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 940e894bc..5bb040206 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman generate systemd", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 60be86ebc..dafc8a837 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -5,6 +5,7 @@ package integration import ( "fmt" "os" + "time" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" @@ -24,7 +25,8 @@ var _ = Describe("Podman healthcheck run", func() { os.Exit(1) } podmanTest = PodmanTestCreate(tempdir) - podmanTest.RestoreAllArtifacts() + podmanTest.Setup() + podmanTest.SeedImages() }) AfterEach(func() { @@ -42,14 +44,24 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck on valid container", func() { - podmanTest.RestoreArtifact(healthcheck) + Skip("Extremely consistent flake - reenable on debugging") session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", healthcheck}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"}) - hc.WaitWithDefaultTimeout() - Expect(hc.ExitCode()).To(Equal(0)) + exitCode := 999 + + // Buy a little time to get container running + for i := 0; i < 5; i++ { + hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"}) + hc.WaitWithDefaultTimeout() + exitCode = hc.ExitCode() + if exitCode == 0 || i == 4 { + break + } + time.Sleep(1 * time.Second) + } + Expect(exitCode).To(Equal(0)) }) It("podman healthcheck that should fail", func() { @@ -63,7 +75,6 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck on stopped container", func() { - podmanTest.RestoreArtifact(healthcheck) session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", healthcheck, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -84,7 +95,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck should be starting", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--healthcheck-retries", "2", "--healthcheck-command", "\"CMD-SHELL ls /foo || exit 1\"", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) inspect := podmanTest.InspectContainer("hc") @@ -92,7 +103,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck failed checks in start-period should not change status", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--healthcheck-start-period", "2m", "--healthcheck-retries", "2", "--healthcheck-command", "\"CMD-SHELL ls /foo || exit 1\"", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-start-period", "2m", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -113,7 +124,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck failed checks must reach retries before unhealthy ", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--healthcheck-retries", "2", "--healthcheck-command", "\"CMD-SHELL ls /foo || exit 1\"", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -134,7 +145,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck good check results in healthy even in start-period", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--healthcheck-start-period", "2m", "--healthcheck-retries", "2", "--healthcheck-command", "\"CMD-SHELL\" \"ls\" \"||\" \"exit\" \"1\"", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-start-period", "2m", "--health-retries", "2", "--health-cmd", "ls || exit 1", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -147,7 +158,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck single healthy result changes failed to healthy", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--healthcheck-retries", "2", "--healthcheck-command", "\"CMD-SHELL\" \"ls\" \"/foo\" \"||\" \"exit\" \"1\"", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go index 9e519dd9c..231e8b856 100644 --- a/test/e2e/history_test.go +++ b/test/e2e/history_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman history", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 23455163b..4eadc77e7 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "sort" + "strings" . "github.com/containers/libpod/test/utils" "github.com/docker/go-units" @@ -25,7 +26,7 @@ var _ = Describe("Podman images", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -44,14 +45,15 @@ var _ = Describe("Podman images", func() { }) It("podman images with no images prints header", func() { - rmi := podmanTest.Podman([]string{"rmi", "-a"}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", "-a"}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"images"}) + session := podmanTest.PodmanNoCache([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(1)) + Expect(session.LineInOutputContains("REPOSITORY")).To(BeTrue()) }) It("podman image List", func() { @@ -65,15 +67,16 @@ var _ = Describe("Podman images", func() { It("podman images with multiple tags", func() { // tag "docker.io/library/alpine:latest" to "foo:{a,b,c}" - session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"}) + podmanTest.RestoreAllArtifacts() + session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // tag "foo:c" to "bar:{a,b}" - session = podmanTest.Podman([]string{"tag", "foo:c", "bar:a", "bar:b"}) + session = podmanTest.PodmanNoCache([]string{"tag", "foo:c", "bar:a", "bar:b"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // check all previous and the newly tagged images - session = podmanTest.Podman([]string{"images"}) + session = podmanTest.PodmanNoCache([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session.LineInOutputContainsTag("docker.io/library/alpine", "latest") @@ -83,7 +86,7 @@ var _ = Describe("Podman images", func() { session.LineInOutputContainsTag("foo", "c") session.LineInOutputContainsTag("bar", "a") session.LineInOutputContainsTag("bar", "b") - session = podmanTest.Podman([]string{"images", "-qn"}) + session = podmanTest.PodmanNoCache([]string{"images", "-qn"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically("==", 2)) @@ -119,19 +122,20 @@ var _ = Describe("Podman images", func() { }) It("podman images filter by image name", func() { - session := podmanTest.Podman([]string{"images", "-q", ALPINE}) + podmanTest.RestoreAllArtifacts() + session := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(1)) - session = podmanTest.Podman([]string{"tag", ALPINE, "foo:a"}) + session = podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foo:a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"tag", BB, "foo:b"}) + session = podmanTest.PodmanNoCache([]string{"tag", BB, "foo:b"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"images", "-q", "foo"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) @@ -141,24 +145,25 @@ var _ = Describe("Podman images", func() { if podmanTest.RemoteTest { Skip("Does not work on remote client") } - result := podmanTest.Podman([]string{"images", "-q", "-f", "reference=docker.io*"}) + podmanTest.RestoreAllArtifacts() + result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=docker.io*"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) Expect(len(result.OutputToStringArray())).To(Equal(2)) - retapline := podmanTest.Podman([]string{"images", "-f", "reference=a*pine"}) + retapline := podmanTest.PodmanNoCache([]string{"images", "-f", "reference=a*pine"}) retapline.WaitWithDefaultTimeout() Expect(retapline.ExitCode()).To(Equal(0)) Expect(len(retapline.OutputToStringArray())).To(Equal(2)) Expect(retapline.LineInOutputContains("alpine")) - retapline = podmanTest.Podman([]string{"images", "-f", "reference=alpine"}) + retapline = podmanTest.PodmanNoCache([]string{"images", "-f", "reference=alpine"}) retapline.WaitWithDefaultTimeout() Expect(retapline.ExitCode()).To(Equal(0)) Expect(len(retapline.OutputToStringArray())).To(Equal(2)) Expect(retapline.LineInOutputContains("alpine")) - retnone := podmanTest.Podman([]string{"images", "-q", "-f", "reference=bogus"}) + retnone := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=bogus"}) retnone.WaitWithDefaultTimeout() Expect(retnone.ExitCode()).To(Equal(0)) Expect(len(retnone.OutputToStringArray())).To(Equal(0)) @@ -182,14 +187,15 @@ RUN apk update && apk add man if podmanTest.RemoteTest { Skip("Does not work on remote client") } - rmi := podmanTest.Podman([]string{"rmi", "busybox"}) + podmanTest.RestoreAllArtifacts() + rmi := podmanTest.PodmanNoCache([]string{"rmi", "busybox"}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) dockerfile := `FROM docker.io/library/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") - result := podmanTest.Podman([]string{"images", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "after=docker.io/library/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) Expect(len(result.OutputToStringArray())).To(Equal(0)) @@ -199,14 +205,15 @@ RUN apk update && apk add man if podmanTest.RemoteTest { Skip("Does not work on remote client") } - rmi := podmanTest.Podman([]string{"image", "rm", "busybox"}) + podmanTest.RestoreAllArtifacts() + rmi := podmanTest.PodmanNoCache([]string{"image", "rm", "busybox"}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) dockerfile := `FROM docker.io/library/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") - result := podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result := podmanTest.PodmanNoCache([]string{"image", "list", "-q", "-f", "after=docker.io/library/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) Expect(len(result.OutputToStringArray())).To(Equal(0)) @@ -282,18 +289,19 @@ RUN apk update && apk add man if podmanTest.RemoteTest { Skip("Does not work on remote client") } + podmanTest.RestoreAllArtifacts() dockerfile := `FROM docker.io/library/alpine:latest RUN mkdir hello RUN touch test.txt ENV foo=bar ` podmanTest.BuildImage(dockerfile, "test", "true") - session := podmanTest.Podman([]string{"images"}) + session := podmanTest.PodmanNoCache([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(4)) - session2 := podmanTest.Podman([]string{"images", "--all"}) + session2 := podmanTest.PodmanNoCache([]string{"images", "--all"}) session2.WaitWithDefaultTimeout() Expect(session2.ExitCode()).To(Equal(0)) Expect(len(session2.OutputToStringArray())).To(Equal(6)) @@ -311,4 +319,89 @@ LABEL "com.example.vendor"="Example Vendor" Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) }) + + It("podman with images with no layers", func() { + if podmanTest.RemoteTest { + Skip("Does not work on remote client") + } + + dockerfile := strings.Join([]string{ + `FROM scratch`, + `LABEL org.opencontainers.image.authors="<somefolks@example.org>"`, + `LABEL org.opencontainers.image.created=2019-06-11T19:03:37Z`, + `LABEL org.opencontainers.image.description="This is a test image"`, + `LABEL org.opencontainers.image.title=test`, + `LABEL org.opencontainers.image.vendor="Example.org"`, + `LABEL org.opencontainers.image.version=1`, + }, "\n") + podmanTest.BuildImage(dockerfile, "foo", "true") + + session := podmanTest.Podman([]string{"images", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output := session.OutputToString() + Expect(output).To(Not(MatchRegexp("<missing>"))) + Expect(output).To(Not(MatchRegexp("error"))) + + session = podmanTest.Podman([]string{"image", "tree", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output = session.OutputToString() + Expect(output).To(MatchRegexp("No Image Layers")) + + session = podmanTest.Podman([]string{"history", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output = session.OutputToString() + Expect(output).To(Not(MatchRegexp("<missing>"))) + Expect(output).To(Not(MatchRegexp("error"))) + + session = podmanTest.Podman([]string{"history", "--quiet", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(6)) + + session = podmanTest.Podman([]string{"image", "list", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output = session.OutputToString() + Expect(output).To(Not(MatchRegexp("<missing>"))) + Expect(output).To(Not(MatchRegexp("error"))) + + session = podmanTest.Podman([]string{"image", "list"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output = session.OutputToString() + Expect(output).To(Not(MatchRegexp("<missing>"))) + Expect(output).To(Not(MatchRegexp("error"))) + + session = podmanTest.Podman([]string{"inspect", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output = session.OutputToString() + Expect(output).To(Not(MatchRegexp("<missing>"))) + Expect(output).To(Not(MatchRegexp("error"))) + + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + output = session.OutputToString() + Expect(output).To(Equal("[]")) + }) + + It("podman images --filter readonly", func() { + SkipIfRemote() + dockerfile := `FROM docker.io/library/alpine:latest +` + podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") + result := podmanTest.Podman([]string{"images", "-f", "readonly=true"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + result1 := podmanTest.Podman([]string{"images", "--filter", "readonly=false"}) + result1.WaitWithDefaultTimeout() + Expect(result1.ExitCode()).To(Equal(0)) + Expect(result.OutputToStringArray()).To(Not(Equal(result1.OutputToStringArray()))) + }) + }) diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index e819d819c..84a91a783 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman import", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -62,14 +62,11 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export.ExitCode()).To(Equal(0)) - importImage := podmanTest.Podman([]string{"import", outfile}) + importImage := podmanTest.PodmanNoCache([]string{"import", outfile}) importImage.WaitWithDefaultTimeout() Expect(importImage.ExitCode()).To(Equal(0)) - results := podmanTest.Podman([]string{"images", "-q"}) - results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) - Expect(len(results.OutputToStringArray())).To(Equal(3)) + Expect(podmanTest.ImageExistsInMainStore(importImage.OutputToString())).To(BeTrue()) }) It("podman import with message flag", func() { diff --git a/test/e2e/init_test.go b/test/e2e/init_test.go index 5865930a5..919fe4abf 100644 --- a/test/e2e/init_test.go +++ b/test/e2e/init_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman init", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index 34328828f..790115133 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -107,4 +107,31 @@ var _ = Describe("Podman inspect", func() { Expect(result.ExitCode()).To(Equal(125)) }) + It("podman inspect with mount filters", func() { + SkipIfRemote() + + ctrSession := podmanTest.Podman([]string{"create", "-v", "/tmp:/test1", ALPINE, "top"}) + ctrSession.WaitWithDefaultTimeout() + Expect(ctrSession.ExitCode()).To(Equal(0)) + + inspectSource := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Source}}"}) + inspectSource.WaitWithDefaultTimeout() + Expect(inspectSource.ExitCode()).To(Equal(0)) + Expect(inspectSource.OutputToString()).To(Equal("/tmp")) + + inspectSrc := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Src}}"}) + inspectSrc.WaitWithDefaultTimeout() + Expect(inspectSrc.ExitCode()).To(Equal(0)) + Expect(inspectSrc.OutputToString()).To(Equal("/tmp")) + + inspectDestination := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Destination}}"}) + inspectDestination.WaitWithDefaultTimeout() + Expect(inspectDestination.ExitCode()).To(Equal(0)) + Expect(inspectDestination.OutputToString()).To(Equal("/test1")) + + inspectDst := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Dst}}"}) + inspectDst.WaitWithDefaultTimeout() + Expect(inspectDst.ExitCode()).To(Equal(0)) + Expect(inspectDst.OutputToString()).To(Equal("/test1")) + }) }) diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go index 3286180a4..017fe4a3f 100644 --- a/test/e2e/kill_test.go +++ b/test/e2e/kill_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman kill", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/libpod_suite_remoteclient_test.go b/test/e2e/libpod_suite_remoteclient_test.go index b7fd8537d..c8210f7d1 100644 --- a/test/e2e/libpod_suite_remoteclient_test.go +++ b/test/e2e/libpod_suite_remoteclient_test.go @@ -30,7 +30,13 @@ func SkipIfRootless() { // Podman is the exec call to podman on the filesystem func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration { - podmanSession := p.PodmanBase(args) + podmanSession := p.PodmanBase(args, false) + return &PodmanSessionIntegration{podmanSession} +} + +// PodmanNoCache calls podman with out adding the imagecache +func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { + podmanSession := p.PodmanBase(args, true) return &PodmanSessionIntegration{podmanSession} } @@ -145,6 +151,21 @@ func getVarlinkOptions(p *PodmanTestIntegration, args []string) []string { return podmanOptions } +func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error { + fmt.Printf("Restoring %s...\n", image) + dest := strings.Split(image, "/") + destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1)) + p.CrioRoot = p.ImageCacheDir + restore := p.PodmanNoCache([]string{"load", "-q", "-i", destName}) + restore.WaitWithDefaultTimeout() + return nil +} + +// SeedImages restores all the artifacts into the main store for remote tests +func (p *PodmanTestIntegration) SeedImages() error { + return p.RestoreAllArtifacts() +} + // RestoreArtifact puts the cached image into our test store func (p *PodmanTestIntegration) RestoreArtifact(image string) error { fmt.Printf("Restoring %s...\n", image) @@ -169,3 +190,6 @@ func (p *PodmanTestIntegration) DelayForVarlink() { time.Sleep(1 * time.Second) } } + +func populateCache(podman *PodmanTestIntegration) {} +func removeCache() {} diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 0a85c625d..8d993ee72 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -23,13 +23,19 @@ func SkipIfRootless() { // Podman is the exec call to podman on the filesystem func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration { - podmanSession := p.PodmanBase(args) + podmanSession := p.PodmanBase(args, false) + return &PodmanSessionIntegration{podmanSession} +} + +// PodmanNoCache calls the podman command with no configured imagecache +func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { + podmanSession := p.PodmanBase(args, true) return &PodmanSessionIntegration{podmanSession} } // PodmanAsUser is the exec call to podman on the filesystem with the specified uid/gid and environment func (p *PodmanTestIntegration) PodmanAsUser(args []string, uid, gid uint32, cwd string, env []string) *PodmanSessionIntegration { - podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env) + podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false) return &PodmanSessionIntegration{podmanSession} } @@ -75,9 +81,40 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error { fmt.Printf("Restoring %s...\n", image) dest := strings.Split(image, "/") destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1)) - restore := p.Podman([]string{"load", "-q", "-i", destName}) + restore := p.PodmanNoCache([]string{"load", "-q", "-i", destName}) restore.Wait(90) return nil } + +// RestoreArtifactToCache populates the imagecache from tarballs that were cached earlier +func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error { + fmt.Printf("Restoring %s...\n", image) + dest := strings.Split(image, "/") + destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1)) + + p.CrioRoot = p.ImageCacheDir + restore := p.PodmanNoCache([]string{"load", "-q", "-i", destName}) + restore.WaitWithDefaultTimeout() + return nil +} + func (p *PodmanTestIntegration) StopVarlink() {} func (p *PodmanTestIntegration) DelayForVarlink() {} + +func populateCache(podman *PodmanTestIntegration) { + for _, image := range CACHE_IMAGES { + podman.RestoreArtifactToCache(image) + } +} + +func removeCache() { + // Remove cache dirs + if err := os.RemoveAll(ImageCacheDir); err != nil { + fmt.Printf("%q\n", err) + } +} + +// SeedImages is a no-op for localized testing +func (p *PodmanTestIntegration) SeedImages() error { + return nil +} diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index 0e193640e..9209e1770 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -3,6 +3,7 @@ package integration import ( + "fmt" "os" "path/filepath" @@ -38,7 +39,11 @@ var _ = Describe("Podman load", func() { It("podman load input flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + images := podmanTest.PodmanNoCache([]string{"images"}) + images.WaitWithDefaultTimeout() + fmt.Println(images.OutputToStringArray()) + + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) @@ -46,7 +51,7 @@ var _ = Describe("Podman load", func() { rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "-i", outfile}) + result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -54,7 +59,7 @@ var _ = Describe("Podman load", func() { It("podman load compressed tar file", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) @@ -62,11 +67,11 @@ var _ = Describe("Podman load", func() { Expect(compress.ExitCode()).To(Equal(0)) outfile = outfile + ".gz" - rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "-i", outfile}) + result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -74,15 +79,15 @@ var _ = Describe("Podman load", func() { It("podman load oci-archive image", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "-i", outfile}) + result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -90,15 +95,15 @@ var _ = Describe("Podman load", func() { It("podman load oci-archive with signature", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "--signature-policy", "/etc/containers/policy.json", "-i", outfile}) + result := podmanTest.PodmanNoCache([]string{"load", "--signature-policy", "/etc/containers/policy.json", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -106,15 +111,15 @@ var _ = Describe("Podman load", func() { It("podman load with quiet flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "-q", "-i", outfile}) + result := podmanTest.PodmanNoCache([]string{"load", "-q", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -122,7 +127,7 @@ var _ = Describe("Podman load", func() { It("podman load directory", func() { outdir := filepath.Join(podmanTest.TempDir, "alpine") - save := podmanTest.Podman([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) @@ -136,7 +141,7 @@ var _ = Describe("Podman load", func() { }) It("podman load bogus file", func() { - save := podmanTest.Podman([]string{"load", "-i", "foobar.tar"}) + save := podmanTest.PodmanNoCache([]string{"load", "-i", "foobar.tar"}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).ToNot(Equal(0)) }) @@ -148,75 +153,75 @@ var _ = Describe("Podman load", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") alpVersion := "docker.io/library/alpine:3.2" - pull := podmanTest.Podman([]string{"pull", alpVersion}) + pull := podmanTest.PodmanNoCache([]string{"pull", alpVersion}) pull.WaitWithDefaultTimeout() Expect(pull.ExitCode()).To(Equal(0)) - save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE, alpVersion}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE, alpVersion}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.Podman([]string{"rmi", ALPINE, alpVersion}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE, alpVersion}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "-i", outfile}) + result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - inspect := podmanTest.Podman([]string{"inspect", ALPINE}) + inspect := podmanTest.PodmanNoCache([]string{"inspect", ALPINE}) inspect.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - inspect = podmanTest.Podman([]string{"inspect", alpVersion}) + inspect = podmanTest.PodmanNoCache([]string{"inspect", alpVersion}) inspect.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) It("podman load localhost registry from scratch", func() { outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz") - setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"}) + setup := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", "hello:world"}) + setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.Podman([]string{"rmi", "hello:world"}) + setup = podmanTest.PodmanNoCache([]string{"rmi", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - load := podmanTest.Podman([]string{"load", "-i", outfile}) + load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"images", "hello:world"}) + result := podmanTest.PodmanNoCache([]string{"images", "hello:world"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.LineInOutputContains("localhost")).To(BeTrue()) }) It("podman load localhost registry from scratch and :latest", func() { + podmanTest.RestoreArtifact(fedoraMinimal) outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz") - podmanTest.RestoreArtifact("fedora-minimal:latest") - setup := podmanTest.Podman([]string{"tag", "fedora-minimal", "hello"}) + setup := podmanTest.PodmanNoCache([]string{"tag", "fedora-minimal", "hello"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", "hello"}) + setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", "hello"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.Podman([]string{"rmi", "hello"}) + setup = podmanTest.PodmanNoCache([]string{"rmi", "hello"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - load := podmanTest.Podman([]string{"load", "-i", outfile}) + load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"images", "hello:latest"}) + result := podmanTest.PodmanNoCache([]string{"images", "hello:latest"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.LineInOutputContains("localhost")).To(BeTrue()) @@ -225,23 +230,23 @@ var _ = Describe("Podman load", func() { It("podman load localhost registry from dir", func() { outfile := filepath.Join(podmanTest.TempDir, "load") - setup := podmanTest.Podman([]string{"tag", BB, "hello:world"}) + setup := podmanTest.PodmanNoCache([]string{"tag", BB, "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-dir", "hello:world"}) + setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-dir", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.Podman([]string{"rmi", "hello:world"}) + setup = podmanTest.PodmanNoCache([]string{"rmi", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - load := podmanTest.Podman([]string{"load", "-i", outfile}) + load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"images", "load:latest"}) + result := podmanTest.PodmanNoCache([]string{"images", "load:latest"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.LineInOutputContains("localhost")).To(BeTrue()) @@ -250,17 +255,17 @@ var _ = Describe("Podman load", func() { It("podman load xz compressed image", func() { outfile := filepath.Join(podmanTest.TempDir, "bb.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, BB}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, BB}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) session := SystemExec("xz", []string{outfile}) Expect(session.ExitCode()).To(Equal(0)) - rmi := podmanTest.Podman([]string{"rmi", BB}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", BB}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"load", "-i", outfile + ".xz"}) + result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile + ".xz"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 20d02efcb..d17f60a5d 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman logs", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -218,4 +218,21 @@ var _ = Describe("Podman logs", func() { Expect(results.ExitCode()).To(Equal(0)) Expect(len(results.OutputToStringArray())).To(Equal(3)) }) + + It("podman logs -f two lines", func() { + containerName := "logs-f-rm" + + logc := podmanTest.Podman([]string{"run", "--rm", "--name", containerName, "-dt", ALPINE, "sh", "-c", "echo podman; sleep 1; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"logs", "-f", containerName}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + + // Verify that the cleanup process worked correctly and we can recreate a container with the same name + logc = podmanTest.Podman([]string{"run", "--rm", "--name", containerName, "-dt", ALPINE, "true"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go index b361e0057..61abdf6fc 100644 --- a/test/e2e/mount_test.go +++ b/test/e2e/mount_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman mount", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/namespace_test.go b/test/e2e/namespace_test.go index 28d050be3..88b48cb06 100644 --- a/test/e2e/namespace_test.go +++ b/test/e2e/namespace_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman namespaces", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index c47189a0e..01fb6d91b 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -27,7 +27,7 @@ var _ = Describe("Podman pause", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -249,7 +249,6 @@ var _ = Describe("Podman pause", func() { }) It("Pause a bunch of running containers", func() { - podmanTest.RestoreArtifact(nginx) for i := 0; i < 3; i++ { name := fmt.Sprintf("test%d", i) run := podmanTest.Podman([]string{"run", "-dt", "--name", name, nginx}) @@ -277,7 +276,6 @@ var _ = Describe("Podman pause", func() { }) It("Unpause a bunch of running containers", func() { - podmanTest.RestoreArtifact(nginx) for i := 0; i < 3; i++ { name := fmt.Sprintf("test%d", i) run := podmanTest.Podman([]string{"run", "-dt", "--name", name, nginx}) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go new file mode 100644 index 000000000..a6f59a3da --- /dev/null +++ b/test/e2e/play_kube_test.go @@ -0,0 +1,123 @@ +// +build !remoteclient + +package integration + +import ( + "os" + "path/filepath" + "text/template" + + . "github.com/containers/libpod/test/utils" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var yamlTemplate = ` +apiVersion: v1 +kind: Pod +metadata: + creationTimestamp: "2019-07-17T14:44:08Z" + labels: + app: {{ .Name }} + name: {{ .Name }} +spec: + containers: +{{ with .Containers }} + {{ range . }} + - command: + - {{ .Cmd }} + env: + - name: PATH + value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: TERM + value: xterm + - name: HOSTNAME + - name: container + value: podman + image: {{ .Image }} + name: {{ .Name }} + resources: {} + securityContext: + allowPrivilegeEscalation: true + capabilities: {} + privileged: false + readOnlyRootFilesystem: false + workingDir: / + {{ end }} +{{ end }} +status: {} +` + +type Pod struct { + Name string + Containers []Container +} + +type Container struct { + Cmd string + Image string + Name string +} + +func generateKubeYaml(ctrs []Container, fileName string) error { + f, err := os.Create(fileName) + if err != nil { + return err + } + defer f.Close() + testPod := Pod{"test", ctrs} + + t, err := template.New("pod").Parse(yamlTemplate) + if err != nil { + return err + } + + if err := t.Execute(f, testPod); err != nil { + return err + } + + return nil +} + +var _ = Describe("Podman generate kube", func() { + var ( + tempdir string + err error + podmanTest *PodmanTestIntegration + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanTestCreate(tempdir) + podmanTest.Setup() + podmanTest.SeedImages() + }) + + AfterEach(func() { + podmanTest.Cleanup() + f := CurrentGinkgoTestDescription() + processTestResult(f) + }) + + It("podman play kube test correct command", func() { + ctrName := "testCtr" + ctrCmd := "top" + testContainer := Container{ctrCmd, ALPINE, ctrName} + tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") + + err := generateKubeYaml([]Container{testContainer}, tempFile) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", tempFile}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.OutputToString()).To(ContainSubstring(ctrCmd)) + }) +}) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 84966f77b..2efa36141 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman pod create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 82f35999c..c8763de9f 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -25,8 +25,7 @@ var _ = Describe("Podman pod create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() - podmanTest.RestoreArtifact(infra) + podmanTest.SeedImages() }) AfterEach(func() { @@ -113,12 +112,10 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - podmanTest.RestoreArtifact(nginx) session = podmanTest.Podman([]string{"run", "-d", "--pod", podID, nginx}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - podmanTest.RestoreArtifact(fedoraMinimal) session = podmanTest.Podman([]string{"run", "--pod", podID, fedoraMinimal, "curl", "localhost:80"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -138,7 +135,6 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - podmanTest.RestoreArtifact(fedoraMinimal) session = podmanTest.Podman([]string{"run", "--pod", podID, fedoraMinimal, "/bin/sh", "-c", "'touch /dev/shm/hi'"}) session.WaitWithDefaultTimeout() if session.ExitCode() != 0 { @@ -216,7 +212,6 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - podmanTest.RestoreArtifact(nginx) session = podmanTest.Podman([]string{"run", "-d", "--pod", podID, nginx}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/pod_inspect_test.go b/test/e2e/pod_inspect_test.go index d1a023153..488dd1685 100644 --- a/test/e2e/pod_inspect_test.go +++ b/test/e2e/pod_inspect_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman pod inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_kill_test.go b/test/e2e/pod_kill_test.go index 23a8ea97e..7cf67bbfc 100644 --- a/test/e2e/pod_kill_test.go +++ b/test/e2e/pod_kill_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman pod kill", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_pause_test.go b/test/e2e/pod_pause_test.go index ab828853b..619ee6f12 100644 --- a/test/e2e/pod_pause_test.go +++ b/test/e2e/pod_pause_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman pod pause", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_pod_namespaces.go b/test/e2e/pod_pod_namespaces.go index 9d6321c0e..83c877f5a 100644 --- a/test/e2e/pod_pod_namespaces.go +++ b/test/e2e/pod_pod_namespaces.go @@ -25,8 +25,7 @@ var _ = Describe("Podman pod create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() - podmanTest.RestoreArtifact(infra) + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_prune_test.go b/test/e2e/pod_prune_test.go index 8a4ba2399..da0d425cb 100644 --- a/test/e2e/pod_prune_test.go +++ b/test/e2e/pod_prune_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman pod prune", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go index 8513c6c2e..6d5873caa 100644 --- a/test/e2e/pod_ps_test.go +++ b/test/e2e/pod_ps_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman ps", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_restart_test.go b/test/e2e/pod_restart_test.go index 7b19ecc94..691fe5f0c 100644 --- a/test/e2e/pod_restart_test.go +++ b/test/e2e/pod_restart_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman pod restart", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index 7417a1298..f0689f152 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -3,6 +3,8 @@ package integration import ( "fmt" "os" + "path/filepath" + "strings" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" @@ -23,7 +25,7 @@ var _ = Describe("Podman pod rm", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -40,6 +42,21 @@ var _ = Describe("Podman pod rm", func() { result := podmanTest.Podman([]string{"pod", "rm", podid}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) + + // Also check that we don't leak cgroups + err := filepath.Walk("/sys/fs/cgroup", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if !info.IsDir() { + Expect(err).To(BeNil()) + } + if strings.Contains(info.Name(), podid) { + return fmt.Errorf("leaking cgroup path %s", path) + } + return nil + }) + Expect(err).To(BeNil()) }) It("podman pod rm latest pod", func() { diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go index 967fbc2da..2722cb5b3 100644 --- a/test/e2e/pod_start_test.go +++ b/test/e2e/pod_start_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman pod start", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_stats_test.go b/test/e2e/pod_stats_test.go index 6018b4494..01176f97c 100644 --- a/test/e2e/pod_stats_test.go +++ b/test/e2e/pod_stats_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman pod stats", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go index 9fd9e3ef4..361a63a7f 100644 --- a/test/e2e/pod_stop_test.go +++ b/test/e2e/pod_stop_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman pod stop", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/pod_top_test.go b/test/e2e/pod_top_test.go index 420e4aca9..c313b0675 100644 --- a/test/e2e/pod_top_test.go +++ b/test/e2e/pod_top_test.go @@ -26,7 +26,7 @@ var _ = Describe("Podman top", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index 7cf3e16bf..26c5fd7d0 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -26,7 +26,7 @@ var _ = Describe("Podman port", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -48,12 +48,14 @@ var _ = Describe("Podman port", func() { Expect(result.ExitCode()).ToNot(Equal(0)) }) - It("podman port -l nginx", func() { - podmanTest.RestoreArtifact(nginx) - session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx}) - session.WaitWithDefaultTimeout() + It("podman port -l nginx", func() { + session, cid := podmanTest.RunNginxWithHealthCheck("") Expect(session.ExitCode()).To(Equal(0)) + if err := podmanTest.RunHealthCheck(cid); err != nil { + Fail(err.Error()) + } + result := podmanTest.Podman([]string{"port", "-l"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) @@ -62,11 +64,13 @@ var _ = Describe("Podman port", func() { }) It("podman container port -l nginx", func() { - podmanTest.RestoreArtifact(nginx) - session := podmanTest.Podman([]string{"container", "run", "-dt", "-P", nginx}) - session.WaitWithDefaultTimeout() + session, cid := podmanTest.RunNginxWithHealthCheck("") Expect(session.ExitCode()).To(Equal(0)) + if err := podmanTest.RunHealthCheck(cid); err != nil { + Fail(err.Error()) + } + result := podmanTest.Podman([]string{"container", "port", "-l"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) @@ -75,11 +79,13 @@ var _ = Describe("Podman port", func() { }) It("podman port -l port nginx", func() { - podmanTest.RestoreArtifact(nginx) - session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx}) - session.WaitWithDefaultTimeout() + session, cid := podmanTest.RunNginxWithHealthCheck("") Expect(session.ExitCode()).To(Equal(0)) + if err := podmanTest.RunHealthCheck(cid); err != nil { + Fail(err.Error()) + } + result := podmanTest.Podman([]string{"port", "-l", "80"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) @@ -88,11 +94,13 @@ var _ = Describe("Podman port", func() { }) It("podman port -a nginx", func() { - podmanTest.RestoreArtifact(nginx) - session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx}) - session.WaitWithDefaultTimeout() + session, cid := podmanTest.RunNginxWithHealthCheck("") Expect(session.ExitCode()).To(Equal(0)) + if err := podmanTest.RunHealthCheck(cid); err != nil { + Fail(err.Error()) + } + result := podmanTest.Podman([]string{"port", "-a"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index 377c9f5e1..df0525a79 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -28,7 +28,7 @@ var _ = Describe("Podman prune", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -77,11 +77,12 @@ var _ = Describe("Podman prune", func() { }) It("podman image prune unused images", func() { - prune := podmanTest.Podman([]string{"image", "prune", "-a"}) + podmanTest.RestoreAllArtifacts() + prune := podmanTest.PodmanNoCache([]string{"image", "prune", "-a"}) prune.WaitWithDefaultTimeout() Expect(prune.ExitCode()).To(Equal(0)) - images := podmanTest.Podman([]string{"images", "-aq"}) + images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() // all images are unused, so they all should be deleted! Expect(len(images.OutputToStringArray())).To(Equal(0)) @@ -89,12 +90,13 @@ var _ = Describe("Podman prune", func() { It("podman system image prune unused images", func() { SkipIfRemote() + podmanTest.RestoreAllArtifacts() podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true") - prune := podmanTest.Podman([]string{"system", "prune", "-a", "--force"}) + prune := podmanTest.PodmanNoCache([]string{"system", "prune", "-a", "--force"}) prune.WaitWithDefaultTimeout() Expect(prune.ExitCode()).To(Equal(0)) - images := podmanTest.Podman([]string{"images", "-aq"}) + images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() // all images are unused, so they all should be deleted! Expect(len(images.OutputToStringArray())).To(Equal(0)) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 7edb350f3..efcf44f76 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -27,7 +27,7 @@ var _ = Describe("Podman ps", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -320,4 +320,42 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:1000-1006")) }) + + It("podman ps sync flag", func() { + session := podmanTest.RunTopContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--sync"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToStringArray()[0]).To(Equal(fullCid)) + }) + + It("podman ps filter name regexp", func() { + session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + session2 := podmanTest.Podman([]string{"run", "-d", "--name", "test11", ALPINE, "top"}) + session2.WaitWithDefaultTimeout() + Expect(session2.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc", "--filter", "name=test1"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + output := result.OutputToStringArray() + Expect(len(output)).To(Equal(2)) + + result = podmanTest.Podman([]string{"ps", "-aq", "--no-trunc", "--filter", "name=test1$"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + output = result.OutputToStringArray() + Expect(len(output)).To(Equal(1)) + Expect(output[0]).To(Equal(fullCid)) + }) }) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 4e4e80d56..d6e7b44d1 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman pull", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -39,132 +38,135 @@ var _ = Describe("Podman pull", func() { }) It("podman pull from docker a not existing image", func() { - session := podmanTest.Podman([]string{"pull", "ibetthisdoesntexistthere:foo"}) + session := podmanTest.PodmanNoCache([]string{"pull", "ibetthisdoesntexistthere:foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) }) It("podman pull from docker with tag", func() { - session := podmanTest.Podman([]string{"pull", "busybox:glibc"}) + session := podmanTest.PodmanNoCache([]string{"pull", "busybox:glibc"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "busybox:glibc"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "busybox:glibc"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from docker without tag", func() { - session := podmanTest.Podman([]string{"pull", "busybox"}) + session := podmanTest.PodmanNoCache([]string{"pull", "busybox"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "busybox"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "busybox"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from alternate registry with tag", func() { - session := podmanTest.Podman([]string{"pull", nginx}) + session := podmanTest.PodmanNoCache([]string{"pull", nginx}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", nginx}) + session = podmanTest.PodmanNoCache([]string{"rmi", nginx}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from alternate registry without tag", func() { - session := podmanTest.Podman([]string{"pull", "quay.io/libpod/alpine_nginx"}) + session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/alpine_nginx"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "quay.io/libpod/alpine_nginx"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "quay.io/libpod/alpine_nginx"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull by digest", func() { - session := podmanTest.Podman([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"}) + session := podmanTest.PodmanNoCache([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine:none"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine:none"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull bogus image", func() { - session := podmanTest.Podman([]string{"pull", "umohnani/get-started"}) + session := podmanTest.PodmanNoCache([]string{"pull", "umohnani/get-started"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) }) It("podman pull from docker-archive", func() { + podmanTest.RestoreArtifact(ALPINE) tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"save", "-o", tarfn, "alpine"}) + session := podmanTest.PodmanNoCache([]string{"save", "-o", tarfn, "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) + session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from oci-archive", func() { + podmanTest.RestoreArtifact(ALPINE) tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar") - session := podmanTest.Podman([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"}) + session := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) + session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from local directory", func() { + podmanTest.RestoreArtifact(ALPINE) dirpath := filepath.Join(podmanTest.TempDir, "alpine") os.MkdirAll(dirpath, os.ModePerm) imgPath := fmt.Sprintf("dir:%s", dirpath) - session := podmanTest.Podman([]string{"push", "alpine", imgPath}) + session := podmanTest.PodmanNoCache([]string{"push", "alpine", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", imgPath}) + session = podmanTest.PodmanNoCache([]string{"pull", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull check quiet", func() { podmanTest.RestoreArtifact(ALPINE) - setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"}) + setup := podmanTest.PodmanNoCache([]string{"images", ALPINE, "-q", "--no-trunc"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) shortImageId := strings.Split(setup.OutputToString(), ":")[1] - rmi := podmanTest.Podman([]string{"rmi", ALPINE}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - pull := podmanTest.Podman([]string{"pull", "-q", ALPINE}) + pull := podmanTest.PodmanNoCache([]string{"pull", "-q", ALPINE}) pull.WaitWithDefaultTimeout() Expect(pull.ExitCode()).To(Equal(0)) @@ -172,17 +174,17 @@ var _ = Describe("Podman pull", func() { }) It("podman pull check all tags", func() { - session := podmanTest.Podman([]string{"pull", "--all-tags", "alpine"}) + session := podmanTest.PodmanNoCache([]string{"pull", "--all-tags", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.LineInOuputStartsWith("Pulled Images:")).To(BeTrue()) - session = podmanTest.Podman([]string{"images"}) + session = podmanTest.PodmanNoCache([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 4)) - rmi := podmanTest.Podman([]string{"rmi", "-a", "-f"}) + rmi := podmanTest.PodmanNoCache([]string{"rmi", "-a", "-f"}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 009067482..cf6279f2f 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -8,6 +8,7 @@ import ( "path/filepath" "strings" + "github.com/containers/libpod/pkg/rootless" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -38,22 +39,18 @@ var _ = Describe("Podman push", func() { }) It("podman push to containers/storage", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "containers-storage:busybox:test"}) + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, "containers-storage:busybox:test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", ALPINE}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - - session = podmanTest.Podman([]string{"rmi", "busybox:test"}) + session = podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman push to dir", func() { bbdir := filepath.Join(podmanTest.TempDir, "busybox") - session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, + session := podmanTest.PodmanNoCache([]string{"push", "--remove-signatures", ALPINE, fmt.Sprintf("dir:%s", bbdir)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -63,10 +60,12 @@ var _ = Describe("Podman push", func() { if podmanTest.Host.Arch == "ppc64le" { Skip("No registry image for ppc64le") } + if rootless.IsRootless() { + podmanTest.RestoreArtifact(registry) + } lock := GetPortLock("5000") defer lock.Unlock() - podmanTest.RestoreArtifact(registry) - session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) + session := podmanTest.PodmanNoCache([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -74,7 +73,7 @@ var _ = Describe("Podman push", func() { Skip("Can not start docker registry.") } - push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) + push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) }) @@ -106,8 +105,7 @@ var _ = Describe("Podman push", func() { } lock := GetPortLock("5000") defer lock.Unlock() - podmanTest.RestoreArtifact(registry) - session := podmanTest.Podman([]string{"run", "--entrypoint", "htpasswd", registry, "-Bbn", "podmantest", "test"}) + session := podmanTest.PodmanNoCache([]string{"run", "--entrypoint", "htpasswd", registry, "-Bbn", "podmantest", "test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -117,7 +115,7 @@ var _ = Describe("Podman push", func() { f.WriteString(session.OutputToString()) f.Sync() - session = podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v", + session = podmanTest.PodmanNoCache([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v", strings.Join([]string{authPath, "/auth"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm", "-e", "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd", "-v", strings.Join([]string{certPath, "/certs"}, ":"), "-e", "REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt", @@ -129,36 +127,36 @@ var _ = Describe("Podman push", func() { Skip("Can not start docker registry.") } - session = podmanTest.Podman([]string{"logs", "registry"}) + session = podmanTest.PodmanNoCache([]string{"logs", "registry"}) session.WaitWithDefaultTimeout() - push := podmanTest.Podman([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/tlstest"}) + push := podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/tlstest"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Not(Equal(0))) - push = podmanTest.Podman([]string{"push", "--creds=podmantest:test", "--tls-verify=false", ALPINE, "localhost:5000/tlstest"}) + push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", "--tls-verify=false", ALPINE, "localhost:5000/tlstest"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) setup := SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), "/etc/containers/certs.d/localhost:5000/ca.crt"}) Expect(setup.ExitCode()).To(Equal(0)) - push = podmanTest.Podman([]string{"push", "--creds=podmantest:wrongpasswd", ALPINE, "localhost:5000/credstest"}) + push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:wrongpasswd", ALPINE, "localhost:5000/credstest"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Not(Equal(0))) - push = podmanTest.Podman([]string{"push", "--creds=podmantest:test", "--cert-dir=fakedir", ALPINE, "localhost:5000/certdirtest"}) + push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", "--cert-dir=fakedir", ALPINE, "localhost:5000/certdirtest"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Not(Equal(0))) - push = podmanTest.Podman([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/defaultflags"}) + push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/defaultflags"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) }) It("podman push to docker-archive", func() { tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"push", ALPINE, + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, fmt.Sprintf("docker-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -177,7 +175,7 @@ var _ = Describe("Podman push", func() { Skip("Docker is not available") } - session := podmanTest.Podman([]string{"push", ALPINE, "docker-daemon:alpine:podmantest"}) + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, "docker-daemon:alpine:podmantest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -191,7 +189,7 @@ var _ = Describe("Podman push", func() { It("podman push to oci-archive", func() { tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"push", ALPINE, + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, fmt.Sprintf("oci-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -208,7 +206,7 @@ var _ = Describe("Podman push", func() { setup := SystemExec("ostree", []string{strings.Join([]string{"--repo=", ostreePath}, ""), "init"}) Expect(setup.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"push", ALPINE, strings.Join([]string{"ostree:alp@", ostreePath}, "")}) + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, strings.Join([]string{"ostree:alp@", ostreePath}, "")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -216,7 +214,7 @@ var _ = Describe("Podman push", func() { It("podman push to docker-archive no reference", func() { tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"push", ALPINE, + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -224,7 +222,7 @@ var _ = Describe("Podman push", func() { It("podman push to oci-archive no reference", func() { ociarc := filepath.Join(podmanTest.TempDir, "alp-oci") - session := podmanTest.Podman([]string{"push", ALPINE, + session := podmanTest.PodmanNoCache([]string{"push", ALPINE, fmt.Sprintf("oci-archive:%s", ociarc)}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 7a9a466d8..2b515f53b 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman restart", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 29150d67c..2dbabbf6a 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman rm", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index e034f24cf..1b0329a83 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -41,24 +41,24 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi with fq name", func() { - session := podmanTest.Podman([]string{"rmi", ALPINE}) + session := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman rmi with short name", func() { - session := podmanTest.Podman([]string{"rmi", "alpine"}) + session := podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman rmi all images", func() { - podmanTest.PullImages([]string{nginx}) - session := podmanTest.Podman([]string{"rmi", "-a"}) + podmanTest.RestoreArtifact(nginx) + session := podmanTest.PodmanNoCache([]string{"rmi", "-a"}) session.WaitWithDefaultTimeout() - images := podmanTest.Podman([]string{"images"}) + images := podmanTest.PodmanNoCache([]string{"images"}) images.WaitWithDefaultTimeout() fmt.Println(images.OutputToStringArray()) Expect(session.ExitCode()).To(Equal(0)) @@ -66,23 +66,23 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi all images forcibly with short options", func() { - podmanTest.PullImages([]string{nginx}) - session := podmanTest.Podman([]string{"rmi", "-fa"}) + podmanTest.RestoreArtifact(nginx) + session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman rmi tagged image", func() { - setup := podmanTest.Podman([]string{"images", "-q", ALPINE}) + setup := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"tag", "alpine", "foo:bar", "foo"}) + session := podmanTest.PodmanNoCache([]string{"tag", "alpine", "foo:bar", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - result := podmanTest.Podman([]string{"images", "-q", "foo"}) + result := podmanTest.PodmanNoCache([]string{"images", "-q", "foo"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) @@ -90,95 +90,95 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi image with tags by ID cannot be done without force", func() { - setup := podmanTest.Podman([]string{"images", "-q", ALPINE}) + setup := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) alpineId := setup.OutputToString() - session := podmanTest.Podman([]string{"tag", "alpine", "foo:bar", "foo"}) + session := podmanTest.PodmanNoCache([]string{"tag", "alpine", "foo:bar", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Trying without --force should fail - result := podmanTest.Podman([]string{"rmi", alpineId}) + result := podmanTest.PodmanNoCache([]string{"rmi", alpineId}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).ToNot(Equal(0)) // With --force it should work - resultForce := podmanTest.Podman([]string{"rmi", "-f", alpineId}) + resultForce := podmanTest.PodmanNoCache([]string{"rmi", "-f", alpineId}) resultForce.WaitWithDefaultTimeout() Expect(resultForce.ExitCode()).To(Equal(0)) }) It("podman rmi image that is a parent of another image", func() { SkipIfRemote() - session := podmanTest.Podman([]string{"rmi", "-fa"}) + session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"run", "--name", "c_test", ALPINE, "true"}) + session = podmanTest.PodmanNoCache([]string{"run", "--name", "c_test", ALPINE, "true"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"commit", "-q", "c_test", "test"}) + session = podmanTest.PodmanNoCache([]string{"commit", "-q", "c_test", "test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rm", "c_test"}) + session = podmanTest.PodmanNoCache([]string{"rm", "c_test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", ALPINE}) + session = podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"images", "-q"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(1)) - session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) untaggedImg := session.OutputToStringArray()[1] - session = podmanTest.Podman([]string{"rmi", "-f", untaggedImg}) + session = podmanTest.PodmanNoCache([]string{"rmi", "-f", untaggedImg}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) }) It("podman rmi image that is created from another named imaged", func() { SkipIfRemote() - session := podmanTest.Podman([]string{"rmi", "-fa"}) + session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"create", "--name", "c_test1", ALPINE, "true"}) + session = podmanTest.PodmanNoCache([]string{"create", "--name", "c_test1", ALPINE, "true"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"commit", "-q", "c_test1", "test1"}) + session = podmanTest.PodmanNoCache([]string{"commit", "-q", "c_test1", "test1"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"create", "--name", "c_test2", "test1", "true"}) + session = podmanTest.PodmanNoCache([]string{"create", "--name", "c_test2", "test1", "true"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"commit", "-q", "c_test2", "test2"}) + session = podmanTest.PodmanNoCache([]string{"commit", "-q", "c_test2", "test2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rm", "-a"}) + session = podmanTest.PodmanNoCache([]string{"rm", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "test2"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "test2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"images", "-q"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) @@ -186,7 +186,7 @@ var _ = Describe("Podman rmi", func() { It("podman rmi with cached images", func() { SkipIfRemote() - session := podmanTest.Podman([]string{"rmi", "-fa"}) + session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -205,51 +205,51 @@ var _ = Describe("Podman rmi", func() { ` podmanTest.BuildImage(dockerfile, "test2", "true") - session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) numOfImages := len(session.OutputToStringArray()) - session = podmanTest.Podman([]string{"rmi", "test2"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "test2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(numOfImages - len(session.OutputToStringArray())).To(Equal(2)) - session = podmanTest.Podman([]string{"rmi", "test"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(1)) podmanTest.BuildImage(dockerfile, "test3", "true") - session = podmanTest.Podman([]string{"rmi", ALPINE}) + session = podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "test3"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "test3"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"images", "-q", "-a"}) + session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToString())).To(Equal(0)) }) It("podman rmi -a with no images should be exit 0", func() { - session := podmanTest.Podman([]string{"rmi", "-fa"}) + session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session2 := podmanTest.Podman([]string{"rmi", "-fa"}) + session2 := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) session2.WaitWithDefaultTimeout() Expect(session2.ExitCode()).To(Equal(0)) }) @@ -265,12 +265,12 @@ RUN find $LOCAL ` podmanTest.BuildImage(dockerfile, "test", "true") - session := podmanTest.Podman([]string{"rmi", "-a"}) + session := podmanTest.PodmanNoCache([]string{"rmi", "-a"}) session.WaitWithDefaultTimeout() fmt.Println(session.OutputToString()) Expect(session.ExitCode()).To(Equal(0)) - images := podmanTest.Podman([]string{"images", "-aq"}) + images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() Expect(images.ExitCode()).To(Equal(0)) Expect(len(images.OutputToStringArray())).To(Equal(0)) @@ -279,7 +279,7 @@ RUN find $LOCAL // Don't rerun all tests; just assume that if we get that diagnostic, // we're getting rmi It("podman image rm is the same as rmi", func() { - session := podmanTest.Podman([]string{"image", "rm"}) + session := podmanTest.PodmanNoCache([]string{"image", "rm"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) Expect(session.LineInOutputContains("image name or ID must be specified")) diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go index 0d04c5f03..1fb9f6871 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreArtifact(fedoraMinimal) + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index b20e37794..86790e726 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -4,6 +4,7 @@ package integration import ( "os" + "strings" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" @@ -24,7 +25,7 @@ var _ = Describe("Podman run exit", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.RestoreArtifact(ALPINE) }) AfterEach(func() { @@ -35,18 +36,32 @@ var _ = Describe("Podman run exit", func() { }) It("podman run -d mount cleanup test", func() { + result := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"}) + result.WaitWithDefaultTimeout() + cid := result.OutputToString() + Expect(result.ExitCode()).To(Equal(0)) + mount := SystemExec("mount", nil) Expect(mount.ExitCode()).To(Equal(0)) + Expect(strings.Contains(mount.OutputToString(), cid)) - out1 := mount.OutputToString() - result := podmanTest.Podman([]string{"create", "-dt", ALPINE, "echo", "hello"}) - result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Equal(0)) + pmount := podmanTest.Podman([]string{"mount", "--notruncate"}) + pmount.WaitWithDefaultTimeout() + Expect(strings.Contains(pmount.OutputToString(), cid)) + Expect(pmount.ExitCode()).To(Equal(0)) + + stop := podmanTest.Podman([]string{"stop", cid}) + stop.WaitWithDefaultTimeout() + Expect(stop.ExitCode()).To(Equal(0)) mount = SystemExec("mount", nil) Expect(mount.ExitCode()).To(Equal(0)) + Expect(!strings.Contains(mount.OutputToString(), cid)) + + pmount = podmanTest.Podman([]string{"mount", "--notruncate"}) + pmount.WaitWithDefaultTimeout() + Expect(!strings.Contains(pmount.OutputToString(), cid)) + Expect(pmount.ExitCode()).To(Equal(0)) - out2 := mount.OutputToString() - Expect(out1).To(Equal(out2)) }) }) diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index 42a66865c..87f89b1dd 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run cpu", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go index fac09b78d..cf7ce9cdf 100644 --- a/test/e2e/run_device_test.go +++ b/test/e2e/run_device_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run device", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -85,4 +85,13 @@ var _ = Describe("Podman run device", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) + + It("podman run device host device with --privileged", func() { + if _, err := os.Stat("/dev/kvm"); err != nil { + Skip("/dev/kvm not available") + } + session := podmanTest.Podman([]string{"run", "--privileged", ALPINE, "ls", "/dev/kvm"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go index 0f4dd6742..081fab3fd 100644 --- a/test/e2e/run_dns_test.go +++ b/test/e2e/run_dns_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run dns", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -94,4 +94,22 @@ var _ = Describe("Podman run dns", func() { Expect(session.ExitCode()).To(Equal(0)) Expect(session.LineInOutputContains("foobar")).To(BeTrue()) }) + + It("podman run mutually excludes --dns* and --network", func() { + session := podmanTest.Podman([]string{"run", "--dns=1.2.3.4", "--network", "container:ALPINE", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + + session = podmanTest.Podman([]string{"run", "--dns-opt=1.2.3.4", "--network", "container:ALPINE", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + + session = podmanTest.Podman([]string{"run", "--dns-search=foobar.com", "--network", "none", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + + session = podmanTest.Podman([]string{"run", "--dns=1.2.3.4", "--network", "host", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To((Equal(0))) + }) }) diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index ee9fd1263..b1344a371 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run entrypoint", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreArtifact(ALPINE) + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go index da4cf7ee7..861d6b3b7 100644 --- a/test/e2e/run_exit_test.go +++ b/test/e2e/run_exit_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run exit", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_memory_test.go b/test/e2e/run_memory_test.go index 05d0b7a18..8fe90c8d8 100644 --- a/test/e2e/run_memory_test.go +++ b/test/e2e/run_memory_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman run memory", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 93919925c..31291d373 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman run networking", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -78,7 +78,6 @@ var _ = Describe("Podman run networking", func() { }) It("podman run network expose ports in image metadata", func() { - podmanTest.RestoreArtifact(nginx) session := podmanTest.Podman([]string{"create", "-dt", "-P", nginx}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) @@ -179,6 +178,12 @@ var _ = Describe("Podman run networking", func() { Expect(exec4.OutputToString()).To(ContainSubstring("192.0.2.2 test1")) }) + It("podman run /etc/hosts contains --hostname", func() { + session := podmanTest.Podman([]string{"run", "--rm", "--hostname", "foohostname", ALPINE, "grep", "foohostname", "/etc/hosts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman run network in user created network namespace", func() { SkipIfRootless() if Containerized() { diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go index 51f921bce..e3e86fc66 100644 --- a/test/e2e/run_ns_test.go +++ b/test/e2e/run_ns_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman run ns", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreArtifact(fedoraMinimal) + podmanTest.SeedImages() }) AfterEach(func() { @@ -51,6 +51,15 @@ var _ = Describe("Podman run ns", func() { Expect(session.ExitCode()).To(Not(Equal(0))) }) + It("podman run --cgroup private test", func() { + session := podmanTest.Podman([]string{"run", "--cgroupns=private", fedoraMinimal, "cat", "/proc/self/cgroup"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + output := session.OutputToString() + Expect(output).ToNot(ContainSubstring("slice")) + }) + It("podman run ipcns test", func() { setup := SystemExec("ls", []string{"--inode", "-d", "/dev/shm"}) Expect(setup.ExitCode()).To(Equal(0)) diff --git a/test/e2e/run_passwd_test.go b/test/e2e/run_passwd_test.go index becbc5bfa..bd6a0e036 100644 --- a/test/e2e/run_passwd_test.go +++ b/test/e2e/run_passwd_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run passwd", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go index 16011b2fd..f2c424483 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman privileged container tests", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_restart_test.go b/test/e2e/run_restart_test.go index 9976b45e8..8bbdf2056 100644 --- a/test/e2e/run_restart_test.go +++ b/test/e2e/run_restart_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman run restart containers", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go index 4d2bad49c..a2228411e 100644 --- a/test/e2e/run_selinux_test.go +++ b/test/e2e/run_selinux_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() if !selinux.GetEnabled() { Skip("SELinux not enabled") } diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index e482adb84..1dbac1dc9 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -11,6 +11,7 @@ import ( "syscall" "time" + "github.com/containers/libpod/pkg/rootless" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -33,7 +34,7 @@ var _ = Describe("Podman run with --sig-proxy", func() { } podmanTest = PodmanTestCreate(tmpdir) podmanTest.Setup() - podmanTest.RestoreArtifact(fedoraMinimal) + podmanTest.SeedImages() }) AfterEach(func() { @@ -53,7 +54,9 @@ var _ = Describe("Podman run with --sig-proxy", func() { os.Mkdir(udsDir, 0700) udsPath := filepath.Join(udsDir, "fifo") syscall.Mkfifo(udsPath, 0600) - + if rootless.IsRootless() { + podmanTest.RestoreArtifact(fedoraMinimal) + } _, pid := podmanTest.PodmanPID([]string{"run", "-it", "-v", fmt.Sprintf("%s:/h:Z", udsDir), fedoraMinimal, "bash", "-c", sigCatch}) uds, _ := os.OpenFile(udsPath, os.O_RDONLY|syscall.O_NONBLOCK, 0600) @@ -108,6 +111,9 @@ var _ = Describe("Podman run with --sig-proxy", func() { Specify("signals are not forwarded to container with sig-proxy false", func() { signal := syscall.SIGPOLL + if rootless.IsRootless() { + podmanTest.RestoreArtifact(fedoraMinimal) + } session, pid := podmanTest.PodmanPID([]string{"run", "--name", "test2", "--sig-proxy=false", fedoraMinimal, "bash", "-c", sigCatch}) ok := WaitForContainer(podmanTest) diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go index 318a7a62d..b9698cdd9 100644 --- a/test/e2e/run_staticip_test.go +++ b/test/e2e/run_staticip_test.go @@ -25,7 +25,7 @@ var _ = Describe("Podman run with --ip flag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() // Cleanup the CNI networks used by the tests os.RemoveAll("/var/lib/cni/networks/podman") }) @@ -56,10 +56,10 @@ var _ = Describe("Podman run with --ip flag", func() { }) It("Podman run with specified static IP has correct IP", func() { - result := podmanTest.Podman([]string{"run", "-ti", "--ip", "10.88.64.128", ALPINE, "ip", "addr"}) + result := podmanTest.Podman([]string{"run", "-ti", "--ip", "10.88.63.2", ALPINE, "ip", "addr"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - Expect(result.OutputToString()).To(ContainSubstring("10.88.64.128/16")) + Expect(result.OutputToString()).To(ContainSubstring("10.88.63.2/16")) }) It("Podman run two containers with the same IP", func() { diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index f908fe154..e35c84f5b 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -8,7 +8,9 @@ import ( "net" "os" "path/filepath" + "strconv" "strings" + "syscall" "time" . "github.com/containers/libpod/test/utils" @@ -32,7 +34,7 @@ var _ = Describe("Podman run", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -51,7 +53,6 @@ var _ = Describe("Podman run", func() { It("podman run a container based on a complex local image name", func() { SkipIfRootless() imageName := strings.TrimPrefix(nginx, "quay.io/") - podmanTest.RestoreArtifact(nginx) session := podmanTest.Podman([]string{"run", imageName, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) @@ -59,7 +60,6 @@ var _ = Describe("Podman run", func() { }) It("podman run a container based on on a short name with localhost", func() { - podmanTest.RestoreArtifact(nginx) tag := podmanTest.Podman([]string{"tag", nginx, "localhost/libpod/alpine_nginx:latest"}) tag.WaitWithDefaultTimeout() @@ -73,7 +73,6 @@ var _ = Describe("Podman run", func() { }) It("podman container run a container based on on a short name with localhost", func() { - podmanTest.RestoreArtifact(nginx) tag := podmanTest.Podman([]string{"image", "tag", nginx, "localhost/libpod/alpine_nginx:latest"}) tag.WaitWithDefaultTimeout() @@ -227,9 +226,24 @@ var _ = Describe("Podman run", func() { Expect(match).Should(BeTrue()) }) + It("podman run --host-env environment test", func() { + os.Setenv("FOO", "BAR") + session := podmanTest.Podman([]string{"run", "--rm", "--env-host", ALPINE, "printenv", "FOO"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + match, _ := session.GrepString("BAR") + Expect(match).Should(BeTrue()) + + session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO=BAR1", "--env-host", ALPINE, "printenv", "FOO"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + match, _ = session.GrepString("BAR1") + Expect(match).Should(BeTrue()) + os.Unsetenv("FOO") + }) + It("podman run limits test", func() { SkipIfRootless() - podmanTest.RestoreArtifact(fedoraMinimal) session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "rtprio=99", "--cap-add=sys_nice", fedoraMinimal, "cat", "/proc/self/sched"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -254,6 +268,25 @@ var _ = Describe("Podman run", func() { Expect(session.OutputToString()).To(ContainSubstring("100")) }) + It("podman run limits host test", func() { + SkipIfRemote() + + var l syscall.Rlimit + + err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &l) + Expect(err).To(BeNil()) + + session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "host", fedoraMinimal, "ulimit", "-Hn"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + ulimitCtrStr := strings.TrimSpace(session.OutputToString()) + ulimitCtr, err := strconv.ParseUint(ulimitCtrStr, 10, 0) + Expect(err).To(BeNil()) + + Expect(ulimitCtr).Should(BeNumerically(">=", l.Max)) + }) + It("podman run with cidfile", func() { session := podmanTest.Podman([]string{"run", "--cidfile", tempdir + "cidfile", ALPINE, "ls"}) session.WaitWithDefaultTimeout() @@ -349,11 +382,12 @@ var _ = Describe("Podman run", func() { }) It("podman run tagged image", func() { - tag := podmanTest.Podman([]string{"tag", "busybox", "bb"}) + podmanTest.RestoreArtifact(BB) + tag := podmanTest.PodmanNoCache([]string{"tag", "busybox", "bb"}) tag.WaitWithDefaultTimeout() Expect(tag.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"run", "--rm", "bb", "ls"}) + session := podmanTest.PodmanNoCache([]string{"run", "--rm", "bb", "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -536,15 +570,10 @@ var _ = Describe("Podman run", func() { }) It("podman run with built-in volume image", func() { - podmanTest.RestoreArtifact(redis) session := podmanTest.Podman([]string{"run", "--rm", redis, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", redis}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - dockerfile := `FROM busybox RUN mkdir -p /myvol/data && chown -R mail.0 /myvol VOLUME ["/myvol/data"] @@ -555,10 +584,6 @@ USER mail` session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring("mail root")) - - session = podmanTest.Podman([]string{"rmi", "test"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) }) It("podman run --volumes-from flag", func() { @@ -571,7 +596,6 @@ USER mail` err = ioutil.WriteFile(volFile, []byte(data), 0755) Expect(err).To(BeNil()) - podmanTest.RestoreArtifact(redis) session := podmanTest.Podman([]string{"create", "--volume", vol + ":/myvol", redis, "sh"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -587,7 +611,6 @@ USER mail` }) It("podman run --volumes-from flag with built-in volumes", func() { - podmanTest.RestoreArtifact(redis) session := podmanTest.Podman([]string{"create", redis, "sh"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -641,7 +664,6 @@ USER mail` }) It("podman run findmnt nothing shared", func() { - podmanTest.RestoreArtifact(fedoraMinimal) vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") err := os.MkdirAll(vol1, 0755) Expect(err).To(BeNil()) @@ -657,7 +679,6 @@ USER mail` }) It("podman run findmnt shared", func() { - podmanTest.RestoreArtifact(fedoraMinimal) vol1 := filepath.Join(podmanTest.TempDir, "vol-test1") err := os.MkdirAll(vol1, 0755) Expect(err).To(BeNil()) @@ -675,6 +696,14 @@ USER mail` Expect(isSharedOnly).Should(BeTrue()) }) + It("podman run --mount type=bind,bind-nonrecursive", func() { + SkipIfRootless() + session := podmanTest.Podman([]string{"run", "--mount", "type=bind,bind-nonrecursive,slave,src=/,target=/host", fedoraMinimal, "findmnt", "-nR", "/host"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(1)) + }) + It("podman run --pod automatically", func() { session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", ALPINE, "ls"}) session.WaitWithDefaultTimeout() @@ -720,28 +749,25 @@ USER mail` Expect(session.OutputToString()).To(Not(ContainSubstring("/dev/shm type tmpfs (ro,"))) }) - It("podman run with bad healthcheck interval", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-interval", "0.5s", ALPINE, "top"}) - session.Wait() - Expect(session.ExitCode()).ToNot(Equal(0)) - }) - It("podman run with bad healthcheck retries", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-retries", "0", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--health-cmd", "[\"foo\"]", "--health-retries", "0", ALPINE, "top"}) session.Wait() Expect(session.ExitCode()).ToNot(Equal(0)) + Expect(session.ErrorToString()).To(ContainSubstring("healthcheck-retries must be greater than 0")) }) It("podman run with bad healthcheck timeout", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-timeout", "0s", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--health-cmd", "[\"foo\"]", "--health-timeout", "0s", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).ToNot(Equal(0)) + Expect(session.ErrorToString()).To(ContainSubstring("healthcheck-timeout must be at least 1 second")) }) It("podman run with bad healthcheck start-period", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-start-period", "-1s", ALPINE, "top"}) + session := podmanTest.Podman([]string{"run", "-dt", "--health-cmd", "[\"foo\"]", "--health-start-period", "-1s", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).ToNot(Equal(0)) + Expect(session.ErrorToString()).To(ContainSubstring("healthcheck-start-period must be 0 seconds or greater")) }) It("podman run with --add-host and --no-hosts fails", func() { @@ -765,10 +791,9 @@ USER mail` }) It("podman run with restart-policy always restarts containers", func() { - podmanTest.RestoreArtifact(fedoraMinimal) testDir := filepath.Join(podmanTest.RunRoot, "restart-test") - err := os.Mkdir(testDir, 0755) + err := os.MkdirAll(testDir, 0755) Expect(err).To(BeNil()) aliveFile := filepath.Join(testDir, "running") diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index ce6971cd1..e873f5abe 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -31,7 +31,7 @@ var _ = Describe("Podman UserNS support", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -85,4 +85,19 @@ var _ = Describe("Podman UserNS support", func() { ok, _ := session.GrepString(uid) Expect(ok).To(BeTrue()) }) + + It("podman --userns=container:CTR", func() { + ctrName := "userns-ctr" + session := podmanTest.Podman([]string{"run", "-d", "--uidmap=0:0:1", "--uidmap=1:1:4998", "--name", ctrName, "alpine", "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // runc has an issue and we also need to join the IPC namespace. + session = podmanTest.Podman([]string{"run", "--rm", "--userns=container:" + ctrName, "--ipc=container:" + ctrName, "alpine", "cat", "/proc/self/uid_map"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + ok, _ := session.GrepString("4998") + Expect(ok).To(BeTrue()) + }) }) diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index d031ca143..9e160e73c 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -26,7 +26,7 @@ var _ = Describe("Podman run with volumes", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -63,6 +63,24 @@ var _ = Describe("Podman run with volumes", func() { Expect(found).Should(BeTrue()) Expect(matches[0]).To(ContainSubstring("rw")) Expect(matches[0]).To(ContainSubstring("shared")) + + // Cached is ignored + session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:cached", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + found, matches = session.GrepString("/run/test") + Expect(found).Should(BeTrue()) + Expect(matches[0]).To(ContainSubstring("rw")) + Expect(matches[0]).To(Not(ContainSubstring("cached"))) + + // Delegated is ignored + session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:delegated", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + found, matches = session.GrepString("/run/test") + Expect(found).Should(BeTrue()) + Expect(matches[0]).To(ContainSubstring("rw")) + Expect(matches[0]).To(Not(ContainSubstring("delegated"))) }) It("podman run with --mount flag", func() { diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index f52a2b8fc..4e2cb501e 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -37,7 +37,7 @@ var _ = Describe("podman container runlabel", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -85,6 +85,7 @@ var _ = Describe("podman container runlabel", func() { }) It("podman container runlabel global options", func() { + Skip("Test nonfunctional for podman-in-podman testing") image := "podman-global-test:ls" podmanTest.BuildImage(GlobalDockerfile, image, "false") result := podmanTest.Podman([]string{"--syslog", "--log-level", "debug", "container", "runlabel", "RUN", image}) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index ffb5182d6..be1ede962 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -37,7 +37,7 @@ var _ = Describe("Podman save", func() { It("podman save output flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -45,7 +45,7 @@ var _ = Describe("Podman save", func() { It("podman save oci flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -54,7 +54,7 @@ var _ = Describe("Podman save", func() { Skip("Pipe redirection in ginkgo probably wont work") outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", ALPINE, ">", outfile}) + save := podmanTest.PodmanNoCache([]string{"save", ALPINE, ">", outfile}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -62,7 +62,7 @@ var _ = Describe("Podman save", func() { It("podman save quiet flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "-q", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -70,7 +70,7 @@ var _ = Describe("Podman save", func() { It("podman save bogus image", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.Podman([]string{"save", "-o", outfile, "FOOBAR"}) + save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "FOOBAR"}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Not(Equal(0))) }) @@ -81,7 +81,7 @@ var _ = Describe("Podman save", func() { } outdir := filepath.Join(podmanTest.TempDir, "save") - save := podmanTest.Podman([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -92,7 +92,7 @@ var _ = Describe("Podman save", func() { } outdir := filepath.Join(podmanTest.TempDir, "save") - save := podmanTest.Podman([]string{"save", "--format", "docker-dir", "-o", outdir, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -103,7 +103,7 @@ var _ = Describe("Podman save", func() { } outdir := filepath.Join(podmanTest.TempDir, "save") - save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -111,7 +111,7 @@ var _ = Describe("Podman save", func() { It("podman save bad filename", func() { outdir := filepath.Join(podmanTest.TempDir, "save:colon") - save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) + save := podmanTest.PodmanNoCache([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Not(Equal(0))) }) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 72b083de8..3b1da859c 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -75,8 +75,8 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() + podmanTest.SeedImages() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -168,7 +168,6 @@ registries = ['{{.Host}}:{{.Port}}']` lock := GetPortLock(registryEndpoints[0].Port) defer lock.Unlock() - podmanTest.RestoreArtifact(registry) fakereg := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", fmt.Sprintf("%s:5000", registryEndpoints[0].Port), registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) @@ -196,7 +195,6 @@ registries = ['{{.Host}}:{{.Port}}']` } lock := GetPortLock(registryEndpoints[3].Port) defer lock.Unlock() - podmanTest.RestoreArtifact(registry) registry := podmanTest.Podman([]string{"run", "-d", "--name", "registry3", "-p", fmt.Sprintf("%s:5000", registryEndpoints[3].Port), registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) @@ -207,11 +205,12 @@ registries = ['{{.Host}}:{{.Port}}']` Skip("Can not start docker registry.") } + podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[3].Address()) - push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) - search := podmanTest.Podman([]string{"search", image, "--tls-verify=false"}) + search := podmanTest.PodmanNoCache([]string{"search", image, "--tls-verify=false"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -225,7 +224,6 @@ registries = ['{{.Host}}:{{.Port}}']` lock := GetPortLock(registryEndpoints[4].Port) defer lock.Unlock() - podmanTest.RestoreArtifact(registry) registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%s:5000", registryEndpoints[4].Port), "--name", "registry4", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) registry.WaitWithDefaultTimeout() @@ -235,8 +233,9 @@ registries = ['{{.Host}}:{{.Port}}']` Skip("Can not start docker registry.") } + podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[4].Address()) - push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -246,7 +245,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.setRegistriesConfigEnv(buffer.Bytes()) ioutil.WriteFile(fmt.Sprintf("%s/registry4.conf", tempdir), buffer.Bytes(), 0644) - search := podmanTest.Podman([]string{"search", image}) + search := podmanTest.PodmanNoCache([]string{"search", image}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -264,7 +263,6 @@ registries = ['{{.Host}}:{{.Port}}']` } lock := GetPortLock(registryEndpoints[5].Port) defer lock.Unlock() - podmanTest.RestoreArtifact(registry) registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%s:5000", registryEndpoints[5].Port), "--name", "registry5", registry}) registry.WaitWithDefaultTimeout() @@ -274,8 +272,9 @@ registries = ['{{.Host}}:{{.Port}}']` Skip("Can not start docker registry.") } + podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[5].Address()) - push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -284,7 +283,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.setRegistriesConfigEnv(buffer.Bytes()) ioutil.WriteFile(fmt.Sprintf("%s/registry5.conf", tempdir), buffer.Bytes(), 0644) - search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"}) + search := podmanTest.PodmanNoCache([]string{"search", image, "--tls-verify=true"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -302,7 +301,6 @@ registries = ['{{.Host}}:{{.Port}}']` } lock := GetPortLock(registryEndpoints[6].Port) defer lock.Unlock() - podmanTest.RestoreArtifact(registry) registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%s:5000", registryEndpoints[6].Port), "--name", "registry6", registry}) registry.WaitWithDefaultTimeout() @@ -312,8 +310,9 @@ registries = ['{{.Host}}:{{.Port}}']` Skip("Can not start docker registry.") } + podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[6].Address()) - push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -322,7 +321,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.setRegistriesConfigEnv(buffer.Bytes()) ioutil.WriteFile(fmt.Sprintf("%s/registry6.conf", tempdir), buffer.Bytes(), 0644) - search := podmanTest.Podman([]string{"search", image}) + search := podmanTest.PodmanNoCache([]string{"search", image}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -343,7 +342,6 @@ registries = ['{{.Host}}:{{.Port}}']` lock8 := GetPortLock("6000") defer lock8.Unlock() - podmanTest.RestoreArtifact(registry) registryLocal := podmanTest.Podman([]string{"run", "-d", "--net=host", "-p", fmt.Sprintf("%s:5000", registryEndpoints[7].Port), "--name", "registry7", registry}) registryLocal.WaitWithDefaultTimeout() @@ -361,7 +359,8 @@ registries = ['{{.Host}}:{{.Port}}']` Skip("Can not start docker registry.") } - push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:6000/my-alpine"}) + podmanTest.RestoreArtifact(ALPINE) + push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:6000/my-alpine"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -371,7 +370,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.setRegistriesConfigEnv(buffer.Bytes()) ioutil.WriteFile(fmt.Sprintf("%s/registry8.conf", tempdir), buffer.Bytes(), 0644) - search := podmanTest.Podman([]string{"search", "my-alpine"}) + search := podmanTest.PodmanNoCache([]string{"search", "my-alpine"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index c92da9777..fc1203ed1 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman start", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index 05f24539f..4000ab33a 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -26,7 +26,7 @@ var _ = Describe("Podman stats", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { @@ -65,7 +65,7 @@ var _ = Describe("Podman stats", func() { session := podmanTest.RunTopContainer("") session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "\"{{.Container}}\""}) + session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "\"{{.ID}}\""}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index e201204df..77ab6dbb0 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman stop", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go index 92787f17c..bbbdf30b0 100644 --- a/test/e2e/system_df_test.go +++ b/test/e2e/system_df_test.go @@ -25,7 +25,8 @@ var _ = Describe("podman system df", func() { os.Exit(1) } podmanTest = PodmanTestCreate(tempdir) - podmanTest.RestoreAllArtifacts() + podmanTest.Setup() + podmanTest.SeedImages() }) AfterEach(func() { @@ -55,7 +56,7 @@ var _ = Describe("podman system df", func() { images := strings.Fields(session.OutputToStringArray()[1]) containers := strings.Fields(session.OutputToStringArray()[2]) volumes := strings.Fields(session.OutputToStringArray()[3]) - Expect(images[1]).To(Equal("2")) + Expect(images[1]).To(Equal("9")) Expect(containers[1]).To(Equal("2")) Expect(volumes[2]).To(Equal("1")) }) diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 52efc9fca..91604867d 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -27,7 +27,7 @@ var _ = Describe("Podman systemd", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() systemd_unit_file = `[Unit] Description=redis container [Service] diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go index 26d6dfa75..2b513015b 100644 --- a/test/e2e/tag_test.go +++ b/test/e2e/tag_test.go @@ -33,11 +33,11 @@ var _ = Describe("Podman tag", func() { }) It("podman tag shortname:latest", func() { - session := podmanTest.Podman([]string{"tag", ALPINE, "foobar:latest"}) + session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.Podman([]string{"inspect", "foobar:latest"}) + results := podmanTest.PodmanNoCache([]string{"inspect", "foobar:latest"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() @@ -46,11 +46,11 @@ var _ = Describe("Podman tag", func() { }) It("podman tag shortname", func() { - session := podmanTest.Podman([]string{"tag", ALPINE, "foobar"}) + session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.Podman([]string{"inspect", "foobar:latest"}) + results := podmanTest.PodmanNoCache([]string{"inspect", "foobar:latest"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() @@ -59,11 +59,11 @@ var _ = Describe("Podman tag", func() { }) It("podman tag shortname:tag", func() { - session := podmanTest.Podman([]string{"tag", ALPINE, "foobar:new"}) + session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar:new"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.Podman([]string{"inspect", "foobar:new"}) + results := podmanTest.PodmanNoCache([]string{"inspect", "foobar:new"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() @@ -72,15 +72,15 @@ var _ = Describe("Podman tag", func() { }) It("podman tag shortname image no tag", func() { - session := podmanTest.Podman([]string{"tag", ALPINE, "foobar"}) + session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.Podman([]string{"tag", "foobar", "barfoo"}) + results := podmanTest.PodmanNoCache([]string{"tag", "foobar", "barfoo"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) - verify := podmanTest.Podman([]string{"inspect", "barfoo"}) + verify := podmanTest.PodmanNoCache([]string{"inspect", "barfoo"}) verify.WaitWithDefaultTimeout() Expect(verify.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index 4c2cdb7b5..b62d242f1 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman top", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/tree_test.go b/test/e2e/tree_test.go index 9740adada..c445328fa 100644 --- a/test/e2e/tree_test.go +++ b/test/e2e/tree_test.go @@ -22,7 +22,8 @@ var _ = Describe("Podman image tree", func() { os.Exit(1) } podmanTest = PodmanTestCreate(tempdir) - podmanTest.RestoreAllArtifacts() + podmanTest.Setup() + podmanTest.RestoreArtifact(BB) }) AfterEach(func() { @@ -36,10 +37,6 @@ var _ = Describe("Podman image tree", func() { if podmanTest.RemoteTest { Skip("Does not work on remote client") } - session := podmanTest.Podman([]string{"pull", "docker.io/library/busybox:latest"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - dockerfile := `FROM docker.io/library/busybox:latest RUN mkdir hello RUN touch test.txt @@ -47,17 +44,17 @@ ENV foo=bar ` podmanTest.BuildImage(dockerfile, "test:latest", "true") - session = podmanTest.Podman([]string{"image", "tree", "test:latest"}) + session := podmanTest.PodmanNoCache([]string{"image", "tree", "test:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"image", "tree", "--whatrequires", "docker.io/library/busybox:latest"}) + session = podmanTest.PodmanNoCache([]string{"image", "tree", "--whatrequires", "docker.io/library/busybox:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "test:latest"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "test:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "docker.io/library/busybox:latest"}) + session = podmanTest.PodmanNoCache([]string{"rmi", "docker.io/library/busybox:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go index 493c4a7d5..8c97e6b28 100644 --- a/test/e2e/trust_test.go +++ b/test/e2e/trust_test.go @@ -27,7 +27,7 @@ var _ = Describe("Podman trust", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/unshare_test.go b/test/e2e/unshare_test.go index 1e3f06a62..5f342ffc3 100644 --- a/test/e2e/unshare_test.go +++ b/test/e2e/unshare_test.go @@ -32,7 +32,7 @@ var _ = Describe("Podman unshare", func() { podmanTest.CgroupManager = "cgroupfs" podmanTest.StorageOptions = ROOTLESS_STORAGE_OPTIONS podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go index 35ee21e49..2c8b3068c 100644 --- a/test/e2e/version_test.go +++ b/test/e2e/version_test.go @@ -27,6 +27,7 @@ var _ = Describe("Podman version", func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() processTestResult(f) + podmanTest.SeedImages() }) diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index dccecd457..041a9e6f0 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman volume create", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_inspect_test.go b/test/e2e/volume_inspect_test.go index e7f20ce7b..0683c6bbf 100644 --- a/test/e2e/volume_inspect_test.go +++ b/test/e2e/volume_inspect_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman volume inspect", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go index 1f0177def..da2d7ae77 100644 --- a/test/e2e/volume_ls_test.go +++ b/test/e2e/volume_ls_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman volume ls", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_prune_test.go b/test/e2e/volume_prune_test.go index 55a95c8c9..ba249278b 100644 --- a/test/e2e/volume_prune_test.go +++ b/test/e2e/volume_prune_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman volume prune", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/volume_rm_test.go b/test/e2e/volume_rm_test.go index 39628d56f..5dcf51ccd 100644 --- a/test/e2e/volume_rm_test.go +++ b/test/e2e/volume_rm_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman volume rm", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go index 28a4c1e40..c03116b01 100644 --- a/test/e2e/wait_test.go +++ b/test/e2e/wait_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman wait", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.SeedImages() }) AfterEach(func() { |