summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2022-07-24 19:44:41 -0400
committerUrvashi Mohnani <umohnani@redhat.com>2022-08-30 10:34:45 -0400
commit98169c20ddc09d8fa14d556e93cad3259b5ccca9 (patch)
tree693394b009dcd1b81425dcf5a8f9474ed333409a /test/e2e
parent57441b4c7127b30d9327cb4dfa189c8b9fc33ac5 (diff)
downloadpodman-98169c20ddc09d8fa14d556e93cad3259b5ccca9.tar.gz
podman-98169c20ddc09d8fa14d556e93cad3259b5ccca9.tar.bz2
podman-98169c20ddc09d8fa14d556e93cad3259b5ccca9.zip
Add emptyDir volume support to kube play
When a kube yaml has a volume set as empty dir, podman will create an anonymous volume with the empty dir name and attach it to the containers running in the pod. When the pod is removed, the empy dir volume created is also removed. Add tests and docs for this as well. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/play_kube_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 7d3a2224c..d1eb960cd 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -509,6 +509,9 @@ spec:
volumes:
{{ range . }}
- name: {{ .Name }}
+ {{- if (eq .VolumeType "EmptyDir") }}
+ emptyDir: {}
+ {{- end }}
{{- if (eq .VolumeType "HostPath") }}
hostPath:
path: {{ .HostPath.Path }}
@@ -1242,12 +1245,15 @@ type ConfigMap struct {
Optional bool
}
+type EmptyDir struct{}
+
type Volume struct {
VolumeType string
Name string
HostPath
PersistentVolumeClaim
ConfigMap
+ EmptyDir
}
// getHostPathVolume takes a type and a location for a HostPath
@@ -1289,6 +1295,14 @@ func getConfigMapVolume(vName string, items []map[string]string, optional bool)
}
}
+func getEmptyDirVolume() *Volume {
+ return &Volume{
+ VolumeType: "EmptyDir",
+ Name: defaultVolName,
+ EmptyDir: EmptyDir{},
+ }
+}
+
type Env struct {
Name string
Value string
@@ -2762,6 +2776,43 @@ VOLUME %s`, ALPINE, hostPathDir+"/")
Expect(kube).Should(Exit(0))
})
+ It("podman play kube with emptyDir volume", func() {
+ podName := "test-pod"
+ ctrName1 := "vol-test-ctr"
+ ctrName2 := "vol-test-ctr-2"
+ ctr1 := getCtr(withVolumeMount("/test-emptydir", false), withImage(BB), withName(ctrName1))
+ ctr2 := getCtr(withVolumeMount("/test-emptydir-2", false), withImage(BB), withName(ctrName2))
+ pod := getPod(withPodName(podName), withVolume(getEmptyDirVolume()), withCtr(ctr1), withCtr(ctr2))
+ err = generateKubeYaml("pod", pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube).Should(Exit(0))
+
+ emptyDirCheck1 := podmanTest.Podman([]string{"exec", podName + "-" + ctrName1, "ls", "/test-emptydir"})
+ emptyDirCheck1.WaitWithDefaultTimeout()
+ Expect(emptyDirCheck1).Should(Exit(0))
+
+ emptyDirCheck2 := podmanTest.Podman([]string{"exec", podName + "-" + ctrName2, "ls", "/test-emptydir-2"})
+ emptyDirCheck2.WaitWithDefaultTimeout()
+ Expect(emptyDirCheck2).Should(Exit(0))
+
+ volList1 := podmanTest.Podman([]string{"volume", "ls", "-q"})
+ volList1.WaitWithDefaultTimeout()
+ Expect(volList1).Should(Exit(0))
+ Expect(volList1.OutputToString()).To(Equal(defaultVolName))
+
+ remove := podmanTest.Podman([]string{"pod", "rm", "-f", podName})
+ remove.WaitWithDefaultTimeout()
+ Expect(remove).Should(Exit(0))
+
+ volList2 := podmanTest.Podman([]string{"volume", "ls", "-q"})
+ volList2.WaitWithDefaultTimeout()
+ Expect(volList2).Should(Exit(0))
+ Expect(volList2.OutputToString()).To(Equal(""))
+ })
+
It("podman play kube applies labels to pods", func() {
var numReplicas int32 = 5
expectedLabelKey := "key1"