mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Switch PD tests to use delayed binding
This commit is contained in:
parent
81985203bf
commit
bbf6683e22
@ -381,8 +381,9 @@ func (g *gcePDCSIDriver) GetDynamicProvisionStorageClass(config *testsuites.PerT
|
||||
if fsType != "" {
|
||||
parameters["csi.storage.k8s.io/fstype"] = fsType
|
||||
}
|
||||
delayedBinding := storagev1.VolumeBindingWaitForFirstConsumer
|
||||
|
||||
return testsuites.GetStorageClass(provisioner, parameters, nil, ns, suffix)
|
||||
return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix)
|
||||
}
|
||||
|
||||
func (g *gcePDCSIDriver) GetClaimSize() string {
|
||||
|
@ -1186,8 +1186,9 @@ func (g *gcePdDriver) GetDynamicProvisionStorageClass(config *testsuites.PerTest
|
||||
}
|
||||
ns := config.Framework.Namespace.Name
|
||||
suffix := fmt.Sprintf("%s-sc", g.driverInfo.Name)
|
||||
delayedBinding := storagev1.VolumeBindingWaitForFirstConsumer
|
||||
|
||||
return testsuites.GetStorageClass(provisioner, parameters, nil, ns, suffix)
|
||||
return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix)
|
||||
}
|
||||
|
||||
func (h *gcePdDriver) GetClaimSize() string {
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
@ -325,14 +325,19 @@ func createVolumeSourceWithPVCPVFromDynamicProvisionSC(
|
||||
pvc, err = cs.CoreV1().PersistentVolumeClaims(ns).Create(pvc)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if !isDelayedBinding(sc) {
|
||||
err = framework.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, cs, pvc.Namespace, pvc.Name, framework.Poll, framework.ClaimProvisionTimeout)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
pvc, err = cs.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(pvc.Name, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
pv, err := cs.CoreV1().PersistentVolumes().Get(pvc.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
var pv *v1.PersistentVolume
|
||||
if !isDelayedBinding(sc) {
|
||||
pv, err = cs.CoreV1().PersistentVolumes().Get(pvc.Spec.VolumeName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
volSource := &v1.VolumeSource{
|
||||
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
|
||||
@ -343,6 +348,13 @@ func createVolumeSourceWithPVCPVFromDynamicProvisionSC(
|
||||
return volSource, pv, pvc
|
||||
}
|
||||
|
||||
func isDelayedBinding(sc *storagev1.StorageClass) bool {
|
||||
if sc.VolumeBindingMode != nil {
|
||||
return *sc.VolumeBindingMode == storagev1.VolumeBindingWaitForFirstConsumer
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getClaim(claimSize string, ns string) *v1.PersistentVolumeClaim {
|
||||
claim := v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
Loading…
Reference in New Issue
Block a user