From 6279515914f4f9208815518a419a222755580554 Mon Sep 17 00:00:00 2001 From: Michelle Au Date: Fri, 28 Dec 2018 11:49:27 -0800 Subject: [PATCH] Add e2e test for removing the subpath directory --- test/e2e/storage/testsuites/subpath.go | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/e2e/storage/testsuites/subpath.go b/test/e2e/storage/testsuites/subpath.go index bdf4a75c61..f7343b680c 100644 --- a/test/e2e/storage/testsuites/subpath.go +++ b/test/e2e/storage/testsuites/subpath.go @@ -22,7 +22,7 @@ import ( "regexp" "strings" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/wait" @@ -377,6 +377,32 @@ func testSubPath(input *subPathTestInput) { // Pod should fail testPodFailSubpath(input.f, input.pod, true) }) + + It("should be able to unmount after the subpath directory is deleted", func() { + // Change volume container to busybox so we can exec later + input.pod.Spec.Containers[1].Image = imageutils.GetE2EImage(imageutils.BusyBox) + input.pod.Spec.Containers[1].Command = []string{"/bin/sh", "-ec", "sleep 100000"} + + By(fmt.Sprintf("Creating pod %s", input.pod.Name)) + pod, err := input.f.ClientSet.CoreV1().Pods(input.f.Namespace.Name).Create(input.pod) + Expect(err).ToNot(HaveOccurred(), "while creating pod") + defer func() { + By(fmt.Sprintf("Deleting pod %s", pod.Name)) + framework.DeletePodWithWait(input.f, input.f.ClientSet, pod) + }() + + // Wait for pod to be running + err = framework.WaitForPodRunningInNamespace(input.f.ClientSet, pod) + Expect(err).ToNot(HaveOccurred(), "while waiting for pod to be running") + + // Exec into container that mounted the volume, delete subpath directory + rmCmd := fmt.Sprintf("rm -rf %s", input.subPathDir) + _, err = podContainerExec(pod, 1, rmCmd) + Expect(err).ToNot(HaveOccurred(), "while removing subpath directory") + + // Delete pod (from defer) and wait for it to be successfully deleted + }) + // TODO: add a test case for the same disk with two partitions }