diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-05-28 13:27:23 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-06-11 11:01:13 +0200 |
commit | 7d71d24440afbf30689c53c2c69205072e4b029f (patch) | |
tree | 20ae3d75ac79b2e9cf5a237ce4582ecd6a508b9c /test | |
parent | 7f5aabb08389f9baee49bd76ab21f876e0bb70b9 (diff) | |
download | podman-7d71d24440afbf30689c53c2c69205072e4b029f.tar.gz podman-7d71d24440afbf30689c53c2c69205072e4b029f.tar.bz2 podman-7d71d24440afbf30689c53c2c69205072e4b029f.zip |
podman-pod{rm,start,stop}: support --pod-id-file
Support the `--pod-id-file` flag in the rm, start and stop pod commands.
This completes the already support flag in pod-create and is another
prerequisite for generating generic systemd unit files for pods.
Also add completions, docs and tests.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/pod_rm_test.go | 69 | ||||
-rw-r--r-- | test/e2e/pod_start_test.go | 57 | ||||
-rw-r--r-- | test/e2e/pod_stop_test.go | 69 |
3 files changed, 195 insertions, 0 deletions
diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index 4060e1268..d0ece7b53 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -2,6 +2,7 @@ package integration import ( "fmt" + "io/ioutil" "os" "path/filepath" "strings" @@ -229,4 +230,72 @@ var _ = Describe("Podman pod rm", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) + + It("podman pod start/remove single pod via --pod-id-file", func() { + tmpDir, err := ioutil.TempDir("", "") + Expect(err).To(BeNil()) + tmpFile := tmpDir + "podID" + defer os.RemoveAll(tmpDir) + + podName := "rudolph" + + // Create a pod with --pod-id-file. + session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Create container inside the pod. + session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) // infra+top + + session = podmanTest.Podman([]string{"pod", "rm", "--pod-id-file", tmpFile, "--force"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + }) + + It("podman pod start/remove multiple pods via --pod-id-file", func() { + tmpDir, err := ioutil.TempDir("", "") + Expect(err).To(BeNil()) + defer os.RemoveAll(tmpDir) + + podIDFiles := []string{} + for _, i := range "0123456789" { + tmpFile := tmpDir + "cid" + string(i) + podName := "rudolph" + string(i) + // Create a pod with --pod-id-file. + session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Create container inside the pod. + session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Append the id files along with the command. + podIDFiles = append(podIDFiles, "--pod-id-file") + podIDFiles = append(podIDFiles, tmpFile) + } + + cmd := []string{"pod", "start"} + cmd = append(cmd, podIDFiles...) + session := podmanTest.Podman(cmd) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(20)) // 10*(infra+top) + + cmd = []string{"pod", "rm", "--force"} + cmd = append(cmd, podIDFiles...) + session = podmanTest.Podman(cmd) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + }) }) diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go index 8e78cadfd..4502a76ed 100644 --- a/test/e2e/pod_start_test.go +++ b/test/e2e/pod_start_test.go @@ -1,6 +1,7 @@ package integration import ( + "io/ioutil" "os" . "github.com/containers/libpod/test/utils" @@ -136,4 +137,60 @@ var _ = Describe("Podman pod start", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) }) + + It("podman pod start single pod via --pod-id-file", func() { + tmpDir, err := ioutil.TempDir("", "") + Expect(err).To(BeNil()) + tmpFile := tmpDir + "podID" + defer os.RemoveAll(tmpDir) + + podName := "rudolph" + + // Create a pod with --pod-id-file. + session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Create container inside the pod. + session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) // infra+top + }) + + It("podman pod start multiple pods via --pod-id-file", func() { + tmpDir, err := ioutil.TempDir("", "") + Expect(err).To(BeNil()) + defer os.RemoveAll(tmpDir) + + podIDFiles := []string{} + for _, i := range "0123456789" { + tmpFile := tmpDir + "cid" + string(i) + podName := "rudolph" + string(i) + // Create a pod with --pod-id-file. + session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Create container inside the pod. + session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Append the id files along with the command. + podIDFiles = append(podIDFiles, "--pod-id-file") + podIDFiles = append(podIDFiles, tmpFile) + } + + cmd := []string{"pod", "start"} + cmd = append(cmd, podIDFiles...) + session := podmanTest.Podman(cmd) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(20)) // 10*(infra+top) + }) }) diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go index 0a46b07c9..0fe580921 100644 --- a/test/e2e/pod_stop_test.go +++ b/test/e2e/pod_stop_test.go @@ -1,6 +1,7 @@ package integration import ( + "io/ioutil" "os" . "github.com/containers/libpod/test/utils" @@ -175,4 +176,72 @@ var _ = Describe("Podman pod stop", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) }) + + It("podman pod start/stop single pod via --pod-id-file", func() { + tmpDir, err := ioutil.TempDir("", "") + Expect(err).To(BeNil()) + tmpFile := tmpDir + "podID" + defer os.RemoveAll(tmpDir) + + podName := "rudolph" + + // Create a pod with --pod-id-file. + session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Create container inside the pod. + session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"pod", "start", "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) // infra+top + + session = podmanTest.Podman([]string{"pod", "stop", "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + }) + + It("podman pod start/stop multiple pods via --pod-id-file", func() { + tmpDir, err := ioutil.TempDir("", "") + Expect(err).To(BeNil()) + defer os.RemoveAll(tmpDir) + + podIDFiles := []string{} + for _, i := range "0123456789" { + tmpFile := tmpDir + "cid" + string(i) + podName := "rudolph" + string(i) + // Create a pod with --pod-id-file. + session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--pod-id-file", tmpFile}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Create container inside the pod. + session = podmanTest.Podman([]string{"create", "--pod", podName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // Append the id files along with the command. + podIDFiles = append(podIDFiles, "--pod-id-file") + podIDFiles = append(podIDFiles, tmpFile) + } + + cmd := []string{"pod", "start"} + cmd = append(cmd, podIDFiles...) + session := podmanTest.Podman(cmd) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(20)) // 10*(infra+top) + + cmd = []string{"pod", "stop"} + cmd = append(cmd, podIDFiles...) + session = podmanTest.Podman(cmd) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + }) }) |