Skip to content

Commit 8d64409

Browse files
committed
Create pod to force volume provisioning in storage e2e test
Otherwise, tests can fail if the default StorageClass is configured with late binding.
1 parent d62762f commit 8d64409

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/e2e/storage/testsuites/provisioning.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,23 @@ func (t StorageClassTest) TestDynamicProvisioning() *v1.PersistentVolume {
350350
}
351351
}()
352352

353+
if class == nil {
354+
// StorageClass is nil, so the default one will be used
355+
scName, err := e2epv.GetDefaultStorageClassName(client)
356+
framework.ExpectNoError(err)
357+
defaultSC, err := client.StorageV1().StorageClasses().Get(context.TODO(), scName, metav1.GetOptions{})
358+
framework.ExpectNoError(err)
359+
// If late binding is configured, create and delete a pod to provision the volume
360+
if *defaultSC.VolumeBindingMode == storagev1.VolumeBindingWaitForFirstConsumer {
361+
ginkgo.By("creating a pod referring to the claim")
362+
var pod *v1.Pod
363+
pod, err := e2epod.CreatePod(t.Client, claim.Namespace, nil /* nodeSelector */, []*v1.PersistentVolumeClaim{claim}, true /* isPrivileged */, "" /* command */)
364+
// Delete pod now, otherwise PV can't be deleted below
365+
framework.ExpectNoError(err)
366+
e2epod.DeletePodOrFail(t.Client, pod.Namespace, pod.Name)
367+
}
368+
}
369+
353370
// Run the checker
354371
if t.PvCheck != nil {
355372
t.PvCheck(claim)

0 commit comments

Comments
 (0)