summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorAlban Bedel <albeu@free.fr>2020-11-18 20:42:37 +0100
committerAlban Bedel <albeu@free.fr>2020-11-27 11:38:33 +0100
commitb84304da5e720df11ebb2093c68a6f7e8a684b34 (patch)
tree47940bdbfa9c1ee3d7344d403625e0c727dd63cc /test/e2e
parentad2439264d401af0443be564ccc68169a8517db4 (diff)
downloadpodman-b84304da5e720df11ebb2093c68a6f7e8a684b34.tar.gz
podman-b84304da5e720df11ebb2093c68a6f7e8a684b34.tar.bz2
podman-b84304da5e720df11ebb2093c68a6f7e8a684b34.zip
Prepare support in kube play for other volume types than hostPath
Replace the simple map of names to paths with a map of names to a struct to allow passing more parameters. Also move the code to parse the volumes to its own file to avoid making the playKubePod() function overly complex. Finally rework the kube volumes test to also be ready to support more volume types. Signed-off-by: Alban Bedel <albeu@free.fr>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/play_kube_test.go48
1 files changed, 29 insertions, 19 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 92e4544f9..eb82b3862 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -164,9 +164,11 @@ spec:
volumes:
{{ range . }}
- name: {{ .Name }}
+ {{- if (eq .VolumeType "HostPath") }}
hostPath:
- path: {{ .Path }}
- type: {{ .Type }}
+ path: {{ .HostPath.Path }}
+ type: {{ .HostPath.Type }}
+ {{- end }}
{{ end }}
{{ end }}
status: {}
@@ -692,19 +694,27 @@ func getCtrNameInPod(pod *Pod) string {
return fmt.Sprintf("%s-%s", pod.Name, defaultCtrName)
}
-type Volume struct {
- Name string
+type HostPath struct {
Path string
Type string
}
-// getVolume takes a type and a location for a volume
-// giving it a default name of volName
-func getVolume(vType, vPath string) *Volume {
+type Volume struct {
+ VolumeType string
+ Name string
+ HostPath
+}
+
+// getHostPathVolume takes a type and a location for a HostPath
+// volume giving it a default name of volName
+func getHostPathVolume(vType, vPath string) *Volume {
return &Volume{
- Name: defaultVolName,
- Path: vPath,
- Type: vType,
+ VolumeType: "HostPath",
+ Name: defaultVolName,
+ HostPath: HostPath{
+ Path: vPath,
+ Type: vType,
+ },
}
}
@@ -1257,7 +1267,7 @@ spec:
It("podman play kube test with non-existent empty HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume(`""`, hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume(`""`, hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1272,7 +1282,7 @@ spec:
Expect(err).To(BeNil())
f.Close()
- pod := getPod(withVolume(getVolume(`""`, hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume(`""`, hostPathLocation)))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1284,7 +1294,7 @@ spec:
It("podman play kube test with non-existent File HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume("File", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1299,7 +1309,7 @@ spec:
Expect(err).To(BeNil())
f.Close()
- pod := getPod(withVolume(getVolume("File", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1311,7 +1321,7 @@ spec:
It("podman play kube test with FileOrCreate HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume("FileOrCreate", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("FileOrCreate", hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1327,7 +1337,7 @@ spec:
It("podman play kube test with DirectoryOrCreate HostPath type volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
- pod := getPod(withVolume(getVolume("DirectoryOrCreate", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("DirectoryOrCreate", hostPathLocation)))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1347,7 +1357,7 @@ spec:
Expect(err).To(BeNil())
f.Close()
- pod := getPod(withVolume(getVolume("Socket", hostPathLocation)))
+ pod := getPod(withVolume(getHostPathVolume("Socket", hostPathLocation)))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1356,14 +1366,14 @@ spec:
Expect(kube.ExitCode()).NotTo(Equal(0))
})
- It("podman play kube test with read only volume", func() {
+ It("podman play kube test with read only HostPath volume", func() {
hostPathLocation := filepath.Join(tempdir, "file")
f, err := os.Create(hostPathLocation)
Expect(err).To(BeNil())
f.Close()
ctr := getCtr(withVolumeMount(hostPathLocation, true), withImage(BB))
- pod := getPod(withVolume(getVolume("File", hostPathLocation)), withCtr(ctr))
+ pod := getPod(withVolume(getHostPathVolume("File", hostPathLocation)), withCtr(ctr))
err = generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())