diff options
Diffstat (limited to 'test/e2e')
61 files changed, 1793 insertions, 848 deletions
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 572e55fe5..63a2df67a 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -7,6 +7,7 @@ import ( "runtime" "strings" + "github.com/containers/buildah" . "github.com/containers/podman/v2/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -26,7 +27,6 @@ var _ = Describe("Podman build", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -38,32 +38,33 @@ var _ = Describe("Podman build", func() { // Let's first do the most simple build possible to make sure stuff is // happy and then clean up after ourselves to make sure that works too. It("podman build and remove basic alpine", func() { - session := podmanTest.PodmanNoCache([]string{"build", "build/basicalpine"}) + podmanTest.AddImageToRWStore(ALPINE) + session := podmanTest.Podman([]string{"build", "build/basicalpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) iid := session.OutputToStringArray()[len(session.OutputToStringArray())-1] // Verify that OS and Arch are being set - inspect := podmanTest.PodmanNoCache([]string{"inspect", iid}) + inspect := podmanTest.Podman([]string{"inspect", iid}) inspect.WaitWithDefaultTimeout() data := inspect.InspectImageJSON() Expect(data[0].Os).To(Equal(runtime.GOOS)) Expect(data[0].Architecture).To(Equal(runtime.GOARCH)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman build with logfile", func() { logfile := filepath.Join(podmanTest.TempDir, "logfile") - session := podmanTest.PodmanNoCache([]string{"build", "--tag", "test", "--logfile", logfile, "build/basicalpine"}) + session := podmanTest.Podman([]string{"build", "--tag", "test", "--logfile", logfile, "build/basicalpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Verify that OS and Arch are being set - inspect := podmanTest.PodmanNoCache([]string{"inspect", "test"}) + inspect := podmanTest.Podman([]string{"inspect", "test"}) inspect.WaitWithDefaultTimeout() data := inspect.InspectImageJSON() Expect(data[0].Os).To(Equal(runtime.GOOS)) @@ -73,7 +74,7 @@ var _ = Describe("Podman build", func() { Expect(err).To(BeNil()) Expect(st.Size()).To(Not(Equal(0))) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -81,7 +82,7 @@ var _ = Describe("Podman build", func() { // If the context directory is pointing at a file and not a directory, // that's a no no, fail out. It("podman build context directory a file", func() { - session := podmanTest.PodmanNoCache([]string{"build", "build/context_dir_a_file"}) + session := podmanTest.Podman([]string{"build", "build/context_dir_a_file"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) }) @@ -89,51 +90,47 @@ var _ = Describe("Podman build", func() { // Check that builds with different values for the squash options // create the appropriate number of layers, then clean up after. It("podman build basic alpine with squash", func() { - session := podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-a", "-t", "test-squash-a:latest", "build/squash"}) + session := podmanTest.Podman([]string{"build", "-f", "build/squash/Dockerfile.squash-a", "-t", "test-squash-a:latest", "build/squash"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-a"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Check for two layers Expect(len(strings.Fields(session.OutputToString()))).To(Equal(2)) - session = podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-b", "--squash", "-t", "test-squash-b:latest", "build/squash"}) + session = podmanTest.Podman([]string{"build", "-f", "build/squash/Dockerfile.squash-b", "--squash", "-t", "test-squash-b:latest", "build/squash"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-b"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-b"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Check for three layers Expect(len(strings.Fields(session.OutputToString()))).To(Equal(3)) - session = podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-c", "--squash", "-t", "test-squash-c:latest", "build/squash"}) + session = podmanTest.Podman([]string{"build", "-f", "build/squash/Dockerfile.squash-c", "--squash", "-t", "test-squash-c:latest", "build/squash"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-c"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-c"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Check for two layers Expect(len(strings.Fields(session.OutputToString()))).To(Equal(2)) - session = podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-c", "--squash-all", "-t", "test-squash-d:latest", "build/squash"}) + session = podmanTest.Podman([]string{"build", "-f", "build/squash/Dockerfile.squash-c", "--squash-all", "-t", "test-squash-d:latest", "build/squash"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-d"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RootFS.Layers}}", "test-squash-d"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Check for one layers Expect(len(strings.Fields(session.OutputToString()))).To(Equal(1)) - session = podmanTest.PodmanNoCache([]string{"rm", "-a"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - - session = podmanTest.PodmanNoCache([]string{"rmi", "-a", "-f"}) + session = podmanTest.Podman([]string{"rm", "-a"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -164,7 +161,7 @@ var _ = Describe("Podman build", func() { }() // When - session := podmanTest.PodmanNoCache([]string{ + session := podmanTest.Podman([]string{ "build", "-f", targetFile, "-t", "test-locations", }) session.WaitWithDefaultTimeout() @@ -188,13 +185,13 @@ var _ = Describe("Podman build", func() { } targetFile := filepath.Join(targetPath, "idFile") - session := podmanTest.PodmanNoCache([]string{"build", "build/basicalpine", "--iidfile", targetFile}) + session := podmanTest.Podman([]string{"build", "build/basicalpine", "--iidfile", targetFile}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) id, _ := ioutil.ReadFile(targetFile) // Verify that id is correct - inspect := podmanTest.PodmanNoCache([]string{"inspect", string(id)}) + inspect := podmanTest.Podman([]string{"inspect", string(id)}) inspect.WaitWithDefaultTimeout() data := inspect.InspectImageJSON() Expect(data[0].ID).To(Equal(string(id))) @@ -202,7 +199,7 @@ var _ = Describe("Podman build", func() { It("podman Test PATH in built image", func() { path := "/tmp:/bin:/usr/bin:/usr/sbin" - session := podmanTest.PodmanNoCache([]string{ + session := podmanTest.Podman([]string{ "build", "-f", "build/basicalpine/Containerfile.path", "-t", "test-path", }) session.WaitWithDefaultTimeout() @@ -213,10 +210,6 @@ var _ = Describe("Podman build", func() { Expect(session.ExitCode()).To(Equal(0)) stdoutLines := session.OutputToStringArray() Expect(stdoutLines[0]).Should(Equal(path)) - - session = podmanTest.PodmanNoCache([]string{"rmi", "-a", "-f"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) }) It("podman build --http_proxy flag", func() { @@ -225,18 +218,30 @@ var _ = Describe("Podman build", func() { podmanTest.StopRemoteService() podmanTest.StartRemoteService() } - podmanTest.RestoreAllArtifacts() - dockerfile := `FROM docker.io/library/alpine:latest + podmanTest.AddImageToRWStore(ALPINE) + dockerfile := `FROM quay.io/libpod/alpine:latest RUN printenv http_proxy` dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755) Expect(err).To(BeNil()) - session := podmanTest.PodmanNoCache([]string{"build", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir}) + session := podmanTest.Podman([]string{"build", "--http-proxy", "--file", dockerfilePath, podmanTest.TempDir}) session.Wait(120) Expect(session.ExitCode()).To(Equal(0)) ok, _ := session.GrepString("1.2.3.4") Expect(ok).To(BeTrue()) os.Unsetenv("http_proxy") }) + + It("podman build and check identity", func() { + session := podmanTest.Podman([]string{"build", "-f", "Containerfile.path", "--no-cache", "-t", "test", "build/basicalpine"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Verify that OS and Arch are being set + inspect := podmanTest.PodmanNoCache([]string{"image", "inspect", "--format", "{{ index .Config.Labels }}", "test"}) + inspect.WaitWithDefaultTimeout() + data := inspect.OutputToString() + Expect(data).To(ContainSubstring(buildah.Version)) + }) }) diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index f22a4c3af..75310b961 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -27,6 +25,7 @@ var _ = Describe("Podman checkpoint", func() { ) BeforeEach(func() { + SkipIfRemote("checkpoint not supported in remote mode") SkipIfRootless("checkpoint not supported in rootless mode") tempdir, err = CreateTempDirInTempDir() if err != nil { diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 3814d161d..facafcb77 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -27,6 +27,7 @@ import ( . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) var ( @@ -71,6 +72,8 @@ type testResult struct { length float64 } +var noCache = "Cannot run nocache with remote" + type testResultsSorted []testResult func (a testResultsSorted) Len() int { return len(a) } @@ -100,10 +103,16 @@ func TestLibpod(t *testing.T) { } var _ = SynchronizedBeforeSuite(func() []byte { + // make cache dir + if err := os.MkdirAll(ImageCacheDir, 0777); err != nil { + fmt.Printf("%q\n", err) + os.Exit(1) + } + // Cache images cwd, _ := os.Getwd() INTEGRATION_ROOT = filepath.Join(cwd, "../../") - podman := PodmanTestCreate("/tmp") + podman := PodmanTestSetup("/tmp") podman.ArtifactPath = ARTIFACT_DIR if _, err := os.Stat(ARTIFACT_DIR); os.IsNotExist(err) { if err = os.Mkdir(ARTIFACT_DIR, 0777); err != nil { @@ -112,16 +121,18 @@ 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 { + // Pull cirros but dont put it into the cache + pullImages := []string{cirros, fedoraToolbox} + pullImages = append(pullImages, CACHE_IMAGES...) + for _, image := range pullImages { podman.createArtifact(image) } + if err := os.MkdirAll(filepath.Join(ImageCacheDir, podman.ImageCacheFS+"-images"), 0777); err != nil { + fmt.Printf("%q\n", err) + os.Exit(1) + } + podman.CrioRoot = ImageCacheDir // If running localized tests, the cache dir is created and populated. if the // tests are remote, this is a no-op populateCache(podman) @@ -290,17 +301,10 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration { return p } -// RestoreAllArtifacts unpacks all cached images -func (p *PodmanTestIntegration) RestoreAllArtifacts() error { - if os.Getenv("NO_TEST_CACHE") != "" { - return nil +func (p PodmanTestIntegration) AddImageToRWStore(image string) { + if err := p.RestoreArtifact(image); err != nil { + logrus.Errorf("unable to restore %s to RW store", image) } - for _, image := range RESTORE_IMAGES { - if err := p.RestoreArtifact(image); err != nil { - return err - } - } - return nil } // createArtifact creates a cached image in the artifact dir @@ -424,7 +428,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.PodmanNoCache([]string{"build", "--layers=" + layers, "-t", imageName, "--file", dockerfilePath, p.TempDir}) + session := p.Podman([]string{"build", "--layers=" + layers, "-t", imageName, "--file", dockerfilePath, p.TempDir}) session.Wait(120) Expect(session).Should(Exit(0), fmt.Sprintf("BuildImage session output: %q", session.OutputToString())) } @@ -481,23 +485,6 @@ func (p *PodmanTestIntegration) CleanupVolume() { } } -// PullImages pulls multiple images -func (p *PodmanTestIntegration) PullImages(images []string) error { - for _, i := range images { - p.PullImage(i) - } - return nil -} - -// PullImage pulls a single image -// TODO should the timeout be configurable? -func (p *PodmanTestIntegration) PullImage(image string) error { - session := p.PodmanNoCache([]string{"pull", image}) - session.Wait(60) - Expect(session.ExitCode()).To(Equal(0)) - return nil -} - // InspectContainerToJSON takes the session output of an inspect // container and returns json func (s *PodmanSessionIntegration) InspectContainerToJSON() []define.InspectContainerData { @@ -559,12 +546,6 @@ func (p *PodmanTestIntegration) RunTopContainerInPod(name, pod string) *PodmanSe 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}) @@ -613,12 +594,10 @@ func SkipIfRootlessCgroupsV1(reason string) { } } -func SkipIfUnprevilegedCPULimits() { +func SkipIfUnprivilegedCPULimits() { info := GetHostDistributionInfo() - if isRootless() && - info.Distribution == "fedora" && - (info.Version == "31" || info.Version == "32") { - ginkgo.Skip("Rootless Fedora doesn't have permission to set CPU limits before version 33") + if isRootless() && info.Distribution == "fedora" { + ginkgo.Skip("Rootless Fedora doesn't have permission to set CPU limits") } } @@ -687,3 +666,125 @@ func (p *PodmanTestIntegration) RestartRemoteService() { p.StopRemoteService() p.StartRemoteService() } + +// 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.PodmanNoEvents([]string{"load", "-q", "-i", destName}) + restore.WaitWithDefaultTimeout() + return nil +} + +func populateCache(podman *PodmanTestIntegration) { + for _, image := range CACHE_IMAGES { + podman.RestoreArtifactToCache(image) + } + // logformatter uses this to recognize the first test + fmt.Printf("-----------------------------\n") +} + +func removeCache() { + // Remove cache dirs + if err := os.RemoveAll(ImageCacheDir); err != nil { + fmt.Printf("%q\n", err) + } +} + +// PodmanNoCache calls the podman command with no configured imagecache +func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { + podmanSession := p.PodmanBase(args, false, true) + return &PodmanSessionIntegration{podmanSession} +} + +func PodmanTestSetup(tempDir string) *PodmanTestIntegration { + return PodmanTestCreateUtil(tempDir, false) +} + +// PodmanNoEvents calls the Podman command without an imagecache and without an +// events backend. It is used mostly for caching and uncaching images. +func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration { + podmanSession := p.PodmanBase(args, true, true) + return &PodmanSessionIntegration{podmanSession} +} + +// MakeOptions assembles all the podman main options +func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache bool) []string { + if p.RemoteTest { + return args + } + var debug string + if _, ok := os.LookupEnv("DEBUG"); ok { + debug = "--log-level=debug --syslog=true " + } + + eventsType := "file" + if noEvents { + eventsType = "none" + } + + podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", + debug, p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ") + if os.Getenv("HOOK_OPTION") != "" { + podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) + } + + podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...) + if !noCache { + cacheOptions := []string{"--storage-opt", + fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)} + podmanOptions = append(cacheOptions, podmanOptions...) + } + podmanOptions = append(podmanOptions, args...) + return podmanOptions +} + +func writeConf(conf []byte, confPath string) { + if err := ioutil.WriteFile(confPath, conf, 777); err != nil { + fmt.Println(err) + } +} + +func removeConf(confPath string) { + if err := os.Remove(confPath); err != nil { + fmt.Println(err) + } +} + +// generateNetworkConfig generates a cni config with a random name +// it returns the network name and the filepath +func generateNetworkConfig(p *PodmanTestIntegration) (string, string) { + // generate a random name to prevent conflicts with other tests + name := "net" + stringid.GenerateNonCryptoID() + path := filepath.Join(p.CNIConfigDir, fmt.Sprintf("%s.conflist", name)) + conf := fmt.Sprintf(`{ + "cniVersion": "0.3.0", + "name": "%s", + "plugins": [ + { + "type": "bridge", + "bridge": "cni1", + "isGateway": true, + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "10.99.0.0/16", + "routes": [ + { "dst": "0.0.0.0/0" } + ] + } + }, + { + "type": "portmap", + "capabilities": { + "portMappings": true + } + } + ] + }`, name) + writeConf([]byte(conf), path) + + return name, path +} diff --git a/test/e2e/config.go b/test/e2e/config.go index 54e39f9d2..e66cd6846 100644 --- a/test/e2e/config.go +++ b/test/e2e/config.go @@ -1,18 +1,18 @@ package integration var ( - redis = "docker.io/library/redis:alpine" + redis = "quay.io/libpod/redis:alpine" fedoraMinimal = "quay.io/libpod/fedora-minimal:latest" - ALPINE = "docker.io/library/alpine:latest" - ALPINELISTTAG = "docker.io/library/alpine:3.10.2" - ALPINELISTDIGEST = "docker.io/library/alpine@sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb" - ALPINEAMD64DIGEST = "docker.io/library/alpine@sha256:acd3ca9941a85e8ed16515bfc5328e4e2f8c128caa72959a58a127b7801ee01f" + ALPINE = "quay.io/libpod/alpine:latest" + ALPINELISTTAG = "quay.io/libpod/alpine:3.10.2" + ALPINELISTDIGEST = "quay.io/libpod/alpine@sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f" + ALPINEAMD64DIGEST = "quay.io/libpod/alpine@sha256:634a8f35b5f16dcf4aaa0822adc0b1964bb786fca12f6831de8ddc45e5986a00" ALPINEAMD64ID = "961769676411f082461f9ef46626dd7a2d1e2b2a38e6a44364bcbecf51e66dd4" - ALPINEARM64DIGEST = "docker.io/library/alpine@sha256:db7f3dcef3d586f7dd123f107c93d7911515a5991c4b9e51fa2a43e46335a43e" + ALPINEARM64DIGEST = "quay.io/libpod/alpine@sha256:f270dcd11e64b85919c3bab66886e59d677cf657528ac0e4805d3c71e458e525" ALPINEARM64ID = "915beeae46751fc564998c79e73a1026542e945ca4f73dc841d09ccc6c2c0672" infra = "k8s.gcr.io/pause:3.2" - BB = "docker.io/library/busybox:latest" - healthcheck = "docker.io/libpod/alpine_healthcheck:latest" + BB = "quay.io/libpod/busybox:latest" + healthcheck = "quay.io/libpod/alpine_healthcheck:latest" ImageCacheDir = "/tmp/podman/imagecachedir" fedoraToolbox = "registry.fedoraproject.org/f32/fedora-toolbox:latest" @@ -20,8 +20,8 @@ var ( // The intention behind blocking all syscalls is to prevent // regressions in the future. The required syscalls can vary // depending on which runtime we're using. - alpineSeccomp = "docker.io/libpod/alpine-with-seccomp:label" + alpineSeccomp = "quay.io/libpod/alpine-with-seccomp:label" // This image has a bogus/invalid seccomp profile which should // yield a json error when being read. - alpineBogusSeccomp = "docker.io/libpod/alpine-with-bogus-seccomp:label" + alpineBogusSeccomp = "quay.io/libpod/alpine-with-bogus-seccomp:label" ) diff --git a/test/e2e/config/containers-remote.conf b/test/e2e/config/containers-remote.conf new file mode 100644 index 000000000..bc9eab951 --- /dev/null +++ b/test/e2e/config/containers-remote.conf @@ -0,0 +1,51 @@ +[containers] + +# A list of ulimits to be set in containers by default, specified as +# "<ulimit name>=<soft limit>:<hard limit>", for example: +# "nofile=1024:2048" +# See setrlimit(2) for a list of resource names. +# Any limit not specified here will be inherited from the process launching the +# container engine. +# Ulimits has limits for non privileged container engines. +# +default_ulimits = [ + "nofile=100:100", +] + +# Environment variable list for the conmon process; used for passing necessary +# environment variables to conmon or the runtime. +# +env = [ + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "foo=bar1", +] + +# container engines use container separation using MAC(SELinux) labeling. +# Flag is ignored on label disabled systems. +# +label = false + +# Size of /dev/shm. Specified as <number><unit>. +# Unit is optional, values: +# b (bytes), k (kilobytes), m (megabytes), or g (gigabytes). +# If the unit is omitted, the system uses bytes. +# +shm_size = "202k" + +# List of devices. Specified as +# "<device-on-host>:<device-on-container>:<permissions>", for example: +# "/dev/sdc:/dev/xvdc:rwm". +# If it is empty or commented out, only the default devices will be used +# +devices = [] + +default_sysctls = [ + "net.ipv4.ping_group_range=0 0", +] + +dns_searches=[ "barfoo.com", ] +dns_servers=[ "4.3.2.1", ] + +tz = "America/New_York" + +umask = "0022" diff --git a/test/e2e/config_amd64.go b/test/e2e/config_amd64.go index 151120058..25e50a541 100644 --- a/test/e2e/config_amd64.go +++ b/test/e2e/config_amd64.go @@ -8,8 +8,9 @@ var ( CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal} nginx = "quay.io/libpod/alpine_nginx:latest" BB_GLIBC = "docker.io/library/busybox:glibc" - registry = "docker.io/library/registry:2.6" + registry = "quay.io/libpod/registry:2.6" labels = "quay.io/libpod/alpine_labels:latest" ubi_minimal = "registry.access.redhat.com/ubi8-minimal" ubi_init = "registry.access.redhat.com/ubi8-init" + cirros = "quay.io/libpod/cirros:latest" ) diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index 965e51973..906153c0f 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -31,6 +29,10 @@ var _ = Describe("Podman run", func() { podmanTest.Setup() podmanTest.SeedImages() os.Setenv("CONTAINERS_CONF", "config/containers.conf") + if IsRemote() { + podmanTest.RestartRemoteService() + } + }) AfterEach(func() { @@ -80,12 +82,14 @@ var _ = Describe("Podman run", func() { }) It("podman Capabilities in containers.conf", func() { - os.Setenv("CONTAINERS_CONF", "config/containers.conf") cap := podmanTest.Podman([]string{"run", ALPINE, "grep", "CapEff", "/proc/self/status"}) cap.WaitWithDefaultTimeout() Expect(cap.ExitCode()).To(Equal(0)) os.Setenv("CONTAINERS_CONF", "config/containers-ns.conf") + if IsRemote() { + podmanTest.RestartRemoteService() + } session := podmanTest.Podman([]string{"run", "busybox", "grep", "CapEff", "/proc/self/status"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -93,7 +97,6 @@ var _ = Describe("Podman run", func() { }) It("podman Regular capabilities", func() { - os.Setenv("CONTAINERS_CONF", "config/containers.conf") setup := podmanTest.RunTopContainer("test1") setup.WaitWithDefaultTimeout() result := podmanTest.Podman([]string{"top", "test1", "capeff"}) @@ -105,6 +108,9 @@ var _ = Describe("Podman run", func() { It("podman drop capabilities", func() { os.Setenv("CONTAINERS_CONF", "config/containers-caps.conf") + if IsRemote() { + podmanTest.RestartRemoteService() + } setup := podmanTest.RunTopContainer("test1") setup.WaitWithDefaultTimeout() result := podmanTest.Podman([]string{"container", "top", "test1", "capeff"}) @@ -116,6 +122,9 @@ var _ = Describe("Podman run", func() { verifyNSHandling := func(nspath, option string) { os.Setenv("CONTAINERS_CONF", "config/containers-ns.conf") + if IsRemote() { + podmanTest.RestartRemoteService() + } //containers.conf default ipcns to default to host session := podmanTest.Podman([]string{"run", ALPINE, "ls", "-l", nspath}) session.WaitWithDefaultTimeout() @@ -168,6 +177,9 @@ var _ = Describe("Podman run", func() { } os.Setenv("CONTAINERS_CONF", conffile) + if IsRemote() { + podmanTest.RestartRemoteService() + } result := podmanTest.Podman([]string{"run", ALPINE, "ls", tempdir}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) @@ -215,6 +227,17 @@ var _ = Describe("Podman run", func() { Expect(session.LineInOuputStartsWith("search")).To(BeFalse()) }) + It("podman run use containers.conf search domain", func() { + session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.LineInOuputStartsWith("search")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("foobar.com")) + + Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) + Expect(session.OutputToString()).To(ContainSubstring("debug")) + }) + It("podman run containers.conf timezone", func() { //containers.conf timezone set to Pacific/Honolulu session := podmanTest.Podman([]string{"run", ALPINE, "date", "+'%H %Z'"}) @@ -222,6 +245,7 @@ var _ = Describe("Podman run", func() { Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring("HST")) }) + It("podman run containers.conf umask", func() { //containers.conf umask set to 0002 if !strings.Contains(podmanTest.OCIRuntime, "crun") { @@ -234,4 +258,57 @@ var _ = Describe("Podman run", func() { Expect(session.OutputToString()).To(Equal("0002")) }) + It("podman-remote test localcontainers.conf versus remote containers.conf", func() { + if !IsRemote() { + Skip("this test is only for remote") + } + + os.Setenv("CONTAINERS_CONF", "config/containers-remote.conf") + // Configuration that comes from remote server + // env + session := podmanTest.Podman([]string{"run", ALPINE, "printenv", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("bar")) + + // dns-search, server, options + session = podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.LineInOuputStartsWith("search")).To(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring("foobar.com")) + Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4")) + Expect(session.OutputToString()).To(ContainSubstring("debug")) + + // sysctls + session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/proc/sys/net/ipv4/ping_group_range"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("1000")) + + // shm-size + session = podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("size=200k")) + + // ulimits + session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("500")) + + // Configuration that comes from remote client + // Timezone + session = podmanTest.Podman([]string{"run", ALPINE, "date", "+'%H %Z'"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("EST")) + + // Umask + session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "umask"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("0022")) + }) }) diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index 6d349ba5b..c1d3be5ab 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -22,6 +20,7 @@ var _ = Describe("Podman cp", func() { ) BeforeEach(func() { + SkipIfRemote("FIXME: Podman-remote cp needs to work") tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) @@ -336,7 +335,7 @@ var _ = Describe("Podman cp", func() { DockerfileName := "Dockerfile.test-cp-root-dir" ctrName := "test-container-cp-root" - session := podmanTest.PodmanNoCache([]string{"build", "-f", "build/" + DockerfileName, "-t", imgName, "build/"}) + session := podmanTest.Podman([]string{"build", "-f", "build/" + DockerfileName, "-t", imgName, "build/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -365,7 +364,7 @@ var _ = Describe("Podman cp", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "-f", imgName}) + session = podmanTest.Podman([]string{"rmi", "-f", imgName}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/create_staticmac_test.go b/test/e2e/create_staticmac_test.go index adffdc1ca..1ac431da2 100644 --- a/test/e2e/create_staticmac_test.go +++ b/test/e2e/create_staticmac_test.go @@ -5,6 +5,7 @@ import ( "github.com/containers/podman/v2/pkg/rootless" . "github.com/containers/podman/v2/test/utils" + "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -45,4 +46,21 @@ var _ = Describe("Podman run with --mac-address flag", func() { Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:0a:29:34")) } }) + + It("Podman run --mac-address with custom network", func() { + net := "n1" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", net}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net) + Expect(session.ExitCode()).To(BeZero()) + + result := podmanTest.Podman([]string{"run", "--network", net, "--mac-address", "92:d0:c6:00:29:34", ALPINE, "ip", "addr"}) + result.WaitWithDefaultTimeout() + if rootless.IsRootless() { + Expect(result.ExitCode()).To(Equal(125)) + } else { + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(ContainSubstring("92:d0:c6:00:29:34")) + } + }) }) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 6b0f7a7af..760345a67 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -271,73 +271,73 @@ var _ = Describe("Podman create", func() { }) It("podman create --pull", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--pull", "never", "--name=foo", "debian"}) + session := podmanTest.Podman([]string{"create", "--pull", "never", "--name=foo", "testimage:00000000"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) - session = podmanTest.PodmanNoCache([]string{"create", "--pull", "always", "--name=foo", "debian"}) + session = podmanTest.Podman([]string{"create", "--pull", "always", "--name=foo", "testimage:00000000"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman create using image list by tag", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINELISTTAG}) + session := podmanTest.Podman([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINELISTTAG}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.Image}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) }) It("podman create using image list by digest", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINELISTDIGEST}) + session := podmanTest.Podman([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.Image}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) }) It("podman create using image list instance by digest", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINEARM64DIGEST}) + session := podmanTest.Podman([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.Image}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) }) It("podman create using cross-arch image list instance by digest", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINEARM64DIGEST}) + session := podmanTest.Podman([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.Image}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.Image}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64ID)) - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.ImageName}}", "foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) }) It("podman create --authfile with nonexist authfile", func() { - session := podmanTest.PodmanNoCache([]string{"create", "--authfile", "/tmp/nonexist", "--name=foo", ALPINE}) + session := podmanTest.Podman([]string{"create", "--authfile", "/tmp/nonexist", "--name=foo", ALPINE}) session.WaitWithDefaultTimeout() Expect(session).To(Not(Equal(0))) }) diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index a698cd4b3..f61f52589 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -87,14 +87,12 @@ var _ = Describe("Podman exec", func() { 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()) + Expect(session.OutputToString()).To(Equal("BAR")) 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()) + Expect(session.OutputToString()).To(Equal("/bin")) }) It("podman exec os.Setenv env", func() { @@ -107,8 +105,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--env", "FOO", "test1", "printenv", "FOO"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString("BAR") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("BAR")) os.Unsetenv("FOO") }) @@ -142,8 +139,7 @@ var _ = Describe("Podman exec", func() { session := podmanTest.Podman([]string{"exec", "--interactive", "--tty", "test1", "/usr/bin/stty", "--all"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ := session.GrepString(" onlcr") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(ContainSubstring(" onlcr")) }) It("podman exec simple command with user", func() { @@ -199,14 +195,12 @@ var _ = Describe("Podman exec", func() { 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()) + Expect(session.OutputToString()).To(Equal("/tmp")) session = podmanTest.Podman([]string{"exec", "-w", "/tmp", "test1", "pwd"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - match, _ = session.GrepString("/tmp") - Expect(match).Should(BeTrue()) + Expect(session.OutputToString()).To(Equal("/tmp")) }) It("podman exec missing working directory test", func() { @@ -280,7 +274,7 @@ var _ = Describe("Podman exec", func() { exec := podmanTest.Podman([]string{"exec", "-ti", ctrName2, "id"}) exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).To(Equal(0)) - Expect(strings.Contains(exec.OutputToString(), fmt.Sprintf("%s(%s)", gid, groupName))).To(BeTrue()) + Expect(exec.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s(%s)", gid, groupName))) }) It("podman exec preserves container groups with --user and --group-add", func() { @@ -300,9 +294,9 @@ RUN useradd -u 1000 auser` exec.WaitWithDefaultTimeout() Expect(exec.ExitCode()).To(Equal(0)) output := exec.OutputToString() - Expect(strings.Contains(output, "4000(first)")).To(BeTrue()) - Expect(strings.Contains(output, "4001(second)")).To(BeTrue()) - Expect(strings.Contains(output, "1000(auser)")).To(BeTrue()) + Expect(output).To(ContainSubstring("4000(first)")) + Expect(output).To(ContainSubstring("4001(second)")) + Expect(output).To(ContainSubstring("1000(auser)")) // Kill the container just so the test does not take 15 seconds to stop. kill := podmanTest.Podman([]string{"kill", ctrName}) @@ -323,7 +317,7 @@ RUN useradd -u 1000 auser` data := podmanTest.InspectContainer(ctrName) Expect(len(data)).To(Equal(1)) Expect(len(data[0].ExecIDs)).To(Equal(1)) - Expect(strings.Contains(exec1.OutputToString(), data[0].ExecIDs[0])).To(BeTrue()) + Expect(exec1.OutputToString()).To(ContainSubstring(data[0].ExecIDs[0])) exec2 := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "ps", "-a"}) exec2.WaitWithDefaultTimeout() diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go index 1076dfc61..7ff5d4207 100644 --- a/test/e2e/exists_test.go +++ b/test/e2e/exists_test.go @@ -23,7 +23,6 @@ var _ = Describe("Podman image|container exists", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -39,6 +38,7 @@ var _ = Describe("Podman image|container exists", func() { Expect(session).Should(Exit(0)) }) It("podman image exists in local storage by short name", func() { + Skip("FIXME-8165: shortnames don't seem to work with quay (#8176)") session := podmanTest.Podman([]string{"image", "exists", "alpine"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index 3c4a1008b..c8782c743 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -397,6 +397,7 @@ var _ = Describe("Podman generate kube", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + podmanTest.AddImageToRWStore(ALPINE) session = podmanTest.Podman([]string{"play", "kube", outputFile}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 71e73af9c..403f15fa7 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -81,7 +81,7 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman healthcheck that should fail", func() { - session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "docker.io/libpod/badhealthcheck:latest"}) + session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "quay.io/libpod/badhealthcheck:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/image_sign_test.go b/test/e2e/image_sign_test.go index c54cf433d..c9041eaba 100644 --- a/test/e2e/image_sign_test.go +++ b/test/e2e/image_sign_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -21,6 +19,7 @@ var _ = Describe("Podman image sign", func() { ) BeforeEach(func() { + SkipIfRemote("podman-remote image sign is not supported") tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 9344132d9..4c65a85d5 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -41,20 +41,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) - }) - - It("podman images with no images prints header", func() { - rmi := podmanTest.PodmanNoCache([]string{"rmi", "-a"}) - rmi.WaitWithDefaultTimeout() - Expect(rmi).Should(Exit(0)) - - session := podmanTest.PodmanNoCache([]string{"images"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(1)) - Expect(session.LineInOutputContains("REPOSITORY")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) }) It("podman image List", func() { @@ -62,35 +50,35 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) }) It("podman images with multiple tags", func() { // tag "docker.io/library/alpine:latest" to "foo:{a,b,c}" - podmanTest.RestoreAllArtifacts() - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"}) + podmanTest.AddImageToRWStore(ALPINE) + session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) // tag "foo:c" to "bar:{a,b}" - session = podmanTest.PodmanNoCache([]string{"tag", "foo:c", "bar:a", "bar:b"}) + session = podmanTest.Podman([]string{"tag", "foo:c", "bar:a", "bar:b"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) // check all previous and the newly tagged images - session = podmanTest.PodmanNoCache([]string{"images"}) + session = podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session.LineInOutputContainsTag("docker.io/library/alpine", "latest") - session.LineInOutputContainsTag("docker.io/library/busybox", "glibc") - session.LineInOutputContainsTag("foo", "a") - session.LineInOutputContainsTag("foo", "b") - session.LineInOutputContainsTag("foo", "c") - session.LineInOutputContainsTag("bar", "a") - session.LineInOutputContainsTag("bar", "b") - session = podmanTest.PodmanNoCache([]string{"images", "-qn"}) + Expect(session.LineInOutputContainsTag("quay.io/libpod/alpine", "latest")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("quay.io/libpod/busybox", "latest")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/foo", "a")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/foo", "b")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/foo", "c")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/bar", "a")).To(BeTrue()) + Expect(session.LineInOutputContainsTag("localhost/bar", "b")).To(BeTrue()) + session = podmanTest.Podman([]string{"images", "-qn"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(BeNumerically("==", 3)) + Expect(len(session.OutputToStringArray())).To(BeNumerically("==", 11)) }) It("podman images with digests", func() { @@ -98,8 +86,8 @@ var _ = Describe("Podman images", func() { session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) - Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("quay.io/libpod/busybox")).To(BeTrue()) }) It("podman empty images list in JSON format", func() { @@ -131,52 +119,53 @@ var _ = Describe("Podman images", func() { }) It("podman images filter by image name", func() { - podmanTest.RestoreAllArtifacts() - session := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE}) + podmanTest.AddImageToRWStore(ALPINE) + podmanTest.AddImageToRWStore(BB) + + session := podmanTest.Podman([]string{"images", "-q", ALPINE}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(1)) - session = podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foo:a"}) + session = podmanTest.Podman([]string{"tag", ALPINE, "foo:a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"tag", BB, "foo:b"}) + session = podmanTest.Podman([]string{"tag", BB, "foo:b"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"images", "-q", "foo"}) + session = podmanTest.Podman([]string{"images", "-q", "foo"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) }) It("podman images filter reference", func() { - podmanTest.RestoreAllArtifacts() - result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=docker.io*"}) + result := podmanTest.Podman([]string{"images", "-q", "-f", "reference=quay.io*"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(len(result.OutputToStringArray())).To(Equal(2)) + Expect(len(result.OutputToStringArray())).To(Equal(8)) - retapline := podmanTest.PodmanNoCache([]string{"images", "-f", "reference=a*pine"}) + retapline := podmanTest.Podman([]string{"images", "-f", "reference=a*pine"}) retapline.WaitWithDefaultTimeout() Expect(retapline).Should(Exit(0)) - Expect(len(retapline.OutputToStringArray())).To(Equal(3)) + Expect(len(retapline.OutputToStringArray())).To(Equal(6)) Expect(retapline.LineInOutputContains("alpine")).To(BeTrue()) - retapline = podmanTest.PodmanNoCache([]string{"images", "-f", "reference=alpine"}) + retapline = podmanTest.Podman([]string{"images", "-f", "reference=alpine"}) retapline.WaitWithDefaultTimeout() Expect(retapline).Should(Exit(0)) - Expect(len(retapline.OutputToStringArray())).To(Equal(3)) + Expect(len(retapline.OutputToStringArray())).To(Equal(6)) Expect(retapline.LineInOutputContains("alpine")).To(BeTrue()) - retnone := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=bogus"}) + retnone := podmanTest.Podman([]string{"images", "-q", "-f", "reference=bogus"}) retnone.WaitWithDefaultTimeout() Expect(retnone).Should(Exit(0)) Expect(len(retnone.OutputToStringArray())).To(Equal(0)) }) It("podman images filter before image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest RUN apk update && apk add strace ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") @@ -188,7 +177,7 @@ RUN apk update && apk add strace }) It("podman images workingdir from image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest WORKDIR /test ` podmanTest.BuildImage(dockerfile, "foobar.com/workdir:latest", "false") @@ -198,38 +187,28 @@ WORKDIR /test Expect(result.OutputToString()).To(Equal("/test")) }) - It("podman images filter after image", func() { - podmanTest.RestoreAllArtifacts() - rmi := podmanTest.PodmanNoCache([]string{"rmi", "busybox"}) - rmi.WaitWithDefaultTimeout() - Expect(rmi).Should(Exit(0)) - - dockerfile := `FROM docker.io/library/alpine:latest + It("podman images filter since image", func() { + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") - result := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result := podmanTest.Podman([]string{"images", "-q", "-f", "since=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(len(result.OutputToStringArray())).To(Equal(0)) + Expect(len(result.OutputToStringArray())).To(Equal(7)) }) It("podman image list filter after image", func() { - podmanTest.RestoreAllArtifacts() - rmi := podmanTest.PodmanNoCache([]string{"image", "rm", "busybox"}) - rmi.WaitWithDefaultTimeout() - Expect(rmi).Should(Exit(0)) - - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") - result := podmanTest.PodmanNoCache([]string{"image", "list", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result := podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) - Expect(result.OutputToStringArray()).Should(HaveLen(0), "list filter output: %q", result.OutputToString()) + Expect(result.OutputToStringArray()).Should(HaveLen(7), "list filter output: %q", result.OutputToString()) }) It("podman images filter dangling", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") @@ -240,6 +219,7 @@ WORKDIR /test }) It("podman pull by digest and list --all", func() { + Skip("FIXME-8165: 'rmi -af' fails with 'layer not known' (#6510)") // Prevent regressing on issue #7651. digestPullAndList := func(noneTag bool) { session := podmanTest.Podman([]string{"pull", ALPINEAMD64DIGEST}) @@ -340,26 +320,25 @@ WORKDIR /test It("podman images --all flag", func() { SkipIfRemote("FIXME This should work on podman-remote, problem is with podman-remote build") - podmanTest.RestoreAllArtifacts() - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest RUN mkdir hello RUN touch test.txt ENV foo=bar ` podmanTest.BuildImage(dockerfile, "test", "true") - session := podmanTest.PodmanNoCache([]string{"images"}) + session := podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(5)) + Expect(len(session.OutputToStringArray())).To(Equal(len(CACHE_IMAGES) + 2)) - session2 := podmanTest.PodmanNoCache([]string{"images", "--all"}) + session2 := podmanTest.Podman([]string{"images", "--all"}) session2.WaitWithDefaultTimeout() Expect(session2).Should(Exit(0)) - Expect(len(session2.OutputToStringArray())).To(Equal(7)) + Expect(len(session2.OutputToStringArray())).To(Equal(len(CACHE_IMAGES) + 4)) }) It("podman images filter by label", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest LABEL version="1.0" LABEL "com.example.vendor"="Example Vendor" ` @@ -436,7 +415,7 @@ LABEL "com.example.vendor"="Example Vendor" }) It("podman images --filter readonly", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ` podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") result := podmanTest.Podman([]string{"images", "-f", "readonly=true"}) diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index 9c6f4381d..1be4ef920 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -19,6 +17,7 @@ var _ = Describe("Podman import", func() { ) BeforeEach(func() { + SkipIfRemote("FIXME: These look like it is supposed to work in remote") tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) @@ -62,11 +61,14 @@ var _ = Describe("Podman import", func() { export.WaitWithDefaultTimeout() Expect(export.ExitCode()).To(Equal(0)) - importImage := podmanTest.PodmanNoCache([]string{"import", outfile}) + importImage := podmanTest.Podman([]string{"import", outfile}) importImage.WaitWithDefaultTimeout() Expect(importImage.ExitCode()).To(Equal(0)) - Expect(podmanTest.ImageExistsInMainStore(importImage.OutputToString())).To(BeTrue()) + // tag the image which proves it is in R/W storage + tag := podmanTest.Podman([]string{"tag", importImage.OutputToString(), "foo"}) + tag.WaitWithDefaultTimeout() + Expect(tag.ExitCode()).To(BeZero()) }) It("podman import with message flag", func() { diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index e8a82f9a1..c2e0f4407 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -40,7 +40,7 @@ var _ = Describe("Podman inspect", func() { Expect(session.ExitCode()).To(Equal(0)) Expect(session.IsJSONOutputValid()).To(BeTrue()) imageData := session.InspectImageJSON() - Expect(imageData[0].RepoTags[0]).To(Equal("docker.io/library/alpine:latest")) + Expect(imageData[0].RepoTags[0]).To(Equal("quay.io/libpod/alpine:latest")) }) It("podman inspect bogus container", func() { @@ -160,10 +160,7 @@ var _ = Describe("Podman inspect", func() { }) It("podman inspect shows healthcheck on docker image", func() { - pull := podmanTest.Podman([]string{"pull", healthcheck}) - pull.WaitWithDefaultTimeout() - Expect(pull.ExitCode()).To(BeZero()) - + podmanTest.AddImageToRWStore(healthcheck) session := podmanTest.Podman([]string{"inspect", "--format=json", healthcheck}) session.WaitWithDefaultTimeout() imageData := session.InspectImageJSON() @@ -248,12 +245,13 @@ var _ = Describe("Podman inspect", func() { }) It("podman inspect container + image with same name gives container", func() { + podmanTest.AddImageToRWStore(ALPINE) ctrName := "testcontainer" - create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE, "sh"}) + create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) - tag := podmanTest.PodmanNoCache([]string{"tag", ALPINE, ctrName + ":latest"}) + tag := podmanTest.Podman([]string{"tag", ALPINE, ctrName + ":latest"}) tag.WaitWithDefaultTimeout() Expect(tag.ExitCode()).To(Equal(0)) @@ -271,7 +269,7 @@ var _ = Describe("Podman inspect", func() { } ctrName := "hugo" - create := podmanTest.PodmanNoCache([]string{ + create := podmanTest.Podman([]string{ "create", "--name", ctrName, "--security-opt", "seccomp=unconfined", "--security-opt", "label=type:spc_t", @@ -291,7 +289,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect pod", func() { podName := "testpod" - create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create := podmanTest.Podman([]string{"pod", "create", "--name", podName}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) @@ -305,7 +303,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect pod with type", func() { podName := "testpod" - create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create := podmanTest.Podman([]string{"pod", "create", "--name", podName}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) @@ -320,7 +318,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect latest pod", func() { SkipIfRemote("--latest flag n/a") podName := "testpod" - create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create := podmanTest.Podman([]string{"pod", "create", "--name", podName}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) @@ -334,7 +332,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect latest defaults to latest container", func() { SkipIfRemote("--latest flag n/a") podName := "testpod" - pod := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + pod := podmanTest.Podman([]string{"pod", "create", "--name", podName}) pod.WaitWithDefaultTimeout() Expect(pod.ExitCode()).To(Equal(0)) @@ -388,7 +386,7 @@ var _ = Describe("Podman inspect", func() { }) It("podman inspect --type container on a pod should fail", func() { podName := "testpod" - create := podmanTest.PodmanNoCache([]string{"pod", "create", "--name", podName}) + create := podmanTest.Podman([]string{"pod", "create", "--name", podName}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) @@ -399,7 +397,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect --type network on a container should fail", func() { ctrName := "testctr" - create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE}) + create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) @@ -410,7 +408,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect --type pod on a container should fail", func() { ctrName := "testctr" - create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE}) + create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) @@ -421,7 +419,7 @@ var _ = Describe("Podman inspect", func() { It("podman inspect --type volume on a container should fail", func() { ctrName := "testctr" - create := podmanTest.PodmanNoCache([]string{"create", "--name", ctrName, ALPINE}) + create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go index 10976fd83..8a4828583 100644 --- a/test/e2e/kill_test.go +++ b/test/e2e/kill_test.go @@ -22,7 +22,6 @@ var _ = Describe("Podman kill", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() }) AfterEach(func() { diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index fa87302ee..fe8b8fe56 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -46,21 +46,6 @@ func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os return &PodmanSessionIntegration{podmanSession} } -// PodmanNoCache calls podman with out adding the imagecache -func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { - var remoteArgs = []string{"--remote", "--url", p.RemoteSocket} - remoteArgs = append(remoteArgs, args...) - podmanSession := p.PodmanBase(remoteArgs, false, true) - return &PodmanSessionIntegration{podmanSession} -} - -// PodmanNoEvents calls the Podman command without an imagecache and without an -// events backend. It is used mostly for caching and uncaching images. -func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration { - podmanSession := p.PodmanBase(args, true, true) - return &PodmanSessionIntegration{podmanSession} -} - func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf") os.Setenv("REGISTRIES_CONFIG_PATH", defaultFile) @@ -93,6 +78,9 @@ func (p *PodmanTestIntegration) StartRemoteService() { remoteSocket := p.RemoteSocket args = append(args, "system", "service", "--time", "0", remoteSocket) podmanOptions := getRemoteOptions(p, args) + cacheOptions := []string{"--storage-opt", + fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)} + podmanOptions = append(cacheOptions, podmanOptions...) command := exec.Command(p.PodmanBinary, podmanOptions...) command.Stdout = os.Stdout command.Stderr = os.Stderr @@ -154,11 +142,6 @@ func (p *PodmanTestIntegration) StopRemoteService() { } //MakeOptions assembles all the podman main options -func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache bool) []string { - return args -} - -//MakeOptions assembles all the podman main options func getRemoteOptions(p *PodmanTestIntegration, args []string) []string { podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s", p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ") @@ -170,19 +153,9 @@ func getRemoteOptions(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.PodmanNoEvents([]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() + return nil } // RestoreArtifact puts the cached image into our test store @@ -212,6 +185,3 @@ func (p *PodmanTestIntegration) DelayForService() error { } return errors.New("Service not detected") } - -func populateCache(podman *PodmanTestIntegration) {} -func removeCache() {} diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index a9da922de..c37b24ab6 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -29,19 +29,6 @@ func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os return &PodmanSessionIntegration{podmanSession} } -// PodmanNoCache calls the podman command with no configured imagecache -func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { - podmanSession := p.PodmanBase(args, false, true) - return &PodmanSessionIntegration{podmanSession} -} - -// PodmanNoEvents calls the Podman command without an imagecache and without an -// events backend. It is used mostly for caching and uncaching images. -func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration { - podmanSession := p.PodmanBase(args, true, true) - return &PodmanSessionIntegration{podmanSession} -} - func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf") os.Setenv("REGISTRIES_CONFIG_PATH", defaultFile) @@ -61,34 +48,6 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration { return PodmanTestCreateUtil(tempDir, false) } -// MakeOptions assembles all the podman main options -func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache bool) []string { - var debug string - if _, ok := os.LookupEnv("DEBUG"); ok { - debug = "--log-level=debug --syslog=true " - } - - eventsType := "file" - if noEvents { - eventsType = "none" - } - - podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", - debug, p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ") - if os.Getenv("HOOK_OPTION") != "" { - podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) - } - - podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...) - if !noCache { - cacheOptions := []string{"--storage-opt", - fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)} - podmanOptions = append(cacheOptions, podmanOptions...) - } - podmanOptions = append(podmanOptions, args...) - return podmanOptions -} - // RestoreArtifact puts the cached image into our test store func (p *PodmanTestIntegration) RestoreArtifact(image string) error { fmt.Printf("Restoring %s...\n", image) @@ -99,36 +58,9 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error { 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.PodmanNoEvents([]string{"load", "-q", "-i", destName}) - restore.WaitWithDefaultTimeout() - return nil -} - func (p *PodmanTestIntegration) StopRemoteService() {} func (p *PodmanTestIntegration) DelayForVarlink() {} -func populateCache(podman *PodmanTestIntegration) { - for _, image := range CACHE_IMAGES { - podman.RestoreArtifactToCache(image) - } - // logformatter uses this to recognize the first test - fmt.Printf("-----------------------------\n") -} - -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 dd91381d9..ffbb9b44f 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -24,7 +24,7 @@ var _ = Describe("Podman load", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.AddImageToRWStore(ALPINE) }) AfterEach(func() { @@ -37,11 +37,11 @@ var _ = Describe("Podman load", func() { It("podman load input flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - images := podmanTest.PodmanNoCache([]string{"images"}) + images := podmanTest.Podman([]string{"images"}) images.WaitWithDefaultTimeout() fmt.Println(images.OutputToStringArray()) - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) @@ -49,7 +49,7 @@ var _ = Describe("Podman load", func() { rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + result := podmanTest.Podman([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -57,7 +57,7 @@ var _ = Describe("Podman load", func() { It("podman load compressed tar file", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) @@ -65,11 +65,11 @@ var _ = Describe("Podman load", func() { Expect(compress.ExitCode()).To(Equal(0)) outfile = outfile + ".gz" - rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + result := podmanTest.Podman([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -77,15 +77,15 @@ var _ = Describe("Podman load", func() { It("podman load oci-archive image", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + result := podmanTest.Podman([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -93,15 +93,15 @@ var _ = Describe("Podman load", func() { It("podman load oci-archive with signature", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "--signature-policy", "/etc/containers/policy.json", "-i", outfile}) + result := podmanTest.Podman([]string{"load", "--signature-policy", "/etc/containers/policy.json", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -109,15 +109,15 @@ var _ = Describe("Podman load", func() { It("podman load with quiet flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "-q", "-i", outfile}) + result := podmanTest.Podman([]string{"load", "-q", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) @@ -126,7 +126,7 @@ var _ = Describe("Podman load", func() { SkipIfRemote("Remote does not support loading directories") outdir := filepath.Join(podmanTest.TempDir, "alpine") - save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) + save := podmanTest.Podman([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) @@ -156,7 +156,7 @@ var _ = Describe("Podman load", func() { }) It("podman load bogus file", func() { - save := podmanTest.PodmanNoCache([]string{"load", "-i", "foobar.tar"}) + save := podmanTest.Podman([]string{"load", "-i", "foobar.tar"}) save.WaitWithDefaultTimeout() Expect(save).To(ExitWithError()) }) @@ -166,77 +166,76 @@ var _ = Describe("Podman load", func() { Skip("skip on ppc64le") } outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - alpVersion := "docker.io/library/alpine:3.2" + alpVersion := "quay.io/libpod/alpine:3.2" - pull := podmanTest.PodmanNoCache([]string{"pull", alpVersion}) + pull := podmanTest.Podman([]string{"pull", alpVersion}) pull.WaitWithDefaultTimeout() Expect(pull.ExitCode()).To(Equal(0)) - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE, alpVersion}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE, alpVersion}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) - rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE, alpVersion}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE, alpVersion}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + result := podmanTest.Podman([]string{"load", "-i", outfile}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - inspect := podmanTest.PodmanNoCache([]string{"inspect", ALPINE}) + inspect := podmanTest.Podman([]string{"inspect", ALPINE}) inspect.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - inspect = podmanTest.PodmanNoCache([]string{"inspect", alpVersion}) + inspect = podmanTest.Podman([]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.PodmanNoCache([]string{"tag", ALPINE, "hello:world"}) + setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", "hello:world"}) + setup = podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"rmi", "hello:world"}) + setup = podmanTest.Podman([]string{"rmi", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + load := podmanTest.Podman([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"images", "hello:world"}) + result := podmanTest.Podman([]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") - setup := podmanTest.PodmanNoCache([]string{"tag", fedoraMinimal, "hello"}) + setup := podmanTest.Podman([]string{"tag", ALPINE, "hello"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", "hello"}) + setup = podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", "hello"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"rmi", "hello"}) + setup = podmanTest.Podman([]string{"rmi", "hello"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + load := podmanTest.Podman([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"images", "hello:latest"}) + result := podmanTest.Podman([]string{"images", "hello:latest"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.LineInOutputContains("localhost")).To(BeTrue()) @@ -246,48 +245,48 @@ var _ = Describe("Podman load", func() { SkipIfRemote("podman-remote does not support loading directories") outfile := filepath.Join(podmanTest.TempDir, "load") - setup := podmanTest.PodmanNoCache([]string{"tag", BB, "hello:world"}) + setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-dir", "hello:world"}) + setup = podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-dir", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"rmi", "hello:world"}) + setup = podmanTest.Podman([]string{"rmi", "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + load := podmanTest.Podman([]string{"load", "-i", outfile}) load.WaitWithDefaultTimeout() Expect(load.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"images", "load:latest"}) + result := podmanTest.Podman([]string{"images", "load:latest"}) result.WaitWithDefaultTimeout() Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.LineInOutputContains("localhost")).To(BeTrue()) }) It("podman load xz compressed image", func() { - outfile := filepath.Join(podmanTest.TempDir, "bb.tar") + outfile := filepath.Join(podmanTest.TempDir, "alp.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, BB}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) session := SystemExec("xz", []string{outfile}) Expect(session.ExitCode()).To(Equal(0)) - rmi := podmanTest.PodmanNoCache([]string{"rmi", BB}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile + ".xz"}) + result := podmanTest.Podman([]string{"load", "-i", outfile + ".xz"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) It("podman load multi-image archive", func() { - result := podmanTest.PodmanNoCache([]string{"load", "-i", "./testdata/image/docker-two-images.tar.xz"}) + result := podmanTest.Podman([]string{"load", "-i", "./testdata/image/docker-two-images.tar.xz"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) Expect(result.LineInOutputContains("example.com/empty:latest")).To(BeTrue()) diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index b1255c00a..5de77f158 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -35,7 +35,6 @@ var _ = Describe("Podman login and logout", func() { os.Exit(1) } podmanTest = PodmanTestCreate(tempdir) - podmanTest.RestoreAllArtifacts() authPath = filepath.Join(podmanTest.TempDir, "auth") os.Mkdir(authPath, os.ModePerm) diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 4214bd50e..a749a86ff 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -337,4 +337,22 @@ var _ = Describe("Podman logs", func() { Expect(results).To(Exit(0)) Expect(results.OutputToString()).To(Equal("podman podman podman")) }) + + It("Make sure logs match expected length", func() { + logc := podmanTest.Podman([]string{"run", "-t", "--name", "test", ALPINE, "sh", "-c", "echo 1; echo 2"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + wait := podmanTest.Podman([]string{"wait", "test"}) + wait.WaitWithDefaultTimeout() + Expect(wait).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "test"}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + outlines := results.OutputToStringArray() + Expect(len(outlines)).To(Equal(2)) + Expect(outlines[0]).To(Equal("1\r")) + Expect(outlines[1]).To(Equal("2\r")) + }) }) diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index b85132814..bc47f7500 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -55,7 +55,12 @@ var _ = Describe("Podman manifest", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"manifest", "inspect", "docker.io/library/busybox"}) + session = podmanTest.Podman([]string{"manifest", "inspect", "quay.io/libpod/busybox"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + // inspect manifest of single image + session = podmanTest.Podman([]string{"manifest", "inspect", "quay.io/libpod/busybox@sha256:6655df04a3df853b029a5fac8836035ac4fab117800c9a6c4b69341bb5306c3d"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) diff --git a/test/e2e/mount_rootless_test.go b/test/e2e/mount_rootless_test.go index 312258532..1e4152709 100644 --- a/test/e2e/mount_rootless_test.go +++ b/test/e2e/mount_rootless_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -18,9 +16,8 @@ var _ = Describe("Podman mount", func() { ) BeforeEach(func() { - if os.Geteuid() == 0 { - Skip("This function is not enabled for rootfull podman") - } + SkipIfNotRootless("This function is not enabled for rootfull podman") + SkipIfRemote("Podman mount not supported for remote connections") tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) @@ -61,18 +58,16 @@ var _ = Describe("Podman mount", func() { }) It("podman image mount", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", ALPINE}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - mount := podmanTest.PodmanNoCache([]string{"image", "mount", ALPINE}) + podmanTest.AddImageToRWStore(ALPINE) + mount := podmanTest.Podman([]string{"image", "mount", ALPINE}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).ToNot(Equal(0)) Expect(mount.ErrorToString()).To(ContainSubstring("podman unshare")) }) It("podman unshare image podman mount", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", ALPINE}) + podmanTest.AddImageToRWStore(ALPINE) + setup := podmanTest.Podman([]string{"pull", ALPINE}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go index 4223961a6..c9274553b 100644 --- a/test/e2e/mount_test.go +++ b/test/e2e/mount_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -18,6 +16,7 @@ var _ = Describe("Podman mount", func() { ) BeforeEach(func() { + SkipIfRemote("Podman mount not supported for remote connections") SkipIfRootless("Podman mount requires podman unshare first to work") tempdir, err = CreateTempDirInTempDir() if err != nil { @@ -25,7 +24,7 @@ var _ = Describe("Podman mount", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.SeedImages() + podmanTest.AddImageToRWStore(ALPINE) }) AfterEach(func() { @@ -281,79 +280,65 @@ var _ = Describe("Podman mount", func() { }) It("podman image mount", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", ALPINE}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - images := podmanTest.PodmanNoCache([]string{"images"}) + images := podmanTest.Podman([]string{"images"}) images.WaitWithDefaultTimeout() Expect(images.ExitCode()).To(Equal(0)) - mount := podmanTest.PodmanNoCache([]string{"image", "mount", ALPINE}) + mount := podmanTest.Podman([]string{"image", "mount", ALPINE}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) - umount := podmanTest.PodmanNoCache([]string{"image", "umount", ALPINE}) + umount := podmanTest.Podman([]string{"image", "umount", ALPINE}) umount.WaitWithDefaultTimeout() Expect(umount.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(Equal("")) // Mount multiple times - mount = podmanTest.PodmanNoCache([]string{"image", "mount", ALPINE}) + mount = podmanTest.Podman([]string{"image", "mount", ALPINE}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount", ALPINE}) + mount = podmanTest.Podman([]string{"image", "mount", ALPINE}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) // Unmount once - mount = podmanTest.PodmanNoCache([]string{"image", "mount", ALPINE}) + mount = podmanTest.Podman([]string{"image", "mount", ALPINE}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(ContainSubstring(ALPINE)) - mount = podmanTest.PodmanNoCache([]string{"image", "umount", "--all"}) + mount = podmanTest.Podman([]string{"image", "umount", "--all"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) }) It("podman mount with json format", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", fedoraMinimal}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - mount := podmanTest.PodmanNoCache([]string{"image", "mount", fedoraMinimal}) + podmanTest.AddImageToRWStore(fedoraMinimal) + mount := podmanTest.Podman([]string{"image", "mount", fedoraMinimal}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) - j := podmanTest.PodmanNoCache([]string{"image", "mount", "--format=json"}) + j := podmanTest.Podman([]string{"image", "mount", "--format=json"}) j.WaitWithDefaultTimeout() Expect(j.ExitCode()).To(Equal(0)) Expect(j.IsJSONOutputValid()).To(BeTrue()) - umount := podmanTest.PodmanNoCache([]string{"image", "umount", fedoraMinimal}) + umount := podmanTest.Podman([]string{"image", "umount", fedoraMinimal}) umount.WaitWithDefaultTimeout() Expect(umount.ExitCode()).To(Equal(0)) }) It("podman umount --all", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", fedoraMinimal}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - setup = podmanTest.PodmanNoCache([]string{"pull", ALPINE}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - + podmanTest.AddImageToRWStore(fedoraMinimal) mount := podmanTest.Podman([]string{"image", "mount", fedoraMinimal}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) @@ -365,78 +350,70 @@ var _ = Describe("Podman mount", func() { }) It("podman mount many", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", fedoraMinimal}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - setup = podmanTest.PodmanNoCache([]string{"pull", ALPINE}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - setup = podmanTest.PodmanNoCache([]string{"pull", "busybox"}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) + Skip("Issue where using short name when we have a lookaside store") + podmanTest.AddImageToRWStore(fedoraMinimal) + podmanTest.AddImageToRWStore(BB) - mount1 := podmanTest.PodmanNoCache([]string{"image", "mount", fedoraMinimal, ALPINE, "busybox"}) + mount1 := podmanTest.Podman([]string{"image", "mount", fedoraMinimal, ALPINE, "busybox"}) mount1.WaitWithDefaultTimeout() Expect(mount1.ExitCode()).To(Equal(0)) - umount := podmanTest.PodmanNoCache([]string{"image", "umount", fedoraMinimal, ALPINE}) + umount := podmanTest.Podman([]string{"image", "umount", fedoraMinimal, ALPINE}) umount.WaitWithDefaultTimeout() Expect(umount.ExitCode()).To(Equal(0)) - mount := podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount := podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(ContainSubstring("busybox")) - mount1 = podmanTest.PodmanNoCache([]string{"image", "unmount", "busybox"}) + mount1 = podmanTest.Podman([]string{"image", "unmount", "busybox"}) mount1.WaitWithDefaultTimeout() Expect(mount1.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(Equal("")) - mount1 = podmanTest.PodmanNoCache([]string{"image", "mount", fedoraMinimal, ALPINE, "busybox"}) + mount1 = podmanTest.Podman([]string{"image", "mount", fedoraMinimal, ALPINE, "busybox"}) mount1.WaitWithDefaultTimeout() Expect(mount1.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(ContainSubstring(fedoraMinimal)) Expect(mount.OutputToString()).To(ContainSubstring(ALPINE)) - umount = podmanTest.PodmanNoCache([]string{"image", "umount", "--all"}) + umount = podmanTest.Podman([]string{"image", "umount", "--all"}) umount.WaitWithDefaultTimeout() Expect(umount.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(Equal("")) - umount = podmanTest.PodmanNoCache([]string{"image", "umount", fedoraMinimal, ALPINE}) + umount = podmanTest.Podman([]string{"image", "umount", fedoraMinimal, ALPINE}) umount.WaitWithDefaultTimeout() Expect(umount.ExitCode()).To(Equal(0)) - mount1 = podmanTest.PodmanNoCache([]string{"image", "mount", "--all"}) + mount1 = podmanTest.Podman([]string{"image", "mount", "--all"}) mount1.WaitWithDefaultTimeout() Expect(mount1.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(ContainSubstring(fedoraMinimal)) Expect(mount.OutputToString()).To(ContainSubstring(ALPINE)) - umount = podmanTest.PodmanNoCache([]string{"image", "umount", "--all"}) + umount = podmanTest.Podman([]string{"image", "umount", "--all"}) umount.WaitWithDefaultTimeout() Expect(umount.ExitCode()).To(Equal(0)) - mount = podmanTest.PodmanNoCache([]string{"image", "mount"}) + mount = podmanTest.Podman([]string{"image", "mount"}) mount.WaitWithDefaultTimeout() Expect(mount.ExitCode()).To(Equal(0)) Expect(mount.OutputToString()).To(Equal("")) diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go index 21f03901b..cb997d10a 100644 --- a/test/e2e/network_create_test.go +++ b/test/e2e/network_create_test.go @@ -177,8 +177,7 @@ var _ = Describe("Podman network create", func() { }) It("podman network create with name and IPv6 subnet", func() { - SkipIfRootless("FIXME I believe this should work in rootlessmode") - + SkipIfRootless("FIXME It needs the ip6tables modules loaded") var ( results []network.NcList ) @@ -218,12 +217,72 @@ var _ = Describe("Podman network create", func() { Expect(subnet.Contains(containerIP)).To(BeTrue()) }) + It("podman network create with name and IPv6 flag (dual-stack)", func() { + SkipIfRootless("FIXME It needs the ip6tables modules loaded") + var ( + results []network.NcList + ) + nc := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:3:2:1::/64", "--ipv6", "newDualStacknetwork"}) + nc.WaitWithDefaultTimeout() + Expect(nc.ExitCode()).To(BeZero()) + + defer podmanTest.removeCNINetwork("newDualStacknetwork") + + // Inspect the network configuration + inspect := podmanTest.Podman([]string{"network", "inspect", "newDualStacknetwork"}) + inspect.WaitWithDefaultTimeout() + + // JSON the network configuration into something usable + err := json.Unmarshal([]byte(inspect.OutputToString()), &results) + Expect(err).To(BeNil()) + result := results[0] + Expect(result["name"]).To(Equal("newDualStacknetwork")) + + // JSON the bridge info + bridgePlugin, err := genericPluginsToBridge(result["plugins"], "bridge") + Expect(err).To(BeNil()) + Expect(bridgePlugin.IPAM.Routes[0].Dest).To(Equal("::/0")) + Expect(bridgePlugin.IPAM.Routes[1].Dest).To(Equal("0.0.0.0/0")) + + // Once a container executes a new network, the nic will be created. We should clean those up + // best we can + defer removeNetworkDevice(bridgePlugin.BrName) + + try := podmanTest.Podman([]string{"run", "-it", "--rm", "--network", "newDualStacknetwork", ALPINE, "sh", "-c", "ip addr show eth0 | grep global | awk ' /inet6 / {print $2}'"}) + try.WaitWithDefaultTimeout() + + _, subnet, err := net.ParseCIDR("fd00:4:3:2:1::/64") + Expect(err).To(BeNil()) + containerIP, _, err := net.ParseCIDR(try.OutputToString()) + Expect(err).To(BeNil()) + // Ensure that the IP the container got is within the subnet the user asked for + Expect(subnet.Contains(containerIP)).To(BeTrue()) + // verify the container has an IPv4 address too (the IPv4 subnet is autogenerated) + try = podmanTest.Podman([]string{"run", "-it", "--rm", "--network", "newDualStacknetwork", ALPINE, "sh", "-c", "ip addr show eth0 | awk ' /inet / {print $2}'"}) + try.WaitWithDefaultTimeout() + containerIP, _, err = net.ParseCIDR(try.OutputToString()) + Expect(err).To(BeNil()) + Expect(containerIP.To4()).To(Not(BeNil())) + }) + It("podman network create with invalid subnet", func() { nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.12.0/17000", "fail"}) nc.WaitWithDefaultTimeout() Expect(nc).To(ExitWithError()) }) + It("podman network create with ipv4 subnet and ipv6 flag", func() { + nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.12.0/24", "--ipv6", "fail"}) + nc.WaitWithDefaultTimeout() + Expect(nc).To(ExitWithError()) + }) + + It("podman network create with empty subnet and ipv6 flag", func() { + nc := podmanTest.Podman([]string{"network", "create", "--ipv6", "fail"}) + nc.WaitWithDefaultTimeout() + Expect(nc).To(ExitWithError()) + }) + It("podman network create with invalid IP", func() { nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.0/17000", "fail"}) nc.WaitWithDefaultTimeout() @@ -247,6 +306,29 @@ var _ = Describe("Podman network create", func() { Expect(ncFail).To(ExitWithError()) }) + It("podman network create two networks with same subnet should fail", func() { + nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.13.0/24", "subnet1"}) + nc.WaitWithDefaultTimeout() + Expect(nc.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork("subnet1") + + ncFail := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.13.0/24", "subnet2"}) + ncFail.WaitWithDefaultTimeout() + Expect(ncFail).To(ExitWithError()) + }) + + It("podman network create two IPv6 networks with same subnet should fail", func() { + SkipIfRootless("FIXME It needs the ip6tables modules loaded") + nc := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:4:4:4::/64", "--ipv6", "subnet1v6"}) + nc.WaitWithDefaultTimeout() + Expect(nc.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork("subnet1v6") + + ncFail := podmanTest.Podman([]string{"network", "create", "--subnet", "fd00:4:4:4:4::/64", "--ipv6", "subnet2v6"}) + ncFail.WaitWithDefaultTimeout() + Expect(ncFail).To(ExitWithError()) + }) + It("podman network create with invalid network name", func() { nc := podmanTest.Podman([]string{"network", "create", "foo "}) nc.WaitWithDefaultTimeout() diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 9bd16c008..adcf74f7e 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -2,10 +2,9 @@ package integration import ( "fmt" - "io/ioutil" "os" - "path/filepath" "strings" + "time" "github.com/containers/podman/v2/pkg/rootless" . "github.com/containers/podman/v2/test/utils" @@ -14,53 +13,6 @@ import ( . "github.com/onsi/gomega" ) -func writeConf(conf []byte, confPath string) { - if err := ioutil.WriteFile(confPath, conf, 777); err != nil { - fmt.Println(err) - } -} -func removeConf(confPath string) { - if err := os.Remove(confPath); err != nil { - fmt.Println(err) - } -} - -// generateNetworkConfig generates a cni config with a random name -// it returns the network name and the filepath -func generateNetworkConfig(p *PodmanTestIntegration) (string, string) { - // generate a random name to prevent conflicts with other tests - name := "net" + stringid.GenerateNonCryptoID() - path := filepath.Join(p.CNIConfigDir, fmt.Sprintf("%s.conflist", name)) - conf := fmt.Sprintf(`{ - "cniVersion": "0.3.0", - "name": "%s", - "plugins": [ - { - "type": "bridge", - "bridge": "cni1", - "isGateway": true, - "ipMasq": true, - "ipam": { - "type": "host-local", - "subnet": "10.99.0.0/16", - "routes": [ - { "dst": "0.0.0.0/0" } - ] - } - }, - { - "type": "portmap", - "capabilities": { - "portMappings": true - } - } - ] - }`, name) - writeConf([]byte(conf), path) - - return name, path -} - var _ = Describe("Podman network", func() { var ( tempdir string @@ -124,31 +76,36 @@ var _ = Describe("Podman network", func() { Expect(session.LineInOutputContains(name)).To(BeFalse()) }) - It("podman network rm no args", func() { - session := podmanTest.Podman([]string{"network", "rm"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).ToNot(BeZero()) - }) + rm_func := func(rm string) { + It(fmt.Sprintf("podman network %s no args", rm), func() { + session := podmanTest.Podman([]string{"network", rm}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).ToNot(BeZero()) - It("podman network rm", func() { - SkipIfRootless("FIXME: This one is definitely broken in rootless mode") - name, path := generateNetworkConfig(podmanTest) - defer removeConf(path) + }) - session := podmanTest.Podman([]string{"network", "ls", "--quiet"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - Expect(session.LineInOutputContains(name)).To(BeTrue()) + It(fmt.Sprintf("podman network %s", rm), func() { + name, path := generateNetworkConfig(podmanTest) + defer removeConf(path) - rm := podmanTest.Podman([]string{"network", "rm", name}) - rm.WaitWithDefaultTimeout() - Expect(rm.ExitCode()).To(BeZero()) + session := podmanTest.Podman([]string{"network", "ls", "--quiet"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.LineInOutputContains(name)).To(BeTrue()) - results := podmanTest.Podman([]string{"network", "ls", "--quiet"}) - results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) - Expect(results.LineInOutputContains(name)).To(BeFalse()) - }) + rm := podmanTest.Podman([]string{"network", rm, name}) + rm.WaitWithDefaultTimeout() + Expect(rm.ExitCode()).To(BeZero()) + + results := podmanTest.Podman([]string{"network", "ls", "--quiet"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(results.LineInOutputContains(name)).To(BeFalse()) + }) + } + + rm_func("rm") + rm_func("remove") It("podman network inspect no args", func() { session := podmanTest.Podman([]string{"network", "inspect"}) @@ -351,4 +308,206 @@ var _ = Describe("Podman network", func() { Expect(lines[0]).To(Equal(netName1)) Expect(lines[1]).To(Equal(netName2)) }) + It("podman network with multiple aliases", func() { + Skip("Until DNSName is updated on our CI images") + var worked bool + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + top := podmanTest.Podman([]string{"run", "-dt", "--name=web", "--network=" + netName, "--network-alias=web1", "--network-alias=web2", nginx}) + top.WaitWithDefaultTimeout() + Expect(top.ExitCode()).To(BeZero()) + interval := time.Duration(250 * time.Millisecond) + // Wait for the nginx service to be running + for i := 0; i < 6; i++ { + // Test curl against the container's name + c1 := podmanTest.Podman([]string{"run", "--network=" + netName, nginx, "curl", "web"}) + c1.WaitWithDefaultTimeout() + worked = Expect(c1.ExitCode()).To(BeZero()) + if worked { + break + } + time.Sleep(interval) + interval *= 2 + } + Expect(worked).To(BeTrue()) + + // Nginx is now running so no need to do a loop + // Test against the first alias + c2 := podmanTest.Podman([]string{"run", "--network=" + netName, nginx, "curl", "web1"}) + c2.WaitWithDefaultTimeout() + Expect(c2.ExitCode()).To(BeZero()) + + // Test against the second alias + c3 := podmanTest.Podman([]string{"run", "--network=" + netName, nginx, "curl", "web2"}) + c3.WaitWithDefaultTimeout() + Expect(c3.ExitCode()).To(BeZero()) + }) + + It("bad network name in disconnect should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + dis := podmanTest.Podman([]string{"network", "disconnect", "foobar", "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).ToNot(BeZero()) + + }) + + It("bad container name in network disconnect should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + dis := podmanTest.Podman([]string{"network", "disconnect", netName, "foobar"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).ToNot(BeZero()) + + }) + + It("podman network disconnect with invalid container state should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + ctr := podmanTest.Podman([]string{"create", "--name", "test", "--network", netName, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + dis := podmanTest.Podman([]string{"network", "disconnect", netName, "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).ToNot(BeZero()) + }) + + It("podman network disconnect", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + ctr := podmanTest.Podman([]string{"run", "-dt", "--name", "test", "--network", netName, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + + dis := podmanTest.Podman([]string{"network", "disconnect", netName, "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).To(BeZero()) + + exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).ToNot(BeZero()) + }) + + It("bad network name in connect should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + dis := podmanTest.Podman([]string{"network", "connect", "foobar", "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).ToNot(BeZero()) + + }) + + It("bad container name in network connect should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + dis := podmanTest.Podman([]string{"network", "connect", netName, "foobar"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).ToNot(BeZero()) + + }) + + It("podman connect on a container that already is connected to the network should error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + ctr := podmanTest.Podman([]string{"create", "--name", "test", "--network", netName, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + con := podmanTest.Podman([]string{"network", "connect", netName, "test"}) + con.WaitWithDefaultTimeout() + Expect(con.ExitCode()).ToNot(BeZero()) + }) + + It("podman network connect with invalid container state should result in error", func() { + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + ctr := podmanTest.Podman([]string{"create", "--name", "test", "--network", netName, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + dis := podmanTest.Podman([]string{"network", "connect", netName, "test"}) + dis.WaitWithDefaultTimeout() + Expect(dis.ExitCode()).ToNot(BeZero()) + }) + + It("podman network connect", func() { + SkipIfRemote("This requires a pending PR to be merged before it will work") + SkipIfRootless("network connect and disconnect are only rootfull") + netName := "aliasTest" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", netName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(netName) + + ctr := podmanTest.Podman([]string{"run", "-dt", "--name", "test", "--network", netName, ALPINE, "top"}) + ctr.WaitWithDefaultTimeout() + Expect(ctr.ExitCode()).To(BeZero()) + + exec := podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + + // Create a second network + newNetName := "aliasTest" + stringid.GenerateNonCryptoID() + session = podmanTest.Podman([]string{"network", "create", newNetName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + defer podmanTest.removeCNINetwork(newNetName) + + connect := podmanTest.Podman([]string{"network", "connect", newNetName, "test"}) + connect.WaitWithDefaultTimeout() + Expect(connect.ExitCode()).To(BeZero()) + + exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"}) + exec.WaitWithDefaultTimeout() + Expect(exec.ExitCode()).To(BeZero()) + }) + + It("podman network create/remove macvlan", func() { + net := "macvlan" + stringid.GenerateNonCryptoID() + nc := podmanTest.Podman([]string{"network", "create", "--macvlan", "lo", net}) + nc.WaitWithDefaultTimeout() + Expect(nc.ExitCode()).To(Equal(0)) + + nc = podmanTest.Podman([]string{"network", "rm", net}) + nc.WaitWithDefaultTimeout() + Expect(nc.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 7ab8dc6f8..5ecfdd6b5 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -164,9 +164,15 @@ spec: volumes: {{ range . }} - name: {{ .Name }} + {{- if (eq .VolumeType "HostPath") }} hostPath: - path: {{ .Path }} - type: {{ .Type }} + path: {{ .HostPath.Path }} + type: {{ .HostPath.Type }} + {{- end }} + {{- if (eq .VolumeType "PersistentVolumeClaim") }} + persistentVolumeClaim: + claimName: {{ .PersistentVolumeClaim.ClaimName }} + {{- end }} {{ end }} {{ end }} status: {} @@ -692,19 +698,44 @@ func getCtrNameInPod(pod *Pod) string { return fmt.Sprintf("%s-%s", pod.Name, defaultCtrName) } -type Volume struct { - Name string +type HostPath struct { Path string Type string } -// getVolume takes a type and a location for a volume -// giving it a default name of volName -func getVolume(vType, vPath string) *Volume { +type PersistentVolumeClaim struct { + ClaimName string +} + +type Volume struct { + VolumeType string + Name string + HostPath + PersistentVolumeClaim +} + +// getHostPathVolume takes a type and a location for a HostPath +// volume giving it a default name of volName +func getHostPathVolume(vType, vPath string) *Volume { + return &Volume{ + VolumeType: "HostPath", + Name: defaultVolName, + HostPath: HostPath{ + Path: vPath, + Type: vType, + }, + } +} + +// getHostPathVolume takes a name for a Persistentvolumeclaim +// volume giving it a default name of volName +func getPersistentVolumeClaimVolume(vName string) *Volume { return &Volume{ - Name: defaultVolName, - Path: vPath, - Type: vType, + VolumeType: "PersistentVolumeClaim", + Name: defaultVolName, + PersistentVolumeClaim: PersistentVolumeClaim{ + ClaimName: vName, + }, } } @@ -959,7 +990,7 @@ var _ = Describe("Podman play kube", func() { kube.WaitWithDefaultTimeout() Expect(kube.ExitCode()).To(Equal(0)) - inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(pod), "--format", "{{ .HostConfig.ExtraHosts }}"}) + inspect := podmanTest.Podman([]string{"inspect", pod.Name, "--format", "{{ .InfraConfig.HostAdd}}"}) inspect.WaitWithDefaultTimeout() Expect(inspect.ExitCode()).To(Equal(0)) Expect(inspect.OutputToString()). @@ -1092,7 +1123,7 @@ var _ = Describe("Podman play kube", func() { }) It("podman play kube with pull always", func() { - oldBB := "docker.io/library/busybox:1.30.1" + oldBB := "quay.io/libpod/busybox:1.30.1" pull := podmanTest.Podman([]string{"pull", oldBB}) pull.WaitWithDefaultTimeout() @@ -1123,7 +1154,7 @@ var _ = Describe("Podman play kube", func() { }) It("podman play kube with latest image should always pull", func() { - oldBB := "docker.io/library/busybox:1.30.1" + oldBB := "quay.io/libpod/busybox:1.30.1" pull := podmanTest.Podman([]string{"pull", oldBB}) pull.WaitWithDefaultTimeout() @@ -1257,7 +1288,7 @@ spec: It("podman play kube test with non-existent empty HostPath type volume", func() { hostPathLocation := filepath.Join(tempdir, "file") - pod := getPod(withVolume(getVolume(`""`, hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume(`""`, hostPathLocation))) err := generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1272,7 +1303,7 @@ spec: Expect(err).To(BeNil()) f.Close() - pod := getPod(withVolume(getVolume(`""`, hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume(`""`, hostPathLocation))) err = generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1284,7 +1315,7 @@ spec: It("podman play kube test with non-existent File HostPath type volume", func() { hostPathLocation := filepath.Join(tempdir, "file") - pod := getPod(withVolume(getVolume("File", hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation))) err := generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1299,7 +1330,7 @@ spec: Expect(err).To(BeNil()) f.Close() - pod := getPod(withVolume(getVolume("File", hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation))) err = generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1311,7 +1342,7 @@ spec: It("podman play kube test with FileOrCreate HostPath type volume", func() { hostPathLocation := filepath.Join(tempdir, "file") - pod := getPod(withVolume(getVolume("FileOrCreate", hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume("FileOrCreate", hostPathLocation))) err := generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1327,7 +1358,7 @@ spec: It("podman play kube test with DirectoryOrCreate HostPath type volume", func() { hostPathLocation := filepath.Join(tempdir, "file") - pod := getPod(withVolume(getVolume("DirectoryOrCreate", hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume("DirectoryOrCreate", hostPathLocation))) err := generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1347,7 +1378,7 @@ spec: Expect(err).To(BeNil()) f.Close() - pod := getPod(withVolume(getVolume("Socket", hostPathLocation))) + pod := getPod(withVolume(getHostPathVolume("Socket", hostPathLocation))) err = generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1356,14 +1387,14 @@ spec: Expect(kube.ExitCode()).NotTo(Equal(0)) }) - It("podman play kube test with read only volume", func() { + It("podman play kube test with read only HostPath volume", func() { hostPathLocation := filepath.Join(tempdir, "file") f, err := os.Create(hostPathLocation) Expect(err).To(BeNil()) f.Close() ctr := getCtr(withVolumeMount(hostPathLocation, true), withImage(BB)) - pod := getPod(withVolume(getVolume("File", hostPathLocation)), withCtr(ctr)) + pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)), withCtr(ctr)) err = generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) @@ -1379,6 +1410,26 @@ spec: Expect(inspect.OutputToString()).To(ContainSubstring(correct)) }) + It("podman play kube test with PersistentVolumeClaim volume", func() { + volumeName := "namedVolume" + + ctr := getCtr(withVolumeMount("/test", false), withImage(BB)) + pod := getPod(withVolume(getPersistentVolumeClaimVolume(volumeName)), withCtr(ctr)) + err = generateKubeYaml("pod", pod, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(pod), "--format", "{{ (index .Mounts 0).Type }}:{{ (index .Mounts 0).Name }}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + + correct := fmt.Sprintf("volume:%s", volumeName) + Expect(inspect.OutputToString()).To(Equal(correct)) + }) + It("podman play kube applies labels to pods", func() { var numReplicas int32 = 5 expectedLabelKey := "key1" @@ -1406,7 +1457,7 @@ spec: It("podman play kube allows setting resource limits", func() { SkipIfContainerized("Resource limits require a running systemd") SkipIfRootlessCgroupsV1("Limits require root or cgroups v2") - SkipIfUnprevilegedCPULimits() + SkipIfUnprivilegedCPULimits() podmanTest.CgroupManager = "systemd" var ( @@ -1466,4 +1517,35 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`}) Expect(kube.ExitCode()).To(Equal(125)) Expect(kube.ErrorToString()).To(ContainSubstring(invalidImageName)) }) + + It("podman play kube applies log driver to containers", func() { + Skip("need to verify images have correct packages for journald") + pod := getPod() + err := generateKubeYaml("pod", pod, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", "--log-driver", "journald", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(pod), "--format", "'{{ .HostConfig.LogConfig.Type }}'"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.OutputToString()).To(ContainSubstring("journald")) + }) + + It("podman play kube test only creating the containers", func() { + pod := getPod() + err := generateKubeYaml("pod", pod, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", "--start=false", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(pod), "--format", "{{ .State.Running }}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.OutputToString()).To(Equal("false")) + }) }) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 83a66d2b9..ccfbcefae 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -9,6 +9,7 @@ import ( "github.com/containers/podman/v2/pkg/rootless" . "github.com/containers/podman/v2/test/utils" + "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -382,7 +383,7 @@ var _ = Describe("Podman pod create", func() { }) It("podman create pod with --infra-image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest entrypoint ["/fromimage"] ` podmanTest.BuildImage(dockerfile, "localhost/infra", "false") @@ -409,7 +410,7 @@ entrypoint ["/fromimage"] }) It("podman create pod with --infra-command --infra-image", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest entrypoint ["/fromimage"] ` podmanTest.BuildImage(dockerfile, "localhost/infra", "false") @@ -446,4 +447,53 @@ entrypoint ["/fromimage"] Expect(check.ExitCode()).To(Equal(0)) Expect(check.OutputToString()).To(Equal("[port_handler=slirp4netns]")) }) + + It("podman pod status test", func() { + podName := "testpod" + create := podmanTest.Podman([]string{"pod", "create", "--name", podName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + status1 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName}) + status1.WaitWithDefaultTimeout() + Expect(status1.ExitCode()).To(Equal(0)) + Expect(strings.Contains(status1.OutputToString(), "Created")).To(BeTrue()) + + ctr1 := podmanTest.Podman([]string{"run", "--pod", podName, "-d", ALPINE, "top"}) + ctr1.WaitWithDefaultTimeout() + Expect(ctr1.ExitCode()).To(Equal(0)) + + status2 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName}) + status2.WaitWithDefaultTimeout() + Expect(status2.ExitCode()).To(Equal(0)) + Expect(strings.Contains(status2.OutputToString(), "Running")).To(BeTrue()) + + ctr2 := podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + ctr2.WaitWithDefaultTimeout() + Expect(ctr2.ExitCode()).To(Equal(0)) + + status3 := podmanTest.Podman([]string{"pod", "inspect", "--format", "{{ .State }}", podName}) + status3.WaitWithDefaultTimeout() + Expect(status3.ExitCode()).To(Equal(0)) + Expect(strings.Contains(status3.OutputToString(), "Degraded")).To(BeTrue()) + }) + + It("podman create pod invalid network config", func() { + net1 := "n1" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", net1}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net1) + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"pod", "create", "--network", "host", "--network", net1}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + Expect(session.ErrorToString()).To(ContainSubstring("host")) + Expect(session.ErrorToString()).To(ContainSubstring("bridge")) + + session = podmanTest.Podman([]string{"pod", "create", "--network", "container:abc"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + Expect(session.ErrorToString()).To(ContainSubstring("pods presently do not support network mode container")) + }) }) diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 797d51c33..7ec36b2f8 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -383,12 +383,14 @@ var _ = Describe("Podman pod create", func() { podID := session.OutputToString() // verify we can add a host to the infra's /etc/hosts - session = podmanTest.Podman([]string{"run", "--pod", podID, "--add-host", "foobar:127.0.0.1", BB, "ping", "-c", "1", "foobar"}) + // N/B: Using alpine for ping, since BB ping throws + // permission denied error as of Fedora 33. + session = podmanTest.Podman([]string{"run", "--pod", podID, "--add-host", "foobar:127.0.0.1", ALPINE, "ping", "-c", "1", "foobar"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // verify we can see the other hosts of infra's /etc/hosts - session = podmanTest.Podman([]string{"run", "--pod", podID, BB, "ping", "-c", "1", "foobar"}) + session = podmanTest.Podman([]string{"run", "--pod", podID, ALPINE, "ping", "-c", "1", "foobar"}) 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 ccdf0a423..25212991d 100644 --- a/test/e2e/pod_inspect_test.go +++ b/test/e2e/pod_inspect_test.go @@ -99,4 +99,23 @@ var _ = Describe("Podman pod inspect", func() { Expect(len(inspectJSON.InfraConfig.PortBindings["80/tcp"])).To(Equal(1)) Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0].HostPort).To(Equal("8080")) }) + + It("podman pod inspect outputs show correct MAC", func() { + SkipIfRootless("--mac-address is not supported in rootless mode") + podName := "testPod" + macAddr := "42:43:44:00:00:01" + create := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--mac-address", macAddr}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + create = podmanTest.Podman([]string{"run", "-d", "--pod", podName, ALPINE, "top"}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(Equal(0)) + + inspectOut := podmanTest.Podman([]string{"pod", "inspect", podName}) + inspectOut.WaitWithDefaultTimeout() + Expect(inspectOut.ExitCode()).To(Equal(0)) + + Expect(inspectOut.OutputToString()).To(ContainSubstring(macAddr)) + }) }) diff --git a/test/e2e/pod_pod_namespaces.go b/test/e2e/pod_pod_namespaces_test.go index 41e9c5683..20b8bdb39 100644 --- a/test/e2e/pod_pod_namespaces.go +++ b/test/e2e/pod_pod_namespaces_test.go @@ -60,6 +60,25 @@ var _ = Describe("Podman pod create", func() { Expect(NAMESPACE1).To(Equal(NAMESPACE2)) }) + It("podman pod container share ipc && /dev/shm ", func() { + session := podmanTest.Podman([]string{"pod", "create"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + podID := session.OutputToString() + + session = podmanTest.Podman([]string{"pod", "start", podID}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "--rm", "--pod", podID, ALPINE, "touch", "/dev/shm/test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "--rm", "--pod", podID, ALPINE, "ls", "/dev/shm/test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman pod container dontshare PIDNS", func() { session := podmanTest.Podman([]string{"pod", "create"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go index a299d3cf2..ea8d10e78 100644 --- a/test/e2e/pod_ps_test.go +++ b/test/e2e/pod_ps_test.go @@ -107,6 +107,28 @@ var _ = Describe("Podman ps", func() { Expect(result.ExitCode()).To(Equal(0)) }) + It("podman pod ps filter name regexp", func() { + _, ec, podid := podmanTest.CreatePod("mypod") + Expect(ec).To(Equal(0)) + _, ec2, _ := podmanTest.CreatePod("mypod1") + Expect(ec2).To(Equal(0)) + + result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "name=mypod"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + output := result.OutputToStringArray() + Expect(len(output)).To(Equal(2)) + + result = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "name=mypod$"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + output = result.OutputToStringArray() + Expect(len(output)).To(Equal(1)) + Expect(output[0]).To(Equal(podid)) + }) + It("podman pod ps mutually exclusive flags", func() { session := podmanTest.Podman([]string{"pod", "ps", "-q", "--format", "{{.ID}}"}) session.WaitWithDefaultTimeout() @@ -172,12 +194,24 @@ var _ = Describe("Podman ps", func() { Expect(session.OutputToString()).To(ContainSubstring(podid1)) Expect(session.OutputToString()).To(Not(ContainSubstring(podid2))) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-names=test", "--filter", "ctr-status=running"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(podid1)) + Expect(session.OutputToString()).To(Not(ContainSubstring(podid2))) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", fmt.Sprintf("ctr-ids=%s", cid)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring(podid2)) Expect(session.OutputToString()).To(Not(ContainSubstring(podid1))) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-ids=" + cid[:40], "--filter", "ctr-ids=" + cid + "$"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(podid2)) + Expect(session.OutputToString()).To(Not(ContainSubstring(podid1))) + _, ec3, podid3 := podmanTest.CreatePod("") Expect(ec3).To(Equal(0)) @@ -188,6 +222,13 @@ var _ = Describe("Podman ps", func() { Expect(session.OutputToString()).To(ContainSubstring(podid2)) Expect(session.OutputToString()).To(Not(ContainSubstring(podid3))) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-number=1", "--filter", "ctr-number=0"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(podid1)) + Expect(session.OutputToString()).To(ContainSubstring(podid2)) + Expect(session.OutputToString()).To(ContainSubstring(podid3)) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-status=running"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -202,6 +243,13 @@ var _ = Describe("Podman ps", func() { Expect(session.OutputToString()).To(Not(ContainSubstring(podid1))) Expect(session.OutputToString()).To(Not(ContainSubstring(podid3))) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-status=exited", "--filter", "ctr-status=running"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(podid1)) + Expect(session.OutputToString()).To(ContainSubstring(podid2)) + Expect(session.OutputToString()).To(Not(ContainSubstring(podid3))) + session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-status=created"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index 969f96165..c02ed5a50 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -135,28 +135,29 @@ var _ = Describe("Podman prune", func() { }) It("podman image prune unused images", func() { - podmanTest.RestoreAllArtifacts() - prune := podmanTest.PodmanNoCache([]string{"image", "prune", "-af"}) + podmanTest.AddImageToRWStore(ALPINE) + podmanTest.AddImageToRWStore(BB) + prune := podmanTest.Podman([]string{"image", "prune", "-af"}) prune.WaitWithDefaultTimeout() Expect(prune.ExitCode()).To(Equal(0)) - images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) + images := podmanTest.Podman([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() // all images are unused, so they all should be deleted! - Expect(len(images.OutputToStringArray())).To(Equal(0)) + Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES))) }) It("podman system image prune unused images", func() { - podmanTest.RestoreAllArtifacts() + podmanTest.AddImageToRWStore(ALPINE) podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true") - prune := podmanTest.PodmanNoCache([]string{"system", "prune", "-a", "--force"}) + prune := podmanTest.Podman([]string{"system", "prune", "-a", "--force"}) prune.WaitWithDefaultTimeout() Expect(prune.ExitCode()).To(Equal(0)) - images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) + images := podmanTest.Podman([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() // all images are unused, so they all should be deleted! - Expect(len(images.OutputToStringArray())).To(Equal(0)) + Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES))) }) It("podman system prune pods", func() { @@ -343,9 +344,9 @@ var _ = Describe("Podman prune", func() { Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) - images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) + images := podmanTest.Podman([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() // all images are unused, so they all should be deleted! - Expect(len(images.OutputToStringArray())).To(Equal(0)) + Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES))) }) }) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 11d0b8c9b..05571157c 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -44,6 +44,12 @@ var _ = Describe("Podman ps", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman container ps no containers", func() { + session := podmanTest.Podman([]string{"container", "ps"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman ps default", func() { session := podmanTest.RunTopContainer("") session.WaitWithDefaultTimeout() @@ -232,12 +238,19 @@ var _ = Describe("Podman ps", func() { }) It("podman ps ancestor filter flag", func() { - _, ec, _ := podmanTest.RunLsContainer("test1") + _, ec, cid := podmanTest.RunLsContainer("test1") Expect(ec).To(Equal(0)) - result := podmanTest.Podman([]string{"ps", "-a", "--filter", "ancestor=docker.io/library/alpine:latest"}) + result := podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=quay.io/libpod/alpine:latest"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal(cid)) + + // Query just by image name, without :latest tag + result = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=quay.io/libpod/alpine"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal(cid)) }) It("podman ps id filter flag", func() { @@ -538,4 +551,126 @@ var _ = Describe("Podman ps", func() { Expect(result.ExitCode()).To(Equal(0)) Expect(result.OutputToString()).To(ContainSubstring("ago")) }) + + It("podman ps filter test", func() { + session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", "--label", "foo=1", + "--label", "bar=2", "--volume", "volume1:/test", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid1 := session.OutputToString() + + session = podmanTest.Podman([]string{"run", "--name", "test2", "--label", "foo=1", + ALPINE, "ls", "/fail"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(1)) + + session = podmanTest.Podman([]string{"create", "--name", "test3", ALPINE, cid1}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "--name", "test4", "--volume", "volume1:/test1", + "--volume", "/:/test2", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "name=test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(5)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.LineInOutputContains("test3")).To(BeTrue()) + Expect(session.LineInOutputContains("test4")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "name=test1", "--filter", "name=test2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + + // check container id matches with regex + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "id=" + cid1[:40], "--filter", "id=" + cid1 + "$"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--filter", "status=created"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test3")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--filter", "status=created", "--filter", "status=exited"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(4)) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.LineInOutputContains("test3")).To(BeTrue()) + Expect(session.LineInOutputContains("test4")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--filter", "label=foo=1", "--filter", "status=exited"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1", "--filter", "label=non=1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(1)) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "label=foo=1", "--filter", "label=bar=2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "exited=1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "exited=1", "--filter", "exited=0"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.LineInOutputContains("test2")).To(BeTrue()) + Expect(session.LineInOutputContains("test4")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "volume=volume1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + Expect(session.LineInOutputContains("test4")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "volume=/:/test2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test4")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "before=test2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.LineInOutputContains("test1")).To(BeTrue()) + + session = podmanTest.Podman([]string{"ps", "--all", "--filter", "since=test2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.LineInOutputContains("test3")).To(BeTrue()) + Expect(session.LineInOutputContains("test4")).To(BeTrue()) + }) }) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 08ab50de1..f1b055d6d 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -35,200 +35,200 @@ var _ = Describe("Podman pull", func() { }) It("podman pull from docker a not existing image", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "ibetthisdoesntexistthere:foo"}) + session := podmanTest.Podman([]string{"pull", "ibetthisdoesntexistthere:foo"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) }) It("podman pull from docker with tag", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "busybox:glibc"}) + session := podmanTest.Podman([]string{"pull", "quay.io/libpod/testdigest_v2s2:20200210"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "busybox:glibc"}) + session = podmanTest.Podman([]string{"rmi", "testdigest_v2s2:20200210"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from docker without tag", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "busybox"}) + session := podmanTest.Podman([]string{"pull", "quay.io/libpod/testdigest_v2s2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "busybox"}) + session = podmanTest.Podman([]string{"rmi", "testdigest_v2s2"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from alternate registry with tag", func() { - session := podmanTest.PodmanNoCache([]string{"pull", nginx}) + session := podmanTest.Podman([]string{"pull", cirros}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", nginx}) + session = podmanTest.Podman([]string{"rmi", cirros}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from alternate registry without tag", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/alpine_nginx"}) + session := podmanTest.Podman([]string{"pull", "quay.io/libpod/cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "quay.io/libpod/alpine_nginx"}) + session = podmanTest.Podman([]string{"rmi", "quay.io/libpod/cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull by digest", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"}) + session := podmanTest.Podman([]string{"pull", "quay.io/libpod/testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine:none"}) + session = podmanTest.Podman([]string{"rmi", "testdigest_v2s2:none"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull by digest (image list)", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "--override-arch=arm64", ALPINELISTDIGEST}) + session := podmanTest.Podman([]string{"pull", "--override-arch=arm64", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // inspect using the digest of the list - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(HavePrefix("[]")) // inspect using the digest of the list - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // inspect using the digest of the arch-specific image's manifest - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(HavePrefix("[]")) // inspect using the digest of the arch-specific image's manifest - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // inspect using the image ID - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(HavePrefix("[]")) // inspect using the image ID - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // remove using the digest of the list - session = podmanTest.PodmanNoCache([]string{"rmi", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"rmi", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull by instance digest (image list)", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "--override-arch=arm64", ALPINEARM64DIGEST}) + session := podmanTest.Podman([]string{"pull", "--override-arch=arm64", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // inspect using the digest of the list - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) // inspect using the digest of the list - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) // inspect using the digest of the arch-specific image's manifest - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(HavePrefix("[]")) // inspect using the digest of the arch-specific image's manifest - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(Not(ContainSubstring(ALPINELISTDIGEST))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // inspect using the image ID - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(HavePrefix("[]")) // inspect using the image ID - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(Not(ContainSubstring(ALPINELISTDIGEST))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // remove using the digest of the instance - session = podmanTest.PodmanNoCache([]string{"rmi", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"rmi", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull by tag (image list)", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "--override-arch=arm64", ALPINELISTTAG}) + session := podmanTest.Podman([]string{"pull", "--override-arch=arm64", ALPINELISTTAG}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // inspect using the tag we used for pulling - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTTAG}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTTAG}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) // inspect using the tag we used for pulling - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTTAG}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTTAG}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // inspect using the digest of the list - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) // inspect using the digest of the list - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // inspect using the digest of the arch-specific image's manifest - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) // inspect using the digest of the arch-specific image's manifest - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // inspect using the image ID - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) // inspect using the image ID - session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) + session = podmanTest.Podman([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) // remove using the tag - session = podmanTest.PodmanNoCache([]string{"rmi", ALPINELISTTAG}) + session = podmanTest.Podman([]string{"rmi", ALPINELISTTAG}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull bogus image", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "umohnani/get-started"}) + session := podmanTest.Podman([]string{"pull", "umohnani/get-started"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) }) @@ -236,26 +236,26 @@ var _ = Describe("Podman pull", func() { It("podman pull from docker-archive", func() { SkipIfRemote("podman-remote does not support pulling from docker-archive") - podmanTest.RestoreArtifact(ALPINE) - tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.PodmanNoCache([]string{"save", "-o", tarfn, "alpine"}) + podmanTest.AddImageToRWStore(cirros) + tarfn := filepath.Join(podmanTest.TempDir, "cirros.tar") + session := podmanTest.Podman([]string{"save", "-o", tarfn, "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Pulling a multi-image archive without further specifying // which image _must_ error out. Pulling is restricted to one // image. - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) expectedError := "Unexpected tar manifest.json: expected 1 item, got 2" @@ -264,31 +264,31 @@ var _ = Describe("Podman pull", func() { // Now pull _one_ image from a multi-image archive via the name // and index syntax. - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:@0")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:@0")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:example.com/empty:latest")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:example.com/empty:latest")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:@1")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:@1")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:example.com/empty/but:different")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:example.com/empty/but:different")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Now check for some errors. - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:foo.com/does/not/exist:latest")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:foo.com/does/not/exist:latest")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) expectedError = "Tag \"foo.com/does/not/exist:latest\" not found" found, _ = session.ErrorGrepString(expectedError) Expect(found).To(Equal(true)) - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:@2")}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/image/docker-two-images.tar.xz:@2")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) expectedError = "Invalid source index @2, only 2 manifest items available" @@ -299,19 +299,19 @@ var _ = Describe("Podman pull", func() { It("podman pull from oci-archive", func() { SkipIfRemote("podman-remote does not support pulling from oci-archive") - podmanTest.RestoreArtifact(ALPINE) - tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar") - session := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"}) + podmanTest.AddImageToRWStore(cirros) + tarfn := filepath.Join(podmanTest.TempDir, "oci-cirrus.tar") + session := podmanTest.Podman([]string{"save", "--format", "oci-archive", "-o", tarfn, "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -319,67 +319,61 @@ var _ = Describe("Podman pull", func() { It("podman pull from local directory", func() { SkipIfRemote("podman-remote does not support pulling from local directory") - podmanTest.RestoreArtifact(ALPINE) - dirpath := filepath.Join(podmanTest.TempDir, "alpine") + podmanTest.AddImageToRWStore(cirros) + dirpath := filepath.Join(podmanTest.TempDir, "cirros") os.MkdirAll(dirpath, os.ModePerm) imgPath := fmt.Sprintf("dir:%s", dirpath) - session := podmanTest.PodmanNoCache([]string{"push", "alpine", imgPath}) + session := podmanTest.Podman([]string{"push", "cirros", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", imgPath}) + session = podmanTest.Podman([]string{"pull", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"images"}) + session = podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue()) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) }) It("podman pull from local OCI directory", func() { SkipIfRemote("podman-remote does not support pulling from OCI directory") - podmanTest.RestoreArtifact(ALPINE) - dirpath := filepath.Join(podmanTest.TempDir, "alpine") + podmanTest.AddImageToRWStore(cirros) + dirpath := filepath.Join(podmanTest.TempDir, "cirros") os.MkdirAll(dirpath, os.ModePerm) imgPath := fmt.Sprintf("oci:%s", dirpath) - session := podmanTest.PodmanNoCache([]string{"push", "alpine", imgPath}) + session := podmanTest.Podman([]string{"push", "cirros", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + session = podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"pull", imgPath}) + session = podmanTest.Podman([]string{"pull", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"images"}) + session = podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue()) - 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.PodmanNoCache([]string{"images", ALPINE, "-q", "--no-trunc"}) + setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) shortImageId := strings.Split(setup.OutputToString(), ":")[1] - rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + rmi := podmanTest.Podman([]string{"rmi", ALPINE}) rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) - pull := podmanTest.PodmanNoCache([]string{"pull", "-q", ALPINE}) + pull := podmanTest.Podman([]string{"pull", "-q", ALPINE}) pull.WaitWithDefaultTimeout() Expect(pull.ExitCode()).To(Equal(0)) @@ -387,19 +381,19 @@ var _ = Describe("Podman pull", func() { }) It("podman pull check all tags", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "--all-tags", "k8s.gcr.io/pause"}) + session := podmanTest.Podman([]string{"pull", "--all-tags", "k8s.gcr.io/pause"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.LineInOuputStartsWith("Pulled Images:")).To(BeTrue()) - session = podmanTest.PodmanNoCache([]string{"images"}) + session = podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 4)) }) It("podman pull from docker with nonexist --authfile", func() { - session := podmanTest.PodmanNoCache([]string{"pull", "--authfile", "/tmp/nonexist", ALPINE}) + session := podmanTest.Podman([]string{"pull", "--authfile", "/tmp/nonexist", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Not(Equal(0))) }) @@ -421,7 +415,7 @@ var _ = Describe("Podman pull", func() { // A `podman inspect $name` must yield the one from the _first_ // matching registry in the registries.conf. getID := func(image string) string { - setup := podmanTest.PodmanNoCache([]string{"image", "inspect", image}) + setup := podmanTest.Podman([]string{"image", "inspect", image}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -431,11 +425,11 @@ var _ = Describe("Podman pull", func() { } untag := func(image string) { - setup := podmanTest.PodmanNoCache([]string{"untag", image}) + setup := podmanTest.Podman([]string{"untag", image}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"image", "inspect", image}) + setup = podmanTest.Podman([]string{"image", "inspect", image}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -445,10 +439,10 @@ var _ = Describe("Podman pull", func() { } tag := func(image, tag string) { - setup := podmanTest.PodmanNoCache([]string{"tag", image, tag}) + setup := podmanTest.Podman([]string{"tag", image, tag}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - setup = podmanTest.PodmanNoCache([]string{"image", "exists", tag}) + setup = podmanTest.Podman([]string{"image", "exists", tag}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) } @@ -489,7 +483,7 @@ var _ = Describe("Podman pull", func() { tag(image1, t.tag1) tag(image2, t.tag2) - setup := podmanTest.PodmanNoCache([]string{"image", "inspect", name}) + setup := podmanTest.Podman([]string{"image", "inspect", name}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 45b8769a2..922995060 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -28,7 +26,7 @@ var _ = Describe("Podman push", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.AddImageToRWStore(ALPINE) }) AfterEach(func() { @@ -39,24 +37,27 @@ var _ = Describe("Podman push", func() { }) It("podman push to containers/storage", func() { - session := podmanTest.PodmanNoCache([]string{"push", ALPINE, "containers-storage:busybox:test"}) + SkipIfRemote("Remote push does not support containers-storage transport") + session := podmanTest.Podman([]string{"push", ALPINE, "containers-storage:busybox:test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + session = podmanTest.Podman([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman push to dir", func() { + SkipIfRemote("Remote push does not support dir transport") bbdir := filepath.Join(podmanTest.TempDir, "busybox") - session := podmanTest.PodmanNoCache([]string{"push", "--remove-signatures", ALPINE, + session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, fmt.Sprintf("dir:%s", bbdir)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman push to local registry", func() { + SkipIfRemote("FIXME: This should work") if podmanTest.Host.Arch == "ppc64le" { Skip("No registry image for ppc64le") } @@ -65,7 +66,7 @@ var _ = Describe("Podman push", func() { } lock := GetPortLock("5000") defer lock.Unlock() - session := podmanTest.PodmanNoCache([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) + session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -73,12 +74,12 @@ var _ = Describe("Podman push", func() { Skip("Cannot start docker registry.") } - push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) // Test --digestfile option - push2 := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--digestfile=/tmp/digestfile.txt", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) + push2 := podmanTest.Podman([]string{"push", "--tls-verify=false", "--digestfile=/tmp/digestfile.txt", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) push2.WaitWithDefaultTimeout() fi, err := os.Lstat("/tmp/digestfile.txt") Expect(err).To(BeNil()) @@ -87,6 +88,7 @@ var _ = Describe("Podman push", func() { }) It("podman push to local registry with authorization", func() { + SkipIfRemote("FIXME: This does not seem to be returning an error") SkipIfRootless("FIXME: Creating content in certs.d we use directories in homedir") if podmanTest.Host.Arch == "ppc64le" { Skip("No registry image for ppc64le") @@ -113,7 +115,7 @@ var _ = Describe("Podman push", func() { } lock := GetPortLock("5000") defer lock.Unlock() - session := podmanTest.PodmanNoCache([]string{"run", "--entrypoint", "htpasswd", registry, "-Bbn", "podmantest", "test"}) + session := podmanTest.Podman([]string{"run", "--entrypoint", "htpasswd", registry, "-Bbn", "podmantest", "test"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -123,7 +125,7 @@ var _ = Describe("Podman push", func() { f.WriteString(session.OutputToString()) f.Sync() - session = podmanTest.PodmanNoCache([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v", + session = podmanTest.Podman([]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", @@ -135,42 +137,44 @@ var _ = Describe("Podman push", func() { Skip("Cannot start docker registry.") } - session = podmanTest.PodmanNoCache([]string{"logs", "registry"}) + session = podmanTest.Podman([]string{"logs", "registry"}) session.WaitWithDefaultTimeout() - push := podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/tlstest"}) + push := podmanTest.Podman([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/tlstest"}) push.WaitWithDefaultTimeout() Expect(push).To(ExitWithError()) - push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", "--tls-verify=false", ALPINE, "localhost:5000/tlstest"}) + push = podmanTest.Podman([]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.PodmanNoCache([]string{"push", "--creds=podmantest:wrongpasswd", ALPINE, "localhost:5000/credstest"}) + push = podmanTest.Podman([]string{"push", "--creds=podmantest:wrongpasswd", ALPINE, "localhost:5000/credstest"}) push.WaitWithDefaultTimeout() Expect(push).To(ExitWithError()) - push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", "--cert-dir=fakedir", ALPINE, "localhost:5000/certdirtest"}) + push = podmanTest.Podman([]string{"push", "--creds=podmantest:test", "--cert-dir=fakedir", ALPINE, "localhost:5000/certdirtest"}) push.WaitWithDefaultTimeout() Expect(push).To(ExitWithError()) - push = podmanTest.PodmanNoCache([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/defaultflags"}) + push = podmanTest.Podman([]string{"push", "--creds=podmantest:test", ALPINE, "localhost:5000/defaultflags"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) }) It("podman push to docker-archive", func() { + SkipIfRemote("Remote push does not support docker-archive transport") tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.PodmanNoCache([]string{"push", ALPINE, + session := podmanTest.Podman([]string{"push", ALPINE, fmt.Sprintf("docker-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman push to docker daemon", func() { + SkipIfRemote("Remote push does not support docker-daemon transport") setup := SystemExec("bash", []string{"-c", "systemctl status docker 2>&1"}) if setup.LineInOutputContains("Active: inactive") { @@ -183,7 +187,7 @@ var _ = Describe("Podman push", func() { Skip("Docker is not available") } - session := podmanTest.PodmanNoCache([]string{"push", ALPINE, "docker-daemon:alpine:podmantest"}) + session := podmanTest.Podman([]string{"push", ALPINE, "docker-daemon:alpine:podmantest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -196,24 +200,27 @@ var _ = Describe("Podman push", func() { }) It("podman push to oci-archive", func() { + SkipIfRemote("Remote push does not support oci-archive transport") tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.PodmanNoCache([]string{"push", ALPINE, + session := podmanTest.Podman([]string{"push", ALPINE, fmt.Sprintf("oci-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman push to docker-archive no reference", func() { + SkipIfRemote("Remote push does not support docker-archive transport") tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.PodmanNoCache([]string{"push", ALPINE, + session := podmanTest.Podman([]string{"push", ALPINE, fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman push to oci-archive no reference", func() { + SkipIfRemote("Remote push does not support oci-archive transport") ociarc := filepath.Join(podmanTest.TempDir, "alp-oci") - session := podmanTest.PodmanNoCache([]string{"push", ALPINE, + session := podmanTest.Podman([]string{"push", ALPINE, fmt.Sprintf("oci-archive:%s", ociarc)}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 7cb489113..c8d77b7c6 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -1,7 +1,6 @@ package integration import ( - "fmt" "os" . "github.com/containers/podman/v2/test/utils" @@ -24,7 +23,6 @@ var _ = Describe("Podman rmi", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -42,48 +40,50 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi with fq name", func() { - session := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + podmanTest.AddImageToRWStore(ALPINE) + session := podmanTest.Podman([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) It("podman rmi with short name", func() { - session := podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) + podmanTest.AddImageToRWStore(cirros) + session := podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) It("podman rmi all images", func() { - podmanTest.RestoreArtifact(nginx) - session := podmanTest.PodmanNoCache([]string{"rmi", "-a"}) + podmanTest.AddImageToRWStore(nginx) + session := podmanTest.Podman([]string{"rmi", "-a"}) session.WaitWithDefaultTimeout() - images := podmanTest.PodmanNoCache([]string{"images"}) + images := podmanTest.Podman([]string{"images"}) images.WaitWithDefaultTimeout() - fmt.Println(images.OutputToStringArray()) Expect(session).Should(Exit(0)) }) It("podman rmi all images forcibly with short options", func() { - podmanTest.RestoreArtifact(nginx) - session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) + podmanTest.AddImageToRWStore(nginx) + session := podmanTest.Podman([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) }) It("podman rmi tagged image", func() { - setup := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE}) + podmanTest.AddImageToRWStore(cirros) + setup := podmanTest.Podman([]string{"images", "-q", cirros}) setup.WaitWithDefaultTimeout() Expect(setup).Should(Exit(0)) - session := podmanTest.PodmanNoCache([]string{"tag", "alpine", "foo:bar", "foo"}) + session := podmanTest.Podman([]string{"tag", cirros, "foo:bar", "foo"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - result := podmanTest.PodmanNoCache([]string{"images", "-q", "foo"}) + result := podmanTest.Podman([]string{"images", "-q", "foo"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) @@ -91,114 +91,106 @@ var _ = Describe("Podman rmi", func() { }) It("podman rmi image with tags by ID cannot be done without force", func() { - setup := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE}) + podmanTest.AddImageToRWStore(cirros) + setup := podmanTest.Podman([]string{"images", "-q", cirros}) setup.WaitWithDefaultTimeout() Expect(setup).Should(Exit(0)) - alpineId := setup.OutputToString() + cirrosId := setup.OutputToString() - session := podmanTest.PodmanNoCache([]string{"tag", "alpine", "foo:bar", "foo"}) + session := podmanTest.Podman([]string{"tag", "cirros", "foo:bar", "foo"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) // Trying without --force should fail - result := podmanTest.PodmanNoCache([]string{"rmi", alpineId}) + result := podmanTest.Podman([]string{"rmi", cirrosId}) result.WaitWithDefaultTimeout() Expect(result).To(ExitWithError()) // With --force it should work - resultForce := podmanTest.PodmanNoCache([]string{"rmi", "-f", alpineId}) + resultForce := podmanTest.Podman([]string{"rmi", "-f", cirrosId}) resultForce.WaitWithDefaultTimeout() Expect(resultForce).Should(Exit(0)) }) It("podman rmi image that is a parent of another image", func() { - session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) + Skip("I need help with this one. i dont understand what is going on") + podmanTest.AddImageToRWStore(cirros) + session := podmanTest.Podman([]string{"run", "--name", "c_test", cirros, "true"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"run", "--name", "c_test", ALPINE, "true"}) + session = podmanTest.Podman([]string{"commit", "-q", "c_test", "test"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"commit", "-q", "c_test", "test"}) + session = podmanTest.Podman([]string{"rm", "c_test"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"rm", "c_test"}) + session = podmanTest.Podman([]string{"rmi", cirros}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + session = podmanTest.Podman([]string{"images", "-q"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) + Expect(len(session.OutputToStringArray())).To(Equal(12)) - session = podmanTest.PodmanNoCache([]string{"images", "-q"}) + session = podmanTest.Podman([]string{"images", "--sort", "created", "--format", "{{.Id}}", "--all"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(1)) - - session = podmanTest.PodmanNoCache([]string{"images", "--sort", "created", "--format", "{{.Id}}", "--all"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(2), + Expect(len(session.OutputToStringArray())).To(Equal(13), "Output from 'podman images -q -a':'%s'", session.Out.Contents()) untaggedImg := session.OutputToStringArray()[1] - session = podmanTest.PodmanNoCache([]string{"rmi", "-f", untaggedImg}) + session = podmanTest.Podman([]string{"rmi", "-f", untaggedImg}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(2), "UntaggedImg is '%s'", untaggedImg) }) It("podman rmi image that is created from another named imaged", func() { - session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - - session = podmanTest.PodmanNoCache([]string{"create", "--name", "c_test1", ALPINE, "true"}) + podmanTest.AddImageToRWStore(ALPINE) + session := podmanTest.Podman([]string{"create", "--name", "c_test1", ALPINE, "true"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"commit", "-q", "c_test1", "test1"}) + session = podmanTest.Podman([]string{"commit", "-q", "c_test1", "test1"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"create", "--name", "c_test2", "test1", "true"}) + session = podmanTest.Podman([]string{"create", "--name", "c_test2", "test1", "true"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"commit", "-q", "c_test2", "test2"}) + session = podmanTest.Podman([]string{"commit", "-q", "c_test2", "test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"rm", "-a"}) + session = podmanTest.Podman([]string{"rm", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "test2"}) + session = podmanTest.Podman([]string{"rmi", "test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"images", "-q"}) + session = podmanTest.Podman([]string{"images", "-q"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(len(session.OutputToStringArray())).To(Equal(len(CACHE_IMAGES) + 1)) }) It("podman rmi with cached images", func() { SkipIfRemote("FIXME This should work on podman-remote, problem is with podman-remote build") - - session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - - dockerfile := `FROM docker.io/library/alpine:latest + podmanTest.AddImageToRWStore(cirros) + dockerfile := `FROM quay.io/libpod/cirros:latest RUN mkdir hello RUN touch test.txt ENV foo=bar ` podmanTest.BuildImage(dockerfile, "test", "true") - dockerfile = `FROM docker.io/library/alpine:latest + dockerfile = `FROM quay.io/libpod/cirros:latest RUN mkdir hello RUN touch test.txt RUN mkdir blah @@ -206,57 +198,57 @@ var _ = Describe("Podman rmi", func() { ` podmanTest.BuildImage(dockerfile, "test2", "true") - session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) + session := podmanTest.Podman([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) numOfImages := len(session.OutputToStringArray()) - session = podmanTest.PodmanNoCache([]string{"rmi", "test2"}) + session = podmanTest.Podman([]string{"rmi", "test2"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) + session = podmanTest.Podman([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(numOfImages - len(session.OutputToStringArray())).To(Equal(2)) - session = podmanTest.PodmanNoCache([]string{"rmi", "test"}) + session = podmanTest.Podman([]string{"rmi", "test"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) + session = podmanTest.Podman([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToStringArray())).To(Equal(1)) + Expect(len(session.OutputToStringArray())).To(Equal(12)) podmanTest.BuildImage(dockerfile, "test3", "true") - session = podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) + session = podmanTest.Podman([]string{"rmi", cirros}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "test3"}) + session = podmanTest.Podman([]string{"rmi", "test3"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session = podmanTest.PodmanNoCache([]string{"images", "-q", "-a"}) + session = podmanTest.Podman([]string{"images", "-q", "-a"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(len(session.OutputToString())).To(Equal(0)) + Expect(len(session.OutputToString())).To(Equal(142)) }) It("podman rmi -a with no images should be exit 0", func() { - session := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) + session := podmanTest.Podman([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - session2 := podmanTest.PodmanNoCache([]string{"rmi", "-fa"}) + session2 := podmanTest.Podman([]string{"rmi", "-fa"}) session2.WaitWithDefaultTimeout() Expect(session2).Should(Exit(0)) }) It("podman rmi -a with parent|child images", func() { - dockerfile := `FROM docker.io/library/alpine:latest AS base + dockerfile := `FROM quay.io/libpod/cirros:latest AS base RUN touch /1 ENV LOCAL=/1 RUN find $LOCAL @@ -265,21 +257,20 @@ RUN find $LOCAL ` podmanTest.BuildImage(dockerfile, "test", "true") - session := podmanTest.PodmanNoCache([]string{"rmi", "-a"}) + session := podmanTest.Podman([]string{"rmi", "-a"}) session.WaitWithDefaultTimeout() - fmt.Println(session.OutputToString()) Expect(session).Should(Exit(0)) - images := podmanTest.PodmanNoCache([]string{"images", "-aq"}) + images := podmanTest.Podman([]string{"images", "-aq"}) images.WaitWithDefaultTimeout() Expect(images).Should(Exit(0)) - Expect(len(images.OutputToStringArray())).To(Equal(0)) + Expect(len(images.OutputToStringArray())).To(Equal(len(CACHE_IMAGES))) }) // 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.PodmanNoCache([]string{"image", "rm"}) + session := podmanTest.Podman([]string{"image", "rm"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(125)) match, _ := session.ErrorGrepString("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 5765d5ef6..35628d44b 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index db802946e..2185d6b13 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -33,7 +33,7 @@ var _ = Describe("Podman run entrypoint", func() { }) It("podman run no command, entrypoint, or cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT [] CMD [] ` @@ -44,7 +44,7 @@ CMD [] }) It("podman run entrypoint", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false") @@ -55,7 +55,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run entrypoint with cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD [ "-v"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` @@ -67,7 +67,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run entrypoint with user cmd overrides image cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD [ "-v"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` @@ -79,7 +79,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run entrypoint with user cmd no image cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false") @@ -91,7 +91,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] It("podman run user entrypoint overrides image entrypoint and image cmd", func() { SkipIfRemote("FIXME: podman-remote not handling passing --entrypoint=\"\" flag correctly") - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD ["-i"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` @@ -108,7 +108,7 @@ ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] }) It("podman run user entrypoint with command overrides image entrypoint and image cmd", func() { - dockerfile := `FROM docker.io/library/alpine:latest + dockerfile := `FROM quay.io/libpod/alpine:latest CMD ["-i"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ` diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 9f6fd8602..1d416498c 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -6,6 +6,7 @@ import ( "strings" . "github.com/containers/podman/v2/test/utils" + "github.com/containers/storage/pkg/stringid" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/uber/jaeger-client-go/utils" @@ -550,6 +551,10 @@ var _ = Describe("Podman run networking", func() { run.WaitWithDefaultTimeout() Expect(run.ExitCode()).To(BeZero()) Expect(run.OutputToString()).To(ContainSubstring(ipAddr)) + + create = podmanTest.Podman([]string{"network", "rm", netName}) + create.WaitWithDefaultTimeout() + Expect(create.ExitCode()).To(BeZero()) }) It("podman run with new:pod and static-ip", func() { @@ -587,11 +592,106 @@ var _ = Describe("Podman run networking", func() { Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) - It("podman run with --net=none adds hostname to /etc/hosts", func() { + It("podman run with --net=none sets hostname", func() { hostname := "testctr" run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "hostname"}) run.WaitWithDefaultTimeout() Expect(run.ExitCode()).To(BeZero()) Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) }) + + It("podman run with --net=none adds hostname to /etc/hosts", func() { + hostname := "testctr" + run := podmanTest.Podman([]string{"run", "--net=none", "--hostname", hostname, ALPINE, "cat", "/etc/hosts"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + Expect(strings.Contains(run.OutputToString(), hostname)).To(BeTrue()) + }) + + ping_test := func(netns string) { + hostname := "testctr" + run := podmanTest.Podman([]string{"run", netns, "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + + run = podmanTest.Podman([]string{"run", netns, "--hostname", hostname, "--name", "test", ALPINE, "ping", "-c", "1", "test"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + } + + It("podman attempt to ping container name and hostname --net=none", func() { + ping_test("--net=none") + }) + + It("podman attempt to ping container name and hostname --net=host", func() { + ping_test("--net=host") + }) + + It("podman attempt to ping container name and hostname --net=private", func() { + ping_test("--net=private") + }) + + It("podman run check dnsname plugin", func() { + pod := "testpod" + session := podmanTest.Podman([]string{"pod", "create", "--name", pod}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + net := "IntTest" + stringid.GenerateNonCryptoID() + session = podmanTest.Podman([]string{"network", "create", net}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net) + Expect(session.ExitCode()).To(BeZero()) + + pod2 := "testpod2" + session = podmanTest.Podman([]string{"pod", "create", "--network", net, "--name", pod2}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--name", "con1", "--network", net, ALPINE, "nslookup", "con1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--name", "con2", "--pod", pod, "--network", net, ALPINE, "nslookup", "con2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + session = podmanTest.Podman([]string{"run", "--name", "con3", "--pod", pod2, ALPINE, "nslookup", "con1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(1)) + Expect(session.ErrorToString()).To(ContainSubstring("can't resolve 'con1'")) + + session = podmanTest.Podman([]string{"run", "--name", "con4", "--network", net, ALPINE, "nslookup", pod2}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + }) + + It("podman run with multiple networks", func() { + net1 := "n1" + stringid.GenerateNonCryptoID() + session := podmanTest.Podman([]string{"network", "create", net1}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net1) + Expect(session.ExitCode()).To(BeZero()) + + net2 := "n2" + stringid.GenerateNonCryptoID() + session = podmanTest.Podman([]string{"network", "create", net2}) + session.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net2) + Expect(session.ExitCode()).To(BeZero()) + + run := podmanTest.Podman([]string{"run", "--network", net1, "--network", net2, ALPINE, "ip", "-o", "-4", "addr"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(BeZero()) + Expect(len(run.OutputToStringArray())).To(Equal(3)) + Expect(run.OutputToString()).To(ContainSubstring("lo")) + Expect(run.OutputToString()).To(ContainSubstring("eth0")) + Expect(run.OutputToString()).To(ContainSubstring("eth1")) + + //invalid config network host and cni should fail + run = podmanTest.Podman([]string{"run", "--network", "host", "--network", net2, ALPINE, "ip", "-o", "-4", "addr"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(Equal(125)) + Expect(run.ErrorToString()).To(ContainSubstring("host")) + Expect(run.ErrorToString()).To(ContainSubstring("bridge")) + }) }) diff --git a/test/e2e/run_seccomp.go b/test/e2e/run_seccomp_test.go index 7d04cc60a..7d04cc60a 100644 --- a/test/e2e/run_seccomp.go +++ b/test/e2e/run_seccomp_test.go diff --git a/test/e2e/run_security_labels.go b/test/e2e/run_security_labels_test.go index 0c5621e3f..0c5621e3f 100644 --- a/test/e2e/run_security_labels.go +++ b/test/e2e/run_security_labels_test.go diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index 2350fe1e5..58b8d04e5 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -46,6 +44,7 @@ var _ = Describe("Podman run with --sig-proxy", func() { }) Specify("signals are forwarded to container using sig-proxy", func() { + SkipIfRemote("FIXME: This looks like it is supposed to work in remote") if podmanTest.Host.Arch == "ppc64le" { Skip("Doesn't work on ppc64le") } @@ -111,6 +110,7 @@ var _ = Describe("Podman run with --sig-proxy", func() { }) Specify("signals are not forwarded to container with sig-proxy false", func() { + SkipIfRemote("FIXME: This looks like it is supposed to work in remote") signal := syscall.SIGFPE if rootless.IsRootless() { podmanTest.RestoreArtifact(fedoraMinimal) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index e6bba9f67..0d65a3e59 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -75,11 +75,9 @@ var _ = Describe("Podman run", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - // the --rm option conflicts with --restart, when the restartPolicy is not "" and "no" - // so the exitCode should not equal 0 session = podmanTest.Podman([]string{"run", "--rm", "--restart", "on-failure", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Not(Equal(0))) + Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"run", "--rm", "--restart", "always", ALPINE}) session.WaitWithDefaultTimeout() @@ -315,6 +313,39 @@ var _ = Describe("Podman run", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring("00000000a80425fb")) + + session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) + + session = podmanTest.Podman([]string{"run", "--user=1000:1000", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + + session = podmanTest.Podman([]string{"run", "--user=0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + + session = podmanTest.Podman([]string{"run", "--user=0:0", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + + if os.Geteuid() > 0 { + if os.Getenv("SKIP_USERNS") != "" { + Skip("Skip userns tests.") + } + if _, err := os.Stat("/proc/self/uid_map"); err != nil { + Skip("User namespaces not supported.") + } + session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000002")) + } }) It("podman run user capabilities test with image", func() { @@ -539,12 +570,12 @@ USER bin` }) It("podman run tagged image", func() { - podmanTest.RestoreArtifact(BB) - tag := podmanTest.PodmanNoCache([]string{"tag", "busybox", "bb"}) + podmanTest.AddImageToRWStore(BB) + tag := podmanTest.Podman([]string{"tag", BB, "bb"}) tag.WaitWithDefaultTimeout() Expect(tag.ExitCode()).To(Equal(0)) - session := podmanTest.PodmanNoCache([]string{"run", "--rm", "bb", "ls"}) + session := podmanTest.Podman([]string{"run", "--rm", "bb", "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -1306,42 +1337,30 @@ WORKDIR /madethis` }) It("podman run a container with --pull never should fail if no local store", func() { - // Make sure ALPINE image does not exist. Ignore errors - session := podmanTest.PodmanNoCache([]string{"rmi", "--force", "never", ALPINE}) - session.WaitWithDefaultTimeout() - - session = podmanTest.PodmanNoCache([]string{"run", "--pull", "never", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"run", "--pull", "never", "docker.io/library/debian:latest", "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) }) It("podman run container with --pull missing and only pull once", func() { - // Make sure ALPINE image does not exist. Ignore errors - session := podmanTest.PodmanNoCache([]string{"rmi", "--force", "never", ALPINE}) - session.WaitWithDefaultTimeout() - - session = podmanTest.PodmanNoCache([]string{"run", "--pull", "missing", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"run", "--pull", "missing", cirros, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) - session = podmanTest.PodmanNoCache([]string{"run", "--pull", "missing", ALPINE, "ls"}) + session = podmanTest.Podman([]string{"run", "--pull", "missing", cirros, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) }) It("podman run container with --pull missing should pull image multiple times", func() { - // Make sure ALPINE image does not exist. Ignore errors - session := podmanTest.PodmanNoCache([]string{"rmi", "--force", "never", ALPINE}) - session.WaitWithDefaultTimeout() - - session = podmanTest.PodmanNoCache([]string{"run", "--pull", "always", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"run", "--pull", "always", cirros, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) - session = podmanTest.PodmanNoCache([]string{"run", "--pull", "always", ALPINE, "ls"}) + session = podmanTest.Podman([]string{"run", "--pull", "always", cirros, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull")) diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index 1c8a67123..7c74cea78 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -540,4 +540,12 @@ VOLUME /test/` session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:%s:O", mountPath, mountDest), "--mount", fmt.Sprintf("type=tmpfs,target=%s", mountDest), ALPINE}) Expect(session.ExitCode()).To(Not(Equal(0))) }) + + It("same volume in multiple places does not deadlock", func() { + volName := "testVol1" + session := podmanTest.Podman([]string{"run", "-t", "-i", "-v", fmt.Sprintf("%s:/test1", volName), "-v", fmt.Sprintf("%s:/test2", volName), "--rm", ALPINE, "sh", "-c", "mount | grep /test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + }) }) diff --git a/test/e2e/run_working_dir.go b/test/e2e/run_working_dir_test.go index 7d8db361c..7d8db361c 100644 --- a/test/e2e/run_working_dir.go +++ b/test/e2e/run_working_dir_test.go diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 79fc4d737..a5737c110 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman save", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -41,7 +40,7 @@ var _ = Describe("Podman save", func() { It("podman save output flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -49,7 +48,7 @@ var _ = Describe("Podman save", func() { It("podman save oci flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -58,7 +57,7 @@ var _ = Describe("Podman save", func() { Skip("Pipe redirection in ginkgo probably won't work") outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", ALPINE, ">", outfile}) + save := podmanTest.Podman([]string{"save", ALPINE, ">", outfile}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -66,7 +65,7 @@ var _ = Describe("Podman save", func() { It("podman save quiet flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-q", "-o", outfile, ALPINE}) + save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -74,7 +73,7 @@ var _ = Describe("Podman save", func() { It("podman save bogus image", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "FOOBAR"}) + save := podmanTest.Podman([]string{"save", "-o", outfile, "FOOBAR"}) save.WaitWithDefaultTimeout() Expect(save).To(ExitWithError()) }) @@ -85,7 +84,7 @@ var _ = Describe("Podman save", func() { } outdir := filepath.Join(podmanTest.TempDir, "save") - save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) + save := podmanTest.Podman([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -96,7 +95,7 @@ var _ = Describe("Podman save", func() { } outdir := filepath.Join(podmanTest.TempDir, "save") - save := podmanTest.PodmanNoCache([]string{"save", "--format", "docker-dir", "-o", outdir, ALPINE}) + save := podmanTest.Podman([]string{"save", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -107,7 +106,7 @@ var _ = Describe("Podman save", func() { } outdir := filepath.Join(podmanTest.TempDir, "save") - save := podmanTest.PodmanNoCache([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) + save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -115,12 +114,13 @@ var _ = Describe("Podman save", func() { It("podman save bad filename", func() { outdir := filepath.Join(podmanTest.TempDir, "save:colon") - save := podmanTest.PodmanNoCache([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) + save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save).To(ExitWithError()) }) It("podman save remove signature", func() { + podmanTest.AddImageToRWStore(ALPINE) SkipIfRootless("FIXME: Need get in rootless push sign") if podmanTest.Host.Arch == "ppc64le" { Skip("No registry image for ppc64le") @@ -134,7 +134,7 @@ var _ = Describe("Podman save", func() { defer os.Setenv("GNUPGHOME", origGNUPGHOME) port := 5000 - session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", strings.Join([]string{strconv.Itoa(port), strconv.Itoa(port)}, ":"), "docker.io/registry:2.6"}) + session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", strings.Join([]string{strconv.Itoa(port), strconv.Itoa(port)}, ":"), "quay.io/libpod/registry:2.6"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) { @@ -187,13 +187,13 @@ default-docker: It("podman save image with digest reference", func() { // pull a digest reference - session := podmanTest.PodmanNoCache([]string{"pull", ALPINELISTDIGEST}) + session := podmanTest.Podman([]string{"pull", ALPINELISTDIGEST}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // save a digest reference should exit without error. outfile := filepath.Join(podmanTest.TempDir, "temp.tar") - save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINELISTDIGEST}) + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINELISTDIGEST}) save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) }) @@ -204,7 +204,7 @@ default-docker: It("podman save --multi-image-archive (untagged images)", func() { // Refer to images via ID instead of tag. - session := podmanTest.PodmanNoCache([]string{"images", "--format", "{{.ID}}"}) + session := podmanTest.Podman([]string{"images", "--format", "{{.ID}}"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) ids := session.OutputToStringArray() @@ -219,17 +219,17 @@ default-docker: func multiImageSave(podmanTest *PodmanTestIntegration, images []string) { // Create the archive. outfile := filepath.Join(podmanTest.TempDir, "temp.tar") - session := podmanTest.PodmanNoCache(append([]string{"save", "-o", outfile, "--multi-image-archive"}, images...)) + session := podmanTest.Podman(append([]string{"save", "-o", outfile, "--multi-image-archive"}, images...)) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Remove all images. - session = podmanTest.PodmanNoCache([]string{"rmi", "-af"}) + session = podmanTest.Podman([]string{"rmi", "-af"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Now load the archive. - session = podmanTest.PodmanNoCache([]string{"load", "-i", outfile}) + session = podmanTest.Podman([]string{"load", "-i", outfile}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Grep for each image in the `podman load` output. @@ -240,7 +240,7 @@ func multiImageSave(podmanTest *PodmanTestIntegration, images []string) { // Make sure that each image has really been loaded. for _, image := range images { - session = podmanTest.PodmanNoCache([]string{"image", "exists", image}) + session = podmanTest.Podman([]string{"image", "exists", image}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) } diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 4f2751099..5c3c69fd4 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -93,10 +93,10 @@ registries = ['{{.Host}}:{{.Port}}']` }) It("podman search single registry flag", func() { - search := podmanTest.Podman([]string{"search", "quay.io/libpod/gate:latest"}) + search := podmanTest.Podman([]string{"search", "quay.io/skopeo/stable:latest"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) - Expect(search.LineInOutputContains("quay.io/libpod/gate")).To(BeTrue()) + Expect(search.LineInOutputContains("quay.io/skopeo/stable")).To(BeTrue()) }) It("podman search image with description", func() { @@ -116,6 +116,14 @@ registries = ['{{.Host}}:{{.Port}}']` Expect(search.LineInOutputContains("docker.io/library/alpine")).To(BeTrue()) }) + It("podman search format json", func() { + search := podmanTest.Podman([]string{"search", "--format", "json", "alpine"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(search.IsJSONOutputValid()).To(BeTrue()) + Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine")) + }) + It("podman search no-trunc flag", func() { search := podmanTest.Podman([]string{"search", "--no-trunc", "alpine"}) search.WaitWithDefaultTimeout() @@ -218,17 +226,17 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[3].Address()) - push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) - search := podmanTest.PodmanNoCache([]string{"search", image, "--tls-verify=false"}) + search := podmanTest.Podman([]string{"search", image, "--tls-verify=false"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) Expect(search.OutputToString()).ShouldNot(BeEmpty()) // podman search v2 registry with empty query - searchEmpty := podmanTest.PodmanNoCache([]string{"search", fmt.Sprintf("%s/", registryEndpoints[3].Address()), "--tls-verify=false"}) + searchEmpty := podmanTest.Podman([]string{"search", fmt.Sprintf("%s/", registryEndpoints[3].Address()), "--tls-verify=false"}) searchEmpty.WaitWithDefaultTimeout() Expect(searchEmpty.ExitCode()).To(BeZero()) Expect(len(searchEmpty.OutputToStringArray())).To(BeNumerically(">=", 1)) @@ -254,7 +262,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[4].Address()) - push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -268,7 +276,7 @@ registries = ['{{.Host}}:{{.Port}}']` defer podmanTest.RestartRemoteService() } - search := podmanTest.PodmanNoCache([]string{"search", image}) + search := podmanTest.Podman([]string{"search", image}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -298,7 +306,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[5].Address()) - push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -311,7 +319,7 @@ registries = ['{{.Host}}:{{.Port}}']` defer podmanTest.RestartRemoteService() } - search := podmanTest.PodmanNoCache([]string{"search", image, "--tls-verify=true"}) + search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -341,7 +349,7 @@ registries = ['{{.Host}}:{{.Port}}']` podmanTest.RestoreArtifact(ALPINE) image := fmt.Sprintf("%s/my-alpine", registryEndpoints[6].Address()) - push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -355,7 +363,7 @@ registries = ['{{.Host}}:{{.Port}}']` defer podmanTest.RestartRemoteService() } - search := podmanTest.PodmanNoCache([]string{"search", image}) + search := podmanTest.Podman([]string{"search", image}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -395,7 +403,7 @@ registries = ['{{.Host}}:{{.Port}}']` } podmanTest.RestoreArtifact(ALPINE) - push := podmanTest.PodmanNoCache([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:6000/my-alpine"}) + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:6000/my-alpine"}) push.WaitWithDefaultTimeout() Expect(push.ExitCode()).To(Equal(0)) @@ -410,7 +418,7 @@ registries = ['{{.Host}}:{{.Port}}']` defer podmanTest.RestartRemoteService() } - search := podmanTest.PodmanNoCache([]string{"search", "my-alpine"}) + search := podmanTest.Podman([]string{"search", "my-alpine"}) search.WaitWithDefaultTimeout() Expect(search.ExitCode()).To(Equal(0)) @@ -460,4 +468,11 @@ registries = ['{{.Host}}:{{.Port}}']` search.WaitWithDefaultTimeout() Expect(len(search.OutputToStringArray()) == 0).To(BeTrue()) }) + + It("podman search with limit over 100", func() { + search := podmanTest.Podman([]string{"search", "--limit", "130", "registry.redhat.io/rhel"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + Expect(len(search.OutputToStringArray())).To(Equal(131)) + }) }) diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index c8f5efa9d..5e8a7a3d0 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -5,6 +5,7 @@ package integration import ( "fmt" "os" + "strconv" "time" . "github.com/containers/podman/v2/test/utils" @@ -126,4 +127,44 @@ var _ = Describe("Podman stats", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) + + // Regression test for #8265 + It("podman stats with custom memory limits", func() { + // Run thre containers. One with a memory limit. Make sure + // that the limits are different and the limited one has a + // lower limit. + ctrNoLimit0 := "no-limit-0" + ctrNoLimit1 := "no-limit-1" + ctrWithLimit := "with-limit" + + session := podmanTest.Podman([]string{"run", "-d", "--name", ctrNoLimit0, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "-d", "--name", ctrNoLimit1, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "-d", "--name", ctrWithLimit, "--memory", "50m", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"stats", "--no-stream", "--format", "{{.MemLimit}}", ctrNoLimit0, ctrNoLimit1, ctrWithLimit}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // We have three containers. The unlimited ones need to have + // the same limit, the limited one a lower one. + limits := session.OutputToStringArray() + Expect(len(limits)).To(BeNumerically("==", 3)) + Expect(limits[0]).To(Equal(limits[1])) + Expect(limits[0]).ToNot(Equal(limits[2])) + + defaultLimit, err := strconv.Atoi(limits[0]) + Expect(err).To(BeNil()) + customLimit, err := strconv.Atoi(limits[2]) + Expect(err).To(BeNil()) + + Expect(customLimit).To(BeNumerically("<", defaultLimit)) + }) }) diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go index 365e36fc7..050a01805 100644 --- a/test/e2e/system_df_test.go +++ b/test/e2e/system_df_test.go @@ -66,15 +66,16 @@ var _ = Describe("podman system df", func() { }) It("podman system df image with no tag", func() { - session := podmanTest.PodmanNoCache([]string{"create", ALPINE}) + podmanTest.AddImageToRWStore(ALPINE) + session := podmanTest.Podman([]string{"create", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"image", "untag", ALPINE}) + session = podmanTest.Podman([]string{"image", "untag", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"system", "df"}) + session = podmanTest.Podman([]string{"system", "df"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/system_reset_test.go b/test/e2e/system_reset_test.go index 1a030216f..b2d350436 100644 --- a/test/e2e/system_reset_test.go +++ b/test/e2e/system_reset_test.go @@ -46,10 +46,7 @@ var _ = Describe("podman system reset", func() { Expect(session.ExitCode()).To(Equal(0)) l := len(session.OutputToStringArray()) - session = podmanTest.Podman([]string{"pull", ALPINE}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - + podmanTest.AddImageToRWStore(ALPINE) session = podmanTest.Podman([]string{"volume", "create", "data"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 218c250cd..48294943b 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -59,7 +59,7 @@ WantedBy=multi-user.target Expect(stop.ExitCode()).To(Equal(0)) }() - create := podmanTest.Podman([]string{"create", "--name", "redis", "redis"}) + create := podmanTest.Podman([]string{"create", "--name", "redis", redis}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go index 72d5cad77..8e8264e9d 100644 --- a/test/e2e/tag_test.go +++ b/test/e2e/tag_test.go @@ -22,7 +22,7 @@ var _ = Describe("Podman tag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() + podmanTest.AddImageToRWStore(ALPINE) }) AfterEach(func() { @@ -33,54 +33,54 @@ var _ = Describe("Podman tag", func() { }) It("podman tag shortname:latest", func() { - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar:latest"}) + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.PodmanNoCache([]string{"inspect", "foobar:latest"}) + results := podmanTest.Podman([]string{"inspect", "foobar:latest"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("docker.io/library/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) Expect(StringInSlice("localhost/foobar:latest", inspectData[0].RepoTags)).To(BeTrue()) }) It("podman tag shortname", func() { - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar"}) + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.PodmanNoCache([]string{"inspect", "foobar:latest"}) + results := podmanTest.Podman([]string{"inspect", "foobar:latest"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("docker.io/library/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) Expect(StringInSlice("localhost/foobar:latest", inspectData[0].RepoTags)).To(BeTrue()) }) It("podman tag shortname:tag", func() { - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar:new"}) + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar:new"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.PodmanNoCache([]string{"inspect", "foobar:new"}) + results := podmanTest.Podman([]string{"inspect", "foobar:new"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) inspectData := results.InspectImageJSON() - Expect(StringInSlice("docker.io/library/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) + Expect(StringInSlice("quay.io/libpod/alpine:latest", inspectData[0].RepoTags)).To(BeTrue()) Expect(StringInSlice("localhost/foobar:new", inspectData[0].RepoTags)).To(BeTrue()) }) It("podman tag shortname image no tag", func() { - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "foobar"}) + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.PodmanNoCache([]string{"tag", "foobar", "barfoo"}) + results := podmanTest.Podman([]string{"tag", "foobar", "barfoo"}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) - verify := podmanTest.PodmanNoCache([]string{"inspect", "barfoo"}) + verify := podmanTest.Podman([]string{"inspect", "barfoo"}) verify.WaitWithDefaultTimeout() Expect(verify.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go index fbff8d19e..7393b13cb 100644 --- a/test/e2e/toolbox_test.go +++ b/test/e2e/toolbox_test.go @@ -30,10 +30,12 @@ import ( "os" "os/exec" "os/user" + "path" "strconv" "strings" "syscall" + "github.com/containers/podman/v2/pkg/rootless" . "github.com/containers/podman/v2/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -212,7 +214,7 @@ var _ = Describe("Toolbox-specific testing", func() { useradd := fmt.Sprintf("useradd --home-dir %s --shell %s --uid %s %s", homeDir, shell, uid, username) passwd := fmt.Sprintf("passwd --delete %s", username) - + podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", "--user", "root:root", fedoraToolbox, "sh", "-c", fmt.Sprintf("%s; %s; echo READY; sleep 1000", useradd, passwd)}) session.WaitWithDefaultTimeout() @@ -248,6 +250,7 @@ var _ = Describe("Toolbox-specific testing", func() { groupadd := fmt.Sprintf("groupadd --gid %s %s", gid, groupName) + podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", "--user", "root:root", fedoraToolbox, "sh", "-c", fmt.Sprintf("%s; echo READY; sleep 1000", groupadd)}) session.WaitWithDefaultTimeout() @@ -283,7 +286,7 @@ var _ = Describe("Toolbox-specific testing", func() { var gid string = "2000" // The use of bad* in the name of variables does not imply the invocation - // of useradd should fail The user is supposed to be created successfuly + // of useradd should fail The user is supposed to be created successfully // but later his information (uid, home, shell,..) is changed via usermod. useradd := fmt.Sprintf("useradd --home-dir %s --shell %s --uid %s %s", badHomeDir, badShell, badUID, username) @@ -292,6 +295,7 @@ var _ = Describe("Toolbox-specific testing", func() { usermod := fmt.Sprintf("usermod --append --groups wheel --home %s --shell %s --uid %s --gid %s %s", homeDir, shell, uid, gid, username) + podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", "--user", "root:root", fedoraToolbox, "sh", "-c", fmt.Sprintf("%s; %s; %s; echo READY; sleep 1000", useradd, groupadd, usermod)}) session.WaitWithDefaultTimeout() @@ -336,6 +340,7 @@ var _ = Describe("Toolbox-specific testing", func() { // These should be most of the switches that Toolbox uses to create a "toolbox" container // https://github.com/containers/toolbox/blob/master/src/cmd/create.go + podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"create", "--dns", "none", "--hostname", "toolbox", @@ -371,10 +376,24 @@ var _ = Describe("Toolbox-specific testing", func() { currentUser, err := user.Current() Expect(err).To(BeNil()) + + podmanTest.AddImageToRWStore(fedoraToolbox) session = podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:%s", currentUser.HomeDir, currentUser.HomeDir), "--userns=keep-id", fedoraToolbox, "sh", "-c", "echo $HOME"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir)) + + if rootless.IsRootless() { + location := path.Dir(currentUser.HomeDir) + volumeArg := fmt.Sprintf("%s:%s", location, location) + session = podmanTest.Podman([]string{"run", + "--userns=keep-id", + "--volume", volumeArg, + fedoraToolbox, "sh", "-c", "echo $HOME"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir)) + } }) }) diff --git a/test/e2e/tree_test.go b/test/e2e/tree_test.go index eeb00440c..2a7feaacb 100644 --- a/test/e2e/tree_test.go +++ b/test/e2e/tree_test.go @@ -23,7 +23,7 @@ var _ = Describe("Podman image tree", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreArtifact(BB) + podmanTest.AddImageToRWStore(BB) }) AfterEach(func() { @@ -35,24 +35,26 @@ var _ = Describe("Podman image tree", func() { It("podman image tree", func() { SkipIfRemote("Does not work on remote client") - dockerfile := `FROM docker.io/library/busybox:latest + Skip("dont understand why this fails") + podmanTest.AddImageToRWStore(cirros) + dockerfile := `FROM quay.io/libpod/cirros:latest RUN mkdir hello RUN touch test.txt ENV foo=bar ` podmanTest.BuildImage(dockerfile, "test:latest", "true") - session := podmanTest.PodmanNoCache([]string{"image", "tree", "test:latest"}) + session := podmanTest.Podman([]string{"image", "tree", "test:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"image", "tree", "--whatrequires", "docker.io/library/busybox:latest"}) + session = podmanTest.Podman([]string{"image", "tree", "--whatrequires", "quay.io/libpod/cirros:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "test:latest"}) + session = podmanTest.Podman([]string{"rmi", "test:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"rmi", "docker.io/library/busybox:latest"}) + session = podmanTest.Podman([]string{"rmi", "quay.io/libpod/cirros:latest"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go index 987023e4c..19e576490 100644 --- a/test/e2e/trust_test.go +++ b/test/e2e/trust_test.go @@ -1,5 +1,3 @@ -// +build !remote - package integration import ( @@ -21,6 +19,7 @@ var _ = Describe("Podman trust", func() { ) BeforeEach(func() { + SkipIfRemote("podman-remote does not support image trust") tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) diff --git a/test/e2e/untag_test.go b/test/e2e/untag_test.go index 91a933090..4d4f60f0c 100644 --- a/test/e2e/untag_test.go +++ b/test/e2e/untag_test.go @@ -22,7 +22,6 @@ var _ = Describe("Podman untag", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() - podmanTest.RestoreAllArtifacts() }) AfterEach(func() { @@ -33,42 +32,37 @@ var _ = Describe("Podman untag", func() { }) It("podman untag all", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", ALPINE}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) - - tags := []string{ALPINE, "registry.com/foo:bar", "localhost/foo:bar"} + podmanTest.AddImageToRWStore(cirros) + tags := []string{cirros, "registry.com/foo:bar", "localhost/foo:bar"} cmd := []string{"tag"} cmd = append(cmd, tags...) - session := podmanTest.PodmanNoCache(cmd) + session := podmanTest.Podman(cmd) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Make sure that all tags exists. for _, t := range tags { - session = podmanTest.PodmanNoCache([]string{"image", "exists", t}) + session = podmanTest.Podman([]string{"image", "exists", t}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) } // No arguments -> remove all tags. - session = podmanTest.PodmanNoCache([]string{"untag", ALPINE}) + session = podmanTest.Podman([]string{"untag", cirros}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) // Make sure that none of tags exists anymore. for _, t := range tags { - session = podmanTest.PodmanNoCache([]string{"image", "exists", t}) + session = podmanTest.Podman([]string{"image", "exists", t}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(1)) } }) It("podman tag/untag - tag normalization", func() { - setup := podmanTest.PodmanNoCache([]string{"pull", ALPINE}) - setup.WaitWithDefaultTimeout() - Expect(setup.ExitCode()).To(Equal(0)) + podmanTest.AddImageToRWStore(cirros) tests := []struct { tag, normalized string @@ -82,19 +76,19 @@ var _ = Describe("Podman untag", func() { // Make sure that the user input is normalized correctly for // `podman tag` and `podman untag`. for _, tt := range tests { - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tt.tag}) + session := podmanTest.Podman([]string{"tag", cirros, tt.tag}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"image", "exists", tt.normalized}) + session = podmanTest.Podman([]string{"image", "exists", tt.normalized}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"untag", ALPINE, tt.tag}) + session = podmanTest.Podman([]string{"untag", cirros, tt.tag}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.PodmanNoCache([]string{"image", "exists", tt.normalized}) + session = podmanTest.Podman([]string{"image", "exists", tt.normalized}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(1)) } diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go index 1cb6440aa..5c466124d 100644 --- a/test/e2e/volume_ls_test.go +++ b/test/e2e/volume_ls_test.go @@ -83,6 +83,22 @@ var _ = Describe("Podman volume ls", func() { Expect(session.ExitCode()).To(Equal(0)) Expect(len(session.OutputToStringArray())).To(Equal(2)) Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName)) + + session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=bar"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(2)) + Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName)) + + session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=baz"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(0)) }) It("podman volume ls with --filter dangling", func() { @@ -110,4 +126,33 @@ var _ = Describe("Podman volume ls", func() { Expect(lsDangling.ExitCode()).To(Equal(0)) Expect(lsDangling.OutputToString()).To(ContainSubstring(volName1)) }) + It("podman ls volume with multiple --filter flag", func() { + session := podmanTest.Podman([]string{"volume", "create", "--label", "foo=bar", "myvol"}) + volName := session.OutputToString() + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "create", "--label", "foo2=bar2", "anothervol"}) + anotherVol := session.OutputToString() + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "create"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo", "--filter", "label=foo2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName)) + Expect(session.OutputToStringArray()[2]).To(ContainSubstring(anotherVol)) + + session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=bar", "--filter", "label=foo2=bar2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(Equal(3)) + Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName)) + Expect(session.OutputToStringArray()[2]).To(ContainSubstring(anotherVol)) + }) }) |