Skip to content

Commit

Permalink
test: add read-only subdir e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Phaow committed Nov 29, 2024
1 parent ccb8ff6 commit c127ba9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
41 changes: 41 additions & 0 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,47 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
test.Run(ctx, cs, ns)
})

// Track issue https://github.com/kubernetes-csi/csi-driver-smb/issues/834
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) {
skipIfTestingInWindowsCluster()
reclaimPolicy := v1.PersistentVolumeReclaimDelete
pod := testsuites.PodDetails{
Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' >> /mnt/test-1/data && while true; do sleep 100; done"),
Volumes: []testsuites.VolumeDetails{
{
ClaimSize: "10Gi",
MountOptions: []string{
"dir_mode=0777",
"file_mode=0777",
"noperm",
},
ReclaimPolicy: &reclaimPolicy,
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
},
},
IsWindows: isWindowsCluster,
WinServerVer: winServerVer,
}

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"}
expectedString := "dr-xr-xr-x"

test := testsuites.DynamicallyProvisionedDeletePodTest{
CSIDriver: testDriver,
Pod: pod,
PodCheck: &testsuites.PodExecCheck{
Cmd: podCheckCmd,
ExpectedString: expectedString,
},
SkipAfterRestartCheck: true,
StorageClassParameters: defaultStorageClassParameters,
}
test.Run(ctx, cs, ns)
})

ginkgo.It(fmt.Sprintf("should delete PV with reclaimPolicy %q [smb.csi.k8s.io] [Windows]", v1.PersistentVolumeReclaimDelete), func(ctx ginkgo.SpecContext) {
reclaimPolicy := v1.PersistentVolumeReclaimDelete
volumes := []testsuites.VolumeDetails{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type DynamicallyProvisionedDeletePodTest struct {
CSIDriver driver.DynamicPVTestDriver
Pod PodDetails
PodCheck *PodExecCheck
SkipAfterRestartCheck bool
StorageClassParameters map[string]string
}

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

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

0 comments on commit c127ba9

Please sign in to comment.