Skip to content

Commit c127ba9

Browse files
committed
test: add read-only subdir e2e test
1 parent ccb8ff6 commit c127ba9

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

test/e2e/dynamic_provisioning_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,47 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
245245
test.Run(ctx, cs, ns)
246246
})
247247

248+
// Track issue https://github.com/kubernetes-csi/csi-driver-smb/issues/834
249+
ginkgo.It(fmt.Sprintf("should delete PV with reclaimPolicy even if it contains read-only subdir %q [smb.csi.k8s.io]", v1.PersistentVolumeReclaimDelete), func(ctx ginkgo.SpecContext) {
250+
skipIfTestingInWindowsCluster()
251+
reclaimPolicy := v1.PersistentVolumeReclaimDelete
252+
pod := testsuites.PodDetails{
253+
Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' >> /mnt/test-1/data && while true; do sleep 100; done"),
254+
Volumes: []testsuites.VolumeDetails{
255+
{
256+
ClaimSize: "10Gi",
257+
MountOptions: []string{
258+
"dir_mode=0777",
259+
"file_mode=0777",
260+
"noperm",
261+
},
262+
ReclaimPolicy: &reclaimPolicy,
263+
VolumeMount: testsuites.VolumeMountDetails{
264+
NameGenerate: "test-volume-",
265+
MountPathGenerate: "/mnt/test-",
266+
},
267+
},
268+
},
269+
IsWindows: isWindowsCluster,
270+
WinServerVer: winServerVer,
271+
}
272+
273+
podCheckCmd := []string{"sh", "-c", "mkdir /mnt/test-1/subdir-test;chmod a-w /mnt/test-1/subdir-test;ls -ld /mnt/test-1/subdir-test"}
274+
expectedString := "dr-xr-xr-x"
275+
276+
test := testsuites.DynamicallyProvisionedDeletePodTest{
277+
CSIDriver: testDriver,
278+
Pod: pod,
279+
PodCheck: &testsuites.PodExecCheck{
280+
Cmd: podCheckCmd,
281+
ExpectedString: expectedString,
282+
},
283+
SkipAfterRestartCheck: true,
284+
StorageClassParameters: defaultStorageClassParameters,
285+
}
286+
test.Run(ctx, cs, ns)
287+
})
288+
248289
ginkgo.It(fmt.Sprintf("should delete PV with reclaimPolicy %q [smb.csi.k8s.io] [Windows]", v1.PersistentVolumeReclaimDelete), func(ctx ginkgo.SpecContext) {
249290
reclaimPolicy := v1.PersistentVolumeReclaimDelete
250291
volumes := []testsuites.VolumeDetails{

test/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type DynamicallyProvisionedDeletePodTest struct {
3434
CSIDriver driver.DynamicPVTestDriver
3535
Pod PodDetails
3636
PodCheck *PodExecCheck
37+
SkipAfterRestartCheck bool
3738
StorageClassParameters map[string]string
3839
}
3940

@@ -67,7 +68,7 @@ func (t *DynamicallyProvisionedDeletePodTest) Run(ctx context.Context, client cl
6768
ginkgo.By("checking again that the pod is running")
6869
tDeployment.WaitForPodReady(ctx)
6970

70-
if t.PodCheck != nil {
71+
if t.PodCheck != nil && !t.SkipAfterRestartCheck {
7172
ginkgo.By("sleep 5s and then check pod exec after pod restart again")
7273
time.Sleep(5 * time.Second)
7374
// pod will be restarted so expect to see 2 instances of string

0 commit comments

Comments
 (0)