diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-09-18 06:19:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-18 06:19:19 -0400 |
commit | fc131a207ebaf6aa16717781bf78c78690f0408e (patch) | |
tree | 01d147dc5f5a12a380d1f795d6f9e2c58a7012bf /test/e2e/generate_kube_test.go | |
parent | 4b037d2acccd0de8a09fff91be6c266739e68694 (diff) | |
parent | f0ccac199bd500729dabc8948bbd4ddd0124231e (diff) | |
download | podman-fc131a207ebaf6aa16717781bf78c78690f0408e.tar.gz podman-fc131a207ebaf6aa16717781bf78c78690f0408e.tar.bz2 podman-fc131a207ebaf6aa16717781bf78c78690f0408e.zip |
Merge pull request #7671 from zhangguanzhang/play-kube-handle-restartPolicy
handle the restartPolicy for play kube and generate kube
Diffstat (limited to 'test/e2e/generate_kube_test.go')
-rw-r--r-- | test/e2e/generate_kube_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index e886c6000..a3a841dc6 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -3,6 +3,7 @@ package integration import ( "os" "path/filepath" + "strconv" . "github.com/containers/podman/v2/test/utils" "github.com/ghodss/yaml" @@ -201,6 +202,39 @@ var _ = Describe("Podman generate kube", func() { // Expect(err).To(BeNil()) }) + It("podman generate kube on pod with restartPolicy", func() { + // podName, set, expect + testSli := [][]string{ + {"testPod1", "", "Never"}, // some pod create from cmdline, so set it to Never + {"testPod2", "always", "Always"}, + {"testPod3", "on-failure", "OnFailure"}, + {"testPod4", "no", "Never"}, + } + + for k, v := range testSli { + podName := v[0] + podSession := podmanTest.Podman([]string{"pod", "create", "--name", podName}) + podSession.WaitWithDefaultTimeout() + Expect(podSession.ExitCode()).To(Equal(0)) + + ctrName := "ctr" + strconv.Itoa(k) + ctr1Session := podmanTest.Podman([]string{"create", "--name", ctrName, "--pod", podName, + "--restart", v[1], ALPINE, "top"}) + ctr1Session.WaitWithDefaultTimeout() + Expect(ctr1Session.ExitCode()).To(Equal(0)) + + kube := podmanTest.Podman([]string{"generate", "kube", podName}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + pod := new(v1.Pod) + err := yaml.Unmarshal(kube.Out.Contents(), pod) + Expect(err).To(BeNil()) + + Expect(string(pod.Spec.RestartPolicy)).To(Equal(v[2])) + } + }) + It("podman generate kube on pod with ports", func() { podName := "test" podSession := podmanTest.Podman([]string{"pod", "create", "--name", podName, "-p", "4000:4000", "-p", "5000:5000"}) |