summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChen Zhiwei <zhiweik@gmail.com>2021-09-21 05:30:10 -0400
committerChen Zhiwei <zhiweik@gmail.com>2021-10-08 10:14:35 +0800
commit6fc73ea4ea4fa8b82092fc605390d3cfece97dd1 (patch)
treea3705e99f19f204f87bbb927d25e7c5988af3cec /test
parent14c0fcc6b7b3e8c1f28efea329ab9a6bf0d99b70 (diff)
downloadpodman-6fc73ea4ea4fa8b82092fc605390d3cfece97dd1.tar.gz
podman-6fc73ea4ea4fa8b82092fc605390d3cfece97dd1.tar.bz2
podman-6fc73ea4ea4fa8b82092fc605390d3cfece97dd1.zip
[CI:DOCS] introduce --replace flag for play kube
With this flag, users can easily sync up the yaml content with the existing pods. Fixes #11481 Signed-off-by: Chen Zhiwei <zhiweik@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/play_kube_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index a29d0ad46..079bb53b5 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -2798,4 +2798,58 @@ invalid kube kind
exists.WaitWithDefaultTimeout()
Expect(exists).To(Exit(0))
})
+
+ It("podman play kube replace", func() {
+ pod := getPod()
+ err := generateKubeYaml("pod", pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube).Should(Exit(0))
+
+ ls := podmanTest.Podman([]string{"pod", "ps", "--format", "'{{.ID}}'"})
+ ls.WaitWithDefaultTimeout()
+ Expect(ls).Should(Exit(0))
+ Expect(len(ls.OutputToStringArray())).To(Equal(1))
+
+ containerLen := podmanTest.Podman([]string{"pod", "inspect", pod.Name, "--format", "'{{len .Containers}}'"})
+
+ ctr01Name := "ctr01"
+ ctr02Name := "ctr02"
+
+ ctr01 := getCtr(withName(ctr01Name))
+ ctr02 := getCtr(withName(ctr02Name))
+
+ newPod := getPod(
+ withCtr(ctr01),
+ withCtr(ctr02),
+ )
+ err = generateKubeYaml("pod", newPod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ replace := podmanTest.Podman([]string{"play", "kube", "--replace", kubeYaml})
+ replace.WaitWithDefaultTimeout()
+ Expect(replace).Should(Exit(0))
+
+ newContainerLen := podmanTest.Podman([]string{"pod", "inspect", newPod.Name, "--format", "'{{len .Containers}}'"})
+ newContainerLen.WaitWithDefaultTimeout()
+ Expect(newContainerLen).Should(Exit(0))
+ Expect(newContainerLen.OutputToString()).NotTo(Equal(containerLen.OutputToString()))
+ })
+
+ It("podman play kube replace non-existing pod", func() {
+ pod := getPod()
+ err := generateKubeYaml("pod", pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ replace := podmanTest.Podman([]string{"play", "kube", "--replace", kubeYaml})
+ replace.WaitWithDefaultTimeout()
+ Expect(replace).Should(Exit(0))
+
+ ls := podmanTest.Podman([]string{"pod", "ps", "--format", "'{{.ID}}'"})
+ ls.WaitWithDefaultTimeout()
+ Expect(ls).Should(Exit(0))
+ Expect(len(ls.OutputToStringArray())).To(Equal(1))
+ })
})