diff options
author | baude <bbaude@redhat.com> | 2018-02-02 19:05:23 -0600 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-02-05 20:17:37 +0000 |
commit | 3609b82fe6f5fe268cdbe9f8aba43140c4e81f90 (patch) | |
tree | 885ee7015b2f15ce20cdff768b3468ff4c0ad492 /test | |
parent | 1ac11dcf8423575f4e5f5f758b8989cf3fcc389b (diff) | |
download | podman-3609b82fe6f5fe268cdbe9f8aba43140c4e81f90.tar.gz podman-3609b82fe6f5fe268cdbe9f8aba43140c4e81f90.tar.bz2 podman-3609b82fe6f5fe268cdbe9f8aba43140c4e81f90.zip |
Migrate diff, exec, export, and history to ginkgo
Migrate the diff, exec, export, and history bats tests to
the ginkgo test suite.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #287
Approved by: baude
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/diff_test.go | 50 | ||||
-rw-r--r-- | test/e2e/exec_test.go | 62 | ||||
-rw-r--r-- | test/e2e/export_test.go | 46 | ||||
-rw-r--r-- | test/e2e/history_test.go | 72 | ||||
-rw-r--r-- | test/e2e/run_cpu_test.go | 89 | ||||
-rw-r--r-- | test/e2e/run_device_test.go | 43 | ||||
-rw-r--r-- | test/podman_diff.bats | 29 | ||||
-rw-r--r-- | test/podman_exec.bats | 37 | ||||
-rw-r--r-- | test/podman_export.bats | 25 | ||||
-rw-r--r-- | test/podman_history.bats | 53 | ||||
-rw-r--r-- | test/podman_run_cpu.bats | 71 | ||||
-rw-r--r-- | test/podman_run_device.bats | 26 |
12 files changed, 362 insertions, 241 deletions
diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go new file mode 100644 index 000000000..eca485c8b --- /dev/null +++ b/test/e2e/diff_test.go @@ -0,0 +1,50 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman diff", 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 diff of image", func() { + session := podmanTest.Podman([]string{"diff", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + + It("podman diff bogus image", func() { + session := podmanTest.Podman([]string{"diff", "1234"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + }) + + It("podman diff image with json output", func() { + session := podmanTest.Podman([]string{"diff", "--format=json", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.IsJSONOutputValid()).To(BeTrue()) + }) +}) diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go new file mode 100644 index 000000000..6c88cf072 --- /dev/null +++ b/test/e2e/exec_test.go @@ -0,0 +1,62 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman exec", 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 exec into bogus container", func() { + session := podmanTest.Podman([]string{"exec", "foobar", "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + }) + + It("podman exec without command", func() { + session := podmanTest.Podman([]string{"exec", "foobar"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + }) + + It("podman exec simple command", func() { + setup := podmanTest.RunSleepContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", "test1", "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman exec simple command using latest", func() { + setup := podmanTest.RunSleepContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", "-l", "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) +}) diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go new file mode 100644 index 000000000..6746ac769 --- /dev/null +++ b/test/e2e/export_test.go @@ -0,0 +1,46 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "path/filepath" +) + +var _ = Describe("Podman export", 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 export output flag", func() { + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + outfile := filepath.Join(podmanTest.TempDir, "container.tar") + result := podmanTest.Podman([]string{"export", "-o", outfile, cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + _, err := os.Stat(outfile) + Expect(err).To(BeNil()) + + err = os.Remove(outfile) + Expect(err).To(BeNil()) + }) +}) diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go new file mode 100644 index 000000000..a317331ff --- /dev/null +++ b/test/e2e/history_test.go @@ -0,0 +1,72 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman history", 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 history output flag", func() { + session := podmanTest.Podman([]string{"history", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + + It("podman history with GO template", func() { + session := podmanTest.Podman([]string{"history", "--format", "{{.ID}} {{.Created}}", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + + It("podman history with human flag", func() { + session := podmanTest.Podman([]string{"history", "--human=false", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + + It("podman history with quiet flag", func() { + session := podmanTest.Podman([]string{"history", "-qH", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + + It("podman history with no-trunc flag", func() { + session := podmanTest.Podman([]string{"history", "--no-trunc", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + + It("podman history with json flag", func() { + session := podmanTest.Podman([]string{"history", "--format=json", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.IsJSONOutputValid()).To(BeTrue()) + }) +}) diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go new file mode 100644 index 000000000..ca0fb5166 --- /dev/null +++ b/test/e2e/run_cpu_test.go @@ -0,0 +1,89 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman run cpu", 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 cpu-period", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpu-period=5000", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.cfs_period_us"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("5000")) + }) + + It("podman run cpu-quota", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpu-quota=5000", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("5000")) + }) + + It("podman run cpus", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpus=0.5", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.cfs_period_us"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("100000")) + + result = podmanTest.Podman([]string{"run", "--rm", "--cpus=0.5", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("50000")) + }) + + It("podman run cpu-shares", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpu-shares=2", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.shares"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("2")) + }) + + It("podman run cpuset-cpus", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpuset-cpus=0", ALPINE, "cat", "/sys/fs/cgroup/cpuset/cpuset.cpus"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("0")) + }) + + It("podman run cpuset-mems", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpuset-mems=0", ALPINE, "cat", "/sys/fs/cgroup/cpuset/cpuset.mems"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToString()).To(Equal("0")) + }) + + It("podman run cpus and cpu-period", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpu-period=5000", "--cpus=0.5", ALPINE, "ls"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Not(Equal(0))) + }) + + It("podman run cpus and cpu-quota", func() { + result := podmanTest.Podman([]string{"run", "--rm", "--cpu-quota=5000", "--cpus=0.5", ALPINE, "ls"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Not(Equal(0))) + }) +}) diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go new file mode 100644 index 000000000..ab39d2cbd --- /dev/null +++ b/test/e2e/run_device_test.go @@ -0,0 +1,43 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman kill", 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 bad device test", func() { + session := podmanTest.Podman([]string{"run", "-q", "--device", "/dev/baddevice", ALPINE, "ls", "/dev/kmsg"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman run device test", func() { + session := podmanTest.Podman([]string{"run", "-q", "--device", "/dev/kmsg", ALPINE, "ls", "--color=never", "/dev/kmsg"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("/dev/kmsg")) + }) +}) diff --git a/test/podman_diff.bats b/test/podman_diff.bats deleted file mode 100644 index ed1a17309..000000000 --- a/test/podman_diff.bats +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function setup() { - copy_images -} - -function teardown() { - cleanup_test -} - -@test "test diff of image and parent" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS diff $BB - echo "$output" - [ "$status" -eq 0 ] -} - -@test "test diff on non-existent layer" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS diff "abc123" - echo "$output" - [ "$status" -ne 0 ] -} - -@test "test diff with json output" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS diff --format json $BB - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_exec.bats b/test/podman_exec.bats deleted file mode 100644 index f62da59a3..000000000 --- a/test/podman_exec.bats +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "exec into a bogus container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} exec foobar ls - echo "$output" - [ "$status" -eq 125 ] -} - -@test "exec without command should fail" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} exec foobar - echo "$output" - [ "$status" -eq 125 ] -} - -@test "exec simple command" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d -t --name foobar1 ${ALPINE} sleep 60 - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} exec foobar1 ls - echo "$output" - [ "$status" -eq 0 ] -} - -@test "exec simple command using latest" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d -t ${ALPINE} sleep 60 - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} exec -l ls - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_export.bats b/test/podman_export.bats deleted file mode 100644 index 40fc7bb4f..000000000 --- a/test/podman_export.bats +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman export output flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} export -o container.tar $ctr_id - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rm $ctr_id - echo "$output" - [ "$status" -eq 0 ] - rm -f container.tar -} diff --git a/test/podman_history.bats b/test/podman_history.bats deleted file mode 100644 index 2eeb1b5ac..000000000 --- a/test/podman_history.bats +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman history default" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} history $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman history with Go template format" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} history --format "{{.ID}} {{.Created}}" $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman history human flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} history --human=false $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman history quiet flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} history -q $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman history no-trunc flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} history --no-trunc $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman history json flag" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} history --format json $ALPINE | python -m json.tool" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman history short options" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} history -qH $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_run_cpu.bats b/test/podman_run_cpu.bats deleted file mode 100644 index ebd411b41..000000000 --- a/test/podman_run_cpu.bats +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "run cpu-period test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-period=5000 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_period_us | tr -d '\r'" - echo $output - [ "$status" -eq 0 ] - [ "$output" = 5000 ] -} - -@test "run cpu-quota test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-quota=5000 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 5000 ] -} - -@test "run cpus test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpus=0.5 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_period_us | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 100000 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpus=0.5 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 50000 ] -} - -@test "run cpu-shares test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-shares=2 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.shares | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 2 ] -} - -@test "run cpuset-cpus test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpuset-cpus=0 ${ALPINE} cat /sys/fs/cgroup/cpuset/cpuset.cpus | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 0 ] -} - -@test "run cpuset-mems test" { - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpuset-mems=0 ${ALPINE} cat /sys/fs/cgroup/cpuset/cpuset.mems | tr -d '\r'" - echo "$output" - [ "$status" -eq 0 ] - [ "$output" = 0 ] -} - -@test "run failure if cpus and cpu-period set together test" { - # skip, error code incorrect with bash -c and will fail centos test without bash -c - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-period=5000 --cpus=0.5 ${ALPINE} /bin/bash - echo "$output" - [ "$status" -ne 0 ] -} - -@test "run failure if cpus and cpu-quota set together test" { - # skip, error code incorrect with bash -c and will fail centos test without bash -c - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-quota=5000 --cpus=0.5 ${ALPINE} /bin/bash - echo "$output" - [ "$status" -ne 0 ] -} diff --git a/test/podman_run_device.bats b/test/podman_run_device.bats deleted file mode 100644 index b5a901ff9..000000000 --- a/test/podman_run_device.bats +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "run baddevice test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -q --device /dev/baddevice ${ALPINE} ls /dev/kmsg - echo $output - [ "$status" -ne 0 ] -} - -@test "run device test" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -q --device /dev/kmsg ${ALPINE} ls --color=never /dev/kmsg - echo "$output" - [ "$status" -eq 0 ] - device=$(echo $output | tr -d '\r') - echo "<$device>" - [ "$device" = "/dev/kmsg" ] -} |