diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-10-06 19:43:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-06 19:43:47 +0200 |
commit | ab3d3f818d1cc8dc5803c7022876fc87ba39914d (patch) | |
tree | 7f2a14bf2ac19e2d74023ca697502b447fe85333 /test | |
parent | eb85012064804a5d6c027b77bf434970a6a141f9 (diff) | |
parent | 8b189c0a0627e04578fe6591e61af850182b78be (diff) | |
download | podman-ab3d3f818d1cc8dc5803c7022876fc87ba39914d.tar.gz podman-ab3d3f818d1cc8dc5803c7022876fc87ba39914d.tar.bz2 podman-ab3d3f818d1cc8dc5803c7022876fc87ba39914d.zip |
Merge pull request #16067 from tyler92/fix-directory-or-create
Create a full path to a directory when DirectoryOrCreate is used
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/play_kube_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 8b9e43f65..97823e232 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -2604,6 +2604,36 @@ spec: Expect(st.Mode().IsDir()).To(Equal(true)) }) + It("podman play kube test with DirectoryOrCreate HostPath type volume and non-existent directory path", func() { + hostPathLocation := filepath.Join(filepath.Join(tempdir, "dir1"), "dir2") + + pod := getPod(withVolume(getHostPathVolume("DirectoryOrCreate", hostPathLocation))) + err := generateKubeYaml("pod", pod, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube).Should(Exit(0)) + + // the full path should have been created + st, err := os.Stat(hostPathLocation) + Expect(err).To(BeNil()) + Expect(st.Mode().IsDir()).To(Equal(true)) + }) + + It("podman play kube test with DirectoryOrCreate HostPath type volume and existent directory path", func() { + hostPathLocation := filepath.Join(filepath.Join(tempdir, "dir1"), "dir2") + Expect(os.MkdirAll(hostPathLocation, os.ModePerm)).To(BeNil()) + + pod := getPod(withVolume(getHostPathVolume("DirectoryOrCreate", hostPathLocation))) + err := generateKubeYaml("pod", pod, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube).Should(Exit(0)) + }) + It("podman play kube test with Socket HostPath type volume should fail if not socket", func() { hostPathLocation := filepath.Join(tempdir, "file") f, err := os.Create(hostPathLocation) |