Skip to content

Commit 7740b81

Browse files
authored
Merge pull request kubernetes#93555 from cofyc/fix81368
integration: Wait for PV to be available in TestVolumeProvision
2 parents 37cda82 + 930409c commit 7740b81

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

test/integration/volumescheduling/volume_binding_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ func testVolumeProvision(t *testing.T, storageCapacity bool) {
762762
}
763763

764764
run := func(t *testing.T, test testcaseType) {
765-
// Create StorageClasses
765+
t.Log("Creating StorageClass")
766766
suffix := rand.String(4)
767767
classes := map[string]*storagev1.StorageClass{}
768768
classes[classImmediate] = makeDynamicProvisionerStorageClass(fmt.Sprintf("immediate-%v", suffix), &modeImmediate, nil)
@@ -783,35 +783,43 @@ func testVolumeProvision(t *testing.T, storageCapacity bool) {
783783
t.Fatalf("Failed to create StorageClass %q: %v", sc.Name, err)
784784
}
785785
}
786-
// Create PVs
786+
787+
t.Log("Creating PVs")
787788
for _, pvConfig := range test.pvs {
788789
pv := makePV(pvConfig.name, classes[pvConfig.scName].Name, pvConfig.preboundPVC, config.ns, pvConfig.node)
789790
if _, err := config.client.CoreV1().PersistentVolumes().Create(context.TODO(), pv, metav1.CreateOptions{}); err != nil {
790791
t.Fatalf("Failed to create PersistentVolume %q: %v", pv.Name, err)
791792
}
793+
if err := waitForPVPhase(config.client, pvConfig.name, v1.VolumeAvailable); err != nil {
794+
t.Fatalf("PersistentVolume %q failed to become available: %v", pvConfig.name, err)
795+
}
792796
}
793797

794-
// Create PVCs
798+
t.Log("Creating PVCs")
795799
for _, pvcConfig := range test.boundPvcs {
796800
pvc := makePVC(pvcConfig.name, config.ns, &classes[pvcConfig.scName].Name, pvcConfig.preboundPV)
797801
if _, err := config.client.CoreV1().PersistentVolumeClaims(config.ns).Create(context.TODO(), pvc, metav1.CreateOptions{}); err != nil {
798802
t.Fatalf("Failed to create PersistentVolumeClaim %q: %v", pvc.Name, err)
799803
}
800804
}
805+
806+
t.Log("Creating unbound PVCs")
801807
for _, pvcConfig := range test.unboundPvcs {
802808
pvc := makePVC(pvcConfig.name, config.ns, &classes[pvcConfig.scName].Name, pvcConfig.preboundPV)
803809
if _, err := config.client.CoreV1().PersistentVolumeClaims(config.ns).Create(context.TODO(), pvc, metav1.CreateOptions{}); err != nil {
804810
t.Fatalf("Failed to create PersistentVolumeClaim %q: %v", pvc.Name, err)
805811
}
806812
}
813+
814+
t.Log("Creating unbound PVCs which should be dynamically provisioned")
807815
for _, pvcConfig := range test.provisionedPvcs {
808816
pvc := makePVC(pvcConfig.name, config.ns, &classes[pvcConfig.scName].Name, pvcConfig.preboundPV)
809817
if _, err := config.client.CoreV1().PersistentVolumeClaims(config.ns).Create(context.TODO(), pvc, metav1.CreateOptions{}); err != nil {
810818
t.Fatalf("Failed to create PersistentVolumeClaim %q: %v", pvc.Name, err)
811819
}
812820
}
813821

814-
// Create Pod
822+
t.Log("Creating the pod to schedule")
815823
if _, err := config.client.CoreV1().Pods(config.ns).Create(context.TODO(), test.pod, metav1.CreateOptions{}); err != nil {
816824
t.Fatalf("Failed to create Pod %q: %v", test.pod.Name, err)
817825
}
@@ -825,7 +833,7 @@ func testVolumeProvision(t *testing.T, storageCapacity bool) {
825833
}
826834
}
827835

828-
// Validate PVC/PV binding
836+
t.Log("Validating PVC/PV binding")
829837
for _, pvc := range test.boundPvcs {
830838
validatePVCPhase(t, config.client, pvc.name, config.ns, v1.ClaimBound, false)
831839
}
@@ -840,6 +848,7 @@ func testVolumeProvision(t *testing.T, storageCapacity bool) {
840848
}
841849

842850
// Force delete objects, but they still may not be immediately removed
851+
t.Log("Deleting test objects")
843852
deleteTestObjects(config.client, config.ns, deleteOption)
844853
}
845854

0 commit comments

Comments
 (0)