diff options
Diffstat (limited to 'test')
34 files changed, 1063 insertions, 607 deletions
diff --git a/test/demos.sh b/test/demos.sh new file mode 100755 index 000000000..4ce29e160 --- /dev/null +++ b/test/demos.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +echo "This is a demo of the podman search command." +echo "" + +read -p "--> cat /etc/containers/registries.conf" +cat /etc/containers/registries.conf +echo "" + +read -p "--> podman search fedora" +podman search fedora +echo "" + +read -p "--> podman search --filter stars=34 fedora" +podman search --filter stars=34 fedora +echo "" + +read -p "--> podman search --filter is-automated=false --filter stars=34 --filter is-official fedora" +podman search --filter is-automated=false --filter stars=34 --filter is-official fedora +echo "" + +read -p "--> podman search --no-trunc --limit 3 fedora" +podman search --no-trunc --limit 3 fedora +echo "" + +read -p "--> podman search --registry registry.access.redhat.com rhel7" +podman search --registry registry.access.redhat.com rhel7 +echo "" + +read -p "--> podman search --format \"table {{.Name}} {{.Description}}\" fedora" +podman search --format "table {{.Name}} {{.Description}}" fedora +echo "" + +read -p "Demo of a few podman run and create options" +echo "" + +read -p "--> podman run --memory 80m fedora cat /sys/fs/cgroup/memory/memory.limit_in_bytes" +podman run --rm --memory 80m fedora cat /sys/fs/cgroup/memory/memory.limit_in_bytes +echo "" + +read -p "--> podman run --memory 80m --memory-reservation 40m fedora cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes" +podman run --rm --memory 80m --memory-reservation 40m fedora cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes +echo "" + +read -p "--> podman run --memory 40m --memory-reservation 80m fedora cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes" +podman run --rm --memory 40m --memory-reservation 80m fedora cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes +echo "" + +read -p "--> podman run --memory-swappiness 15 fedora cat /sys/fs/cgroup/memory/memory.swappiness" +podman run --rm --memory-swappiness 15 fedora cat /sys/fs/cgroup/memory/memory.swappiness +echo "" + +read -p "--> podman run --kernel-memory 40m fedora cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes" +podman run --rm --kernel-memory 40m fedora cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes +echo "" + +read -p "--> podman run --cpu-period 5000 fedora cat /sys/fs/cgroup/cpu/cpu.cfs_period_us" +podman run --rm --cpu-period 5000 fedora cat /sys/fs/cgroup/cpu/cpu.cfs_period_us +echo "" + +read -p "--> podman run --cpu-quota 15000 --cpu-period 5000 fedora cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us" +podman run --rm --cpu-quota 15000 --cpu-period 5000 fedora cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us +echo "" + +read -p "--> podman run --cpus 0.5 fedora /bin/bash" +read -p "cat /sys/fs/cgroup/cpu/cpu.cfs_period_us" +podman run --rm --cpus 0.5 fedora cat /sys/fs/cgroup/cpu/cpu.cfs_period_us +read -p "cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us" +podman run --rm --cpus 0.5 fedora cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us +echo "" + +read -p "--> podman run --cpu-shares 2 fedora cat /sys/fs/cgroup/cpu/cpu.shares" +podman run --rm --cpu-shares 2 fedora cat /sys/fs/cgroup/cpu/cpu.shares +echo "" + +read -p "--> podman run --cpuset-cpus=0,2 fedora cat /sys/fs/cgroup/cpuset/cpuset.cpus" +podman run --rm --cpuset-cpus=0,2 fedora cat /sys/fs/cgroup/cpuset/cpuset.cpus +echo "" + +read -p "--> podman run --sysctl net.core.somaxconn=65535 alpine sysctl net.core.somaxconn" +podman run --rm --sysctl net.core.somaxconn=65535 alpine sysctl net.core.somaxconn +echo "" + +read -p "--> podman run --ulimit nofile=1024:1028 fedora ulimit -n" +podman run --rm --ulimit nofile=1024:1028 fedora ulimit -n +echo "" + +read -p "--> podman run --blkio-weight 15 fedora cat /sys/fs/cgroup/blkio/blkio.weight" +podman run --rm --blkio-weight 15 fedora cat /sys/fs/cgroup/blkio/blkio.weight +echo "" + +read -p "End of Demo." +echo "Thank you!"
\ No newline at end of file diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go new file mode 100644 index 000000000..afe324e9c --- /dev/null +++ b/test/e2e/attach_test.go @@ -0,0 +1,60 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman attach", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman attach to bogus container", func() { + session := podmanTest.Podman([]string{"attach", "foobar"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + }) + + It("podman attach to non-running container", func() { + session := podmanTest.Podman([]string{"create", "--name", "test1", "-d", "-i", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"attach", "test1"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(125)) + }) + + It("podman attach to multiple containers", func() { + session := podmanTest.RunSleepContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.RunSleepContainer("test2") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"attach", "test1", "test2"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(125)) + }) +}) diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index 6955b33d1..c807b46c5 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -74,6 +74,7 @@ var _ = Describe("Podman commit", func() { }) It("podman commit container with change flag", func() { + podmanTest.RestoreArtifact(fedoraMinimal) test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", fedoraMinimal, "ls"}) test.WaitWithDefaultTimeout() Expect(test.ExitCode()).To(Equal(0)) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index c116cea7d..e54e35761 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -38,7 +38,7 @@ var _ = Describe("Podman create", func() { check := podmanTest.Podman([]string{"inspect", "-l"}) check.WaitWithDefaultTimeout() data := check.InspectContainerToJSON() - Expect(data.CtrInspectData.ID).To(ContainSubstring(cid)) + Expect(data.ID).To(ContainSubstring(cid)) }) It("podman create container based on a remote image", func() { diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go new file mode 100644 index 000000000..4c7c93e4b --- /dev/null +++ b/test/e2e/images_test.go @@ -0,0 +1,53 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman images", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman images", func() { + session := podmanTest.Podman([]string{"images"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(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 in JSON format", func() { + session := podmanTest.Podman([]string{"images", "--format=json"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.IsJSONOutputValid()).To(BeTrue()) + }) + + It("podman images with short options", func() { + session := podmanTest.Podman([]string{"images", "-qn"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 1)) + }) +}) diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go new file mode 100644 index 000000000..448a89539 --- /dev/null +++ b/test/e2e/import_test.go @@ -0,0 +1,107 @@ +package integration + +import ( + "os" + "path/filepath" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman import", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + }) + + It("podman import with source and reference", func() { + outfile := filepath.Join(podmanTest.TempDir, "container.tar") + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) + export.WaitWithDefaultTimeout() + Expect(export.ExitCode()).To(Equal(0)) + + importImage := podmanTest.Podman([]string{"import", outfile, "foobar.com/imported-image:latest"}) + importImage.WaitWithDefaultTimeout() + Expect(importImage.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"inspect", "--type", "image", "foobar.com/imported-image:latest"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + }) + + It("podman import without reference", func() { + outfile := filepath.Join(podmanTest.TempDir, "container.tar") + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) + export.WaitWithDefaultTimeout() + Expect(export.ExitCode()).To(Equal(0)) + + importImage := podmanTest.Podman([]string{"import", outfile}) + importImage.WaitWithDefaultTimeout() + Expect(importImage.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"images", "-q"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("podman import with message flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "container.tar") + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) + export.WaitWithDefaultTimeout() + Expect(export.ExitCode()).To(Equal(0)) + + importImage := podmanTest.Podman([]string{"import", "--message", "importing container test message", outfile, "imported-image"}) + importImage.WaitWithDefaultTimeout() + Expect(importImage.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"history", "imported-image", "--format", "{{.Comment}}"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(results.LineInOuputStartsWith("importing container test message")).To(BeTrue()) + }) + + It("podman import with change flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "container.tar") + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + export := podmanTest.Podman([]string{"export", "-o", outfile, cid}) + export.WaitWithDefaultTimeout() + Expect(export.ExitCode()).To(Equal(0)) + + importImage := podmanTest.Podman([]string{"import", "--change", "CMD=/bin/bash", outfile, "imported-image"}) + importImage.WaitWithDefaultTimeout() + Expect(importImage.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"inspect", "imported-image"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + imageData := results.InspectImageJSON() + Expect(imageData.Config.Cmd[0]).To(Equal("/bin/bash")) + }) + +}) diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go new file mode 100644 index 000000000..b6020f53b --- /dev/null +++ b/test/e2e/inspect_test.go @@ -0,0 +1,75 @@ +package integration + +import ( + "os" + + "strings" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman inspect", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman inspect alpine image", func() { + session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.IsJSONOutputValid()).To(BeTrue()) + imageData := session.InspectImageJSON() + Expect(imageData.RepoTags[0]).To(Equal("docker.io/library/alpine:latest")) + }) + + It("podman inspect bogus container", func() { + session := podmanTest.Podman([]string{"inspect", "foobar4321"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman inspect with GO format", func() { + session := podmanTest.Podman([]string{"inspect", "--format", "{{.ID}}", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"images", "-q", "--no-trunc", ALPINE}) + result.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(strings.Trim(result.OutputToString(), "sha256:")).To(Equal(session.OutputToString())) + }) + + It("podman inspect specified type", func() { + session := podmanTest.Podman([]string{"inspect", "--type", "image", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman inspect container with size", func() { + _, ec, _ := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + result := podmanTest.Podman([]string{"inspect", "--size", "-l"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + conData := result.InspectContainerToJSON() + Expect(conData.SizeRootFs).To(BeNumerically(">", 0)) + }) +}) diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 27848517f..d6263beb2 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -39,7 +39,8 @@ var ( INTEGRATION_ROOT string STORAGE_OPTIONS = "--storage-driver vfs" ARTIFACT_DIR = "/tmp/.artifacts" - IMAGES = []string{"alpine", "busybox"} + CACHE_IMAGES = []string{"alpine", "busybox", fedoraMinimal} + RESTORE_IMAGES = []string{"alpine", "busybox"} ALPINE = "docker.io/library/alpine:latest" BB_GLIBC = "docker.io/library/busybox:glibc" fedoraMinimal = "registry.fedoraproject.org/fedora-minimal:latest" @@ -86,7 +87,7 @@ var _ = BeforeSuite(func() { os.Exit(1) } } - for _, image := range IMAGES { + for _, image := range CACHE_IMAGES { fmt.Printf("Caching %s...\n", image) if err := podman.CreateArtifact(image); err != nil { fmt.Printf("%q\n", err) @@ -280,7 +281,8 @@ func (p *PodmanTest) CreateArtifact(image string) error { return errors.Errorf("error parsing image name %v: %v", image, err) } - exportTo := filepath.Join("dir:", p.ArtifactPath, image) + imageDir := strings.Replace(image, "/", "_", -1) + exportTo := filepath.Join("dir:", p.ArtifactPath, imageDir) exportRef, err := alltransports.ParseImageName(exportTo) if err != nil { return errors.Errorf("error parsing image name %v: %v", exportTo, err) @@ -314,7 +316,8 @@ func (p *PodmanTest) RestoreArtifact(image string) error { return errors.Errorf("error parsing image name: %v", err) } - importFrom := fmt.Sprintf("dir:%s", filepath.Join(p.ArtifactPath, image)) + imageDir := strings.Replace(image, "/", "_", -1) + importFrom := fmt.Sprintf("dir:%s", filepath.Join(p.ArtifactPath, imageDir)) importRef, err := alltransports.ParseImageName(importFrom) if err != nil { return errors.Errorf("error parsing image name %v: %v", image, err) @@ -342,7 +345,7 @@ func (p *PodmanTest) RestoreArtifact(image string) error { // RestoreAllArtifacts unpacks all cached images func (p *PodmanTest) RestoreAllArtifacts() error { - for _, image := range IMAGES { + for _, image := range RESTORE_IMAGES { if err := p.RestoreArtifact(image); err != nil { return err } @@ -413,3 +416,14 @@ func StringInSlice(s string, sl []string) bool { } return false } + +//LineInOutputStartsWith returns true if a line in a +// session output starts with the supplied string +func (s *PodmanSession) LineInOuputStartsWith(term string) bool { + for _, i := range s.OutputToStringArray() { + if strings.HasPrefix(i, term) { + return true + } + } + return false +} diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go new file mode 100644 index 000000000..d8fc440c0 --- /dev/null +++ b/test/e2e/logs_test.go @@ -0,0 +1,60 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman logs", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman logs for container", func() { + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + results := podmanTest.Podman([]string{"logs", cid}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + }) + + It("podman logs tail three lines", func() { + Skip("Tail is not working correctly") + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + results := podmanTest.Podman([]string{"logs", "--tail", "3", cid}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("podman logs since a given time", func() { + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + results := podmanTest.Podman([]string{"logs", "--since", "2017-08-07T10:10:09.056611202-04:00", cid}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + }) + +}) diff --git a/test/e2e/privileged_test.go b/test/e2e/privileged_test.go new file mode 100644 index 000000000..b660e1b55 --- /dev/null +++ b/test/e2e/privileged_test.go @@ -0,0 +1,76 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "strings" +) + +var _ = Describe("Podman privileged container tests", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman privileged make sure sys is mounted rw", func() { + session := podmanTest.Podman([]string{"run", "--privileged", "busybox", "mount"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + ok, lines := session.GrepString("sysfs") + Expect(ok).To(BeTrue()) + Expect(lines[0]).To(ContainSubstring("sysfs (rw,")) + }) + + It("podman privileged CapEff", func() { + cap := podmanTest.SystemExec("grep", []string{"CapEff", "/proc/self/status"}) + cap.WaitWithDefaultTimeout() + Expect(cap.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"run", "--privileged", "busybox", "grep", "CapEff", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal(cap.OutputToString())) + }) + + It("podman cap-add CapEff", func() { + cap := podmanTest.SystemExec("grep", []string{"CapEff", "/proc/self/status"}) + cap.WaitWithDefaultTimeout() + Expect(cap.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"run", "--cap-add", "all", "busybox", "grep", "CapEff", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal(cap.OutputToString())) + }) + + It("podman cap-drop CapEff", func() { + cap := podmanTest.SystemExec("grep", []string{"CapAmb", "/proc/self/status"}) + cap.WaitWithDefaultTimeout() + Expect(cap.ExitCode()).To(Equal(0)) + session := podmanTest.Podman([]string{"run", "--cap-drop", "all", "busybox", "grep", "CapEff", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + capAmp := strings.Split(cap.OutputToString(), " ") + capEff := strings.Split(session.OutputToString(), " ") + Expect(capAmp[1]).To(Equal(capEff[1])) + }) + +}) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index d0aa0bd7c..c4f23c944 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -4,6 +4,7 @@ import ( "os" "fmt" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -100,7 +101,7 @@ var _ = Describe("Podman ps", func() { result := podmanTest.Podman([]string{"ps", "--last", "2"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - Expect(len(result.OutputToStringArray())).Should(Equal(4)) + Expect(len(result.OutputToStringArray())).Should(Equal(3)) }) It("podman ps no-trunc", func() { diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index a59b2ee01..ed0221dfd 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -45,7 +45,7 @@ var _ = Describe("Podman rm", func() { result := podmanTest.Podman([]string{"rm", cid}) result.WaitWithDefaultTimeout() - Expect(result.ExitCode()).To(Not(Equal(0))) + Expect(result.ExitCode()).To(Equal(125)) }) It("podman rm created container", func() { diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go new file mode 100644 index 000000000..27ca1e556 --- /dev/null +++ b/test/e2e/run_dns_test.go @@ -0,0 +1,82 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman run dns", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman run add search domain", func() { + session := podmanTest.Podman([]string{"run", "--dns-search=foobar.com", ALPINE, "cat", "/etc/resolv.conf"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session.LineInOuputStartsWith("search foobar.com") + }) + + It("podman run add bad dns server", func() { + session := podmanTest.Podman([]string{"run", "--dns=foobar", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman run add dns server", func() { + session := podmanTest.Podman([]string{"run", "--dns=1.2.3.4", ALPINE, "cat", "/etc/resolv.conf"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session.LineInOuputStartsWith("server 1.2.3.4") + }) + + It("podman run add dns option", func() { + session := podmanTest.Podman([]string{"run", "--dns-opt=debug", ALPINE, "cat", "/etc/resolv.conf"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session.LineInOuputStartsWith("options debug") + }) + + It("podman run add bad host", func() { + session := podmanTest.Podman([]string{"run", "--add-host=foo:1.2", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman run add host", func() { + session := podmanTest.Podman([]string{"run", "--add-host=foobar:1.1.1.1", ALPINE, "cat", "/etc/hosts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session.LineInOuputStartsWith("foobar 1.1.1.1") + }) + + It("podman run add hostname", func() { + session := podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "cat", "/etc/hostname"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("foobar")) + + session = podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "hostname"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("foobar")) + }) +}) diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go new file mode 100644 index 000000000..3b9e08b5e --- /dev/null +++ b/test/e2e/run_exit_test.go @@ -0,0 +1,61 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman run exit", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman run exit 125", func() { + result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(125)) + }) + + It("podman run exit 126", func() { + result := podmanTest.Podman([]string{"run", ALPINE, "foobar"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(126)) + }) + + It("podman run exit 127", func() { + result := podmanTest.Podman([]string{"run", ALPINE, "/etc"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(127)) + }) + + It("podman run exit 0", func() { + result := podmanTest.Podman([]string{"run", ALPINE, "ls"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman run exit 50", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + result := podmanTest.Podman([]string{"run", "registry.fedoraproject.org/fedora-minimal", "bash", "-c", "exit 50"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(50)) + }) +}) diff --git a/test/e2e/run_memory_test.go b/test/e2e/run_memory_test.go new file mode 100644 index 000000000..a7482a6ea --- /dev/null +++ b/test/e2e/run_memory_test.go @@ -0,0 +1,58 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman run memory", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman run memory test", func() { + session := podmanTest.Podman([]string{"run", "--memory=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.limit_in_bytes"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("41943040")) + }) + + It("podman run memory-reservation test", func() { + session := podmanTest.Podman([]string{"run", "--memory-reservation=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("41943040")) + }) + + It("podman run memory-swappiness test", func() { + session := podmanTest.Podman([]string{"run", "--memory-swappiness=15", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.swappiness"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("15")) + }) + + It("podman run kernel-memory test", func() { + session := podmanTest.Podman([]string{"run", "--kernel-memory=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("41943040")) + }) +}) diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go new file mode 100644 index 000000000..1dfec9f64 --- /dev/null +++ b/test/e2e/run_ns_test.go @@ -0,0 +1,67 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman run ns", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + podmanTest.RestoreArtifact(fedoraMinimal) + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman run pidns test", func() { + session := podmanTest.Podman([]string{"run", fedoraMinimal, "bash", "-c", "echo $$"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("1")) + + session = podmanTest.Podman([]string{"run", "--pid=host", fedoraMinimal, "bash", "-c", "echo $$"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Not(Equal("1"))) + + session = podmanTest.Podman([]string{"run", "--pid=badpid", fedoraMinimal, "bash", "-c", "echo $$"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman run ipcns test", func() { + setup := podmanTest.SystemExec("mktemp", []string{"/dev/shm/podmantest.XXXX)"}) + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"run", "--ipc=host", fedoraMinimal, "ls", setup.OutputToString()}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring(setup.OutputToString())) + + err := os.Remove(setup.OutputToString()) + Expect(err).To(BeNil()) + }) + + It("podman run bad ipc pid test", func() { + session := podmanTest.Podman([]string{"run", "--ipc=badpid", fedoraMinimal, "bash", "-c", "echo $$"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).ToNot(Equal(0)) + }) +}) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 7bd42edc4..3ca06d362 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -115,6 +115,7 @@ var _ = Describe("Podman run", func() { }) It("podman run limits test", func() { + podmanTest.RestoreArtifact(fedoraMinimal) session := podmanTest.Podman([]string{"run", "--rm", "--ulimit", "rtprio=99", "--cap-add=sys_nice", fedoraMinimal, "cat", "/proc/self/sched"}) session.Wait(45) Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go new file mode 100644 index 000000000..351e57bf5 --- /dev/null +++ b/test/e2e/save_test.go @@ -0,0 +1,96 @@ +package integration + +import ( + "os" + "path/filepath" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman save", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + }) + + It("podman save output flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + + It("podman save oci flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + + It("podman save with stdout", func() { + Skip("Pipe redirection in ginkgo probably wont work") + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", ALPINE, ">", outfile}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + + It("podman save quiet flag", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + + It("podman save bogus image", func() { + outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") + + save := podmanTest.Podman([]string{"save", "-o", outfile, "FOOBAR"}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Not(Equal(0))) + }) + + It("podman save to directory with oci format", func() { + outdir := filepath.Join(podmanTest.TempDir, "save") + + save := podmanTest.Podman([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + + It("podman save to directory with v2s2 docker format", func() { + outdir := filepath.Join(podmanTest.TempDir, "save") + + save := podmanTest.Podman([]string{"save", "--format", "docker-dir", "-o", outdir, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + + It("podman save to directory with docker format and compression", func() { + outdir := filepath.Join(podmanTest.TempDir, "save") + + save := podmanTest.Podman([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) + save.WaitWithDefaultTimeout() + Expect(save.ExitCode()).To(Equal(0)) + }) + +}) diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go new file mode 100644 index 000000000..c5ec5710d --- /dev/null +++ b/test/e2e/tag_test.go @@ -0,0 +1,69 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman tag", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman tag shortname:latest", func() { + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + 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.RepoTags)).To(BeTrue()) + Expect(StringInSlice("foobar:latest", inspectData.RepoTags)).To(BeTrue()) + }) + + It("podman tag shortname", func() { + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + 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.RepoTags)).To(BeTrue()) + Expect(StringInSlice("foobar:latest", inspectData.RepoTags)).To(BeTrue()) + }) + + It("podman tag shortname:tag", func() { + session := podmanTest.Podman([]string{"tag", ALPINE, "foobar:new"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + 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.RepoTags)).To(BeTrue()) + Expect(StringInSlice("foobar:new", inspectData.RepoTags)).To(BeTrue()) + }) +}) diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go new file mode 100644 index 000000000..c6b71bec1 --- /dev/null +++ b/test/e2e/version_test.go @@ -0,0 +1,38 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman version", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + podmanTest.RestoreArtifact(fedoraMinimal) + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman version", func() { + session := podmanTest.Podman([]string{"version"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 3)) + }) +}) diff --git a/test/podman_attach.bats b/test/podman_attach.bats deleted file mode 100644 index 605a44789..000000000 --- a/test/podman_attach.bats +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "attach to a bogus container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} attach foobar - echo "$output" - [ "$status" -eq 125 ] -} - -@test "attach to non-running container" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create --name foobar -d -i ${ALPINE} ls - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} attach foobar - echo "$output" - [ "$status" -eq 125 ] -} - -@test "attach to multiple containers" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --name foobar1 -d -i ${ALPINE} /bin/sh - ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --name foobar2 -d -i ${ALPINE} /bin/sh - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} attach foobar1 foobar2 - echo "$output" - [ "$status" -eq 125 ] -} diff --git a/test/podman_images.bats b/test/podman_images.bats deleted file mode 100644 index 5812e8f8b..000000000 --- a/test/podman_images.bats +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} -@test "podman images" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} images - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman images test valid json" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} images --format json - echo "$output" | python -m json.tool - [ "$status" -eq 0 ] -} - -@test "podman images check name json output" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi -fa - ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull ${ALPINE} - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} images --format json - [ "$status" -eq 0 ] - name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]') - [ "$name" == "docker.io/library/alpine:latest" ] -} - -@test "podman images short options" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} images -qn - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_import.bats b/test/podman_import.bats deleted file mode 100644 index 69c704a68..000000000 --- a/test/podman_import.bats +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman import with source and reference" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run bash -cp "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import container.tar imported-image" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} images" - echo "$output" - [ "$status" -eq 0 ] - [[ "$output" == *"imported-image"* ]] - rm -f container.tar -} - -@test "podman import without reference" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import container.tar" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} images" - echo "$output" - [ "$status" -eq 0 ] - [[ "$output" == *"<none>"* ]] - rm -f container.tar -} - -@test "podman import with message flag" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import --message 'importing container test message' container.tar imported-image" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} history imported-image" - echo "$output" - [ "$status" -eq 0 ] - [[ "$output" == *"importing container test message"* ]] - rm -f container.tar -} - -@test "podman import with change flag" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $ALPINE sleep 60" - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} import --change 'CMD=/bin/bash' container.tar imported-image" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect imported-image" - echo "$output" - [ "$status" -eq 0 ] - [[ "$output" == *"/bin/bash"* ]] - rm -f container.tar -} diff --git a/test/podman_inspect.bats b/test/podman_inspect.bats deleted file mode 100644 index 19e5a0a9b..000000000 --- a/test/podman_inspect.bats +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman inspect image" { - run bash -c "${PODMAN_BINARY} $PODMAN_OPTIONS inspect ${ALPINE} | python -m json.tool" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman inspect non-existent container" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS inspect 14rcole/non-existent - echo "$output" - [ "$status" -ne 0 ] -} - -@test "podman inspect with format" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS inspect --format {{.ID}} ${ALPINE} - echo "$output" - [ "$status" -eq 0 ] - inspectOutput="$output" - bash -c run ${PODMAN_BINARY} $PODMAN_OPTIONS images --no-trunc --quiet ${ALPINE} | sed -e 's/sha256://g' - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = "$inspectOutput" ] - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman inspect specified type" { - run bash -c "${PODMAN_BINARY} $PODMAN_OPTIONS inspect --type image ${ALPINE} | python -m json.tool" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman inspect container with size" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} create ${BB} ls - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} $PODMAN_OPTIONS inspect --size -l | python -m json.tool | grep SizeRootFs" - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_logs.bats b/test/podman_logs.bats deleted file mode 100644 index e76bf665a..000000000 --- a/test/podman_logs.bats +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "display logs for container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB ls - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} logs $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "tail three lines of logs for container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB ls - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} logs --tail 3 $ctr_id - echo "$output" - lines=$(echo "$output" | wc -l) - [ "$status" -eq 0 ] - [[ $(wc -l < "$output" ) -le 3 ]] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "display logs for container since a given time" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d $BB ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} logs --since 2017-08-07T10:10:09.056611202-04:00 -l - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm -l - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_run_dns.bats b/test/podman_run_dns.bats deleted file mode 100644 index d37737093..000000000 --- a/test/podman_run_dns.bats +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "test addition of a search domain" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --dns-search=foobar.com ${ALPINE} cat /etc/resolv.conf | grep foo" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "test addition of a bad dns server" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} create --dns="foo" ${ALPINE} ls - echo "$output" - [ "$status" -ne 0 ] -} - -@test "test addition of a dns server" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --dns='1.2.3.4' ${ALPINE} cat /etc/resolv.conf | grep '1.2.3.4'" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "test addition of a dns option" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --dns-opt='debug' ${ALPINE} cat /etc/resolv.conf | grep 'options debug'" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "test addition of a bad add-host" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} create --add-host="foo:1.2" ${ALPINE} ls - echo "$output" - [ "$status" -ne 0 ] -} - -@test "test addition of add-host" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --add-host='foobar:1.1.1.1' ${ALPINE} cat /etc/hosts | grep 'foobar'" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "test addition of hostname" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --hostname='foobar' ${ALPINE} cat /etc/hostname | grep foobar" - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --hostname='foobar' ${ALPINE} hostname | grep foobar" - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_run_exit.bats b/test/podman_run_exit.bats deleted file mode 100644 index 02ccb56ec..000000000 --- a/test/podman_run_exit.bats +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "run exit125 test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --foobar ${ALPINE} ls $tmp - echo $output - echo $status != 125 - [ $status -eq 125 ] -} - -@test "run exit126 test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} foobar - echo $output - echo $status != 126 - [ "$status" -eq 126 ] -} - -@test "run exit127 test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} /etc - echo $output - echo $status != 127 - [ "$status" -eq 127 ] -} - -@test "run exit0 test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} ps - echo $output - echo $status != 0 - [ "$status" -eq 0 ] -} - -@test "run exit50 test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} sh -c "exit 50" - echo $output - echo $status != 50 - [ "$status" -eq 50 ] -} diff --git a/test/podman_run_memory.bats b/test/podman_run_memory.bats deleted file mode 100644 index 2eaebe104..000000000 --- a/test/podman_run_memory.bats +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "run memory test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --memory=40m ${ALPINE} cat /sys/fs/cgroup/memory/memory.limit_in_bytes | tr -d '\r'" - echo $output - [ "$status" -eq 0 ] - [ "$output" = 41943040 ] -} - -@test "run memory-reservation test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --memory-reservation=40m ${ALPINE} cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 41943040 ] -} - -@test "run memory-swappiness test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --memory-swappiness=15 ${ALPINE} cat /sys/fs/cgroup/memory/memory.swappiness | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 15 ] -} - -@test "run kernel-memory test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --kernel-memory=40m ${ALPINE} cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 41943040 ] -} diff --git a/test/podman_run_ns.bats b/test/podman_run_ns.bats deleted file mode 100644 index 8ed710394..000000000 --- a/test/podman_run_ns.bats +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "run pidns test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} sh -c 'echo \$\$'" - echo $output - [ "$status" -eq 0 ] - pid=$(echo $output | tr -d '\r') - [ $pid = "1" ] - - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --pid=host ${ALPINE} sh -c 'echo \$\$'" - echo $output - pid=$(echo $output | tr -d '\r') - [ "$status" -eq 0 ] - [ $pid != "1" ] - - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --pid=badpid ${ALPINE} sh -c 'echo $$' - echo $output - [ "$status" -ne 0 ] -} - -@test "run ipcns test" { - tmp=$(mktemp /dev/shm/foo.XXXXX) - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --ipc=host ${ALPINE} ls $tmp - echo $output - out=$(echo $output | tr -d '\r') - [ "$status" -eq 0 ] - [ $out != $tmp ] - - rm -f $tmp - - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --ipc=badpid ${ALPINE} sh -c 'echo $$' - echo $output - [ "$status" -ne 0 ] -} diff --git a/test/podman_run_security.bats b/test/podman_run_security.bats deleted file mode 100644 index 07dabf44b..000000000 --- a/test/podman_run_security.bats +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "run privileged test" { - cap=$(grep CapEff /proc/self/status | cut -f2 -d":") - - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --privileged ${ALPINE} grep CapEff /proc/self/status - echo $output - [ "$status" -eq 0 ] - containercap=$(echo $output | tr -d '\r'| cut -f2 -d":") - [ $containercap = $cap ] - - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --cap-add all ${ALPINE} grep CapEff /proc/self/status - echo $output - [ "$status" -eq 0 ] - containercap=$(echo $output | tr -d '\r'| cut -f2 -d":") - [ $containercap = $cap ] - - cap=$(grep CapAmb /proc/self/status | cut -f2 -d":") - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --cap-drop all ${ALPINE} grep CapEff /proc/self/status - echo $output - [ "$status" -eq 0 ] - containercap=$(echo $output | tr -d '\r'| cut -f2 -d":") - [ $containercap = $cap ] -} diff --git a/test/podman_save.bats b/test/podman_save.bats deleted file mode 100644 index 5adfb8fea..000000000 --- a/test/podman_save.bats +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman save output flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman save oci flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar --format oci-archive $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman save using stdout" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} save $ALPINE > alpine.tar" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman save quiet flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -q -o alpine.tar $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -f alpine.tar -} - -@test "podman save non-existent image" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alpine.tar FOOBAR - echo "$output" - [ "$status" -ne 0 ] -} - -@test "podman save to directory with oci format" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save --format oci-dir -o alp-dir $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -rf alp-dir -} - -@test "podman save to directory with v2s2 (docker) format" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save --format docker-dir -o alp-dir $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -rf alp-dir -} - -@test "podman save to directory with compression" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save --compress --format docker-dir -o alp-dir $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -rf alp-dir - - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save --format docker-dir --compress -o alp-dir $ALPINE - echo "$output" - [ "$status" -eq 0 ] - rm -rf alp-dir -} diff --git a/test/podman_search.bats b/test/podman_search.bats new file mode 100644 index 000000000..07621d722 --- /dev/null +++ b/test/podman_search.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats + +load helpers + +function teardown() { + cleanup_test +} + +@test "podman search" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search alpine + echo "$output" + [ "$status" -eq 0 ] +} + +@test "podman search registry flag" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --registry registry.fedoraproject.org fedora + echo "$output" + [ "$status" -eq 0 ] +} + +@test "podman search filter flag" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --filter=is-official alpine + echo "$output" + [ "$status" -eq 0 ] +} + +@test "podman search format flag" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --format "table {{.Index}} {{.Name}}" alpine + echo "$output" + [ "$status" -eq 0 ] +} + +@test "podman search no-trunc flag" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --no-trunc alpine + echo "$output" + [ "$status" -eq 0 ] +} + +@test "podman search limit flag" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} search --limit 3 alpine + echo "$output" + [ "$status" -eq 0 ] +}
\ No newline at end of file diff --git a/test/podman_tag.bats b/test/podman_tag.bats deleted file mode 100644 index 749c3ae2c..000000000 --- a/test/podman_tag.bats +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman tag with shortname:latest" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} tag ${ALPINE} foobar:latest - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect foobar:latest - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi --force foobar:latest - [ "$status" -eq 0 ] -} - -@test "podman tag with shortname" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} tag ${ALPINE} foobar - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect foobar:latest - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi --force foobar:latest - [ "$status" -eq 0 ] -} - -@test "podman tag with shortname:tag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} tag ${ALPINE} foobar:v - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect foobar:v - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi --force foobar:v - [ "$status" -eq 0 ] -} diff --git a/test/podman_version.bats b/test/podman_version.bats deleted file mode 100644 index a44da5943..000000000 --- a/test/podman_version.bats +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -@test "podman version test" { - run ${PODMAN_BINARY} version - echo "$output" - [ "$status" -eq 0 ] -} |