Copy the same storageclass instead of constructing one in external test

This commit is contained in:
Jiawei Wang 2020-12-01 16:53:13 -08:00
parent e0c587bf4f
commit 8c17534429
4 changed files with 15 additions and 5 deletions

View File

@ -299,7 +299,7 @@ func (d *driverDefinition) GetDynamicProvisionStorageClass(e2econfig *testsuites
// reconsidered if we eventually need to move in-tree storage tests out.
sc.Parameters["csi.storage.k8s.io/fstype"] = fsType
}
return testsuites.GetStorageClass(sc.Provisioner, sc.Parameters, sc.VolumeBindingMode, f.Namespace.Name, "e2e-sc")
return testsuites.CopyStorageClass(sc, f.Namespace.Name, "e2e-sc")
}
func loadSnapshotClass(filename string) (*unstructured.Unstructured, error) {

View File

@ -242,9 +242,7 @@ func CreateVolumeResource(driver TestDriver, config *PerTestConfig, pattern test
if pattern.BindingMode != "" {
r.Sc.VolumeBindingMode = &pattern.BindingMode
}
if pattern.AllowExpansion != false {
r.Sc.AllowVolumeExpansion = &pattern.AllowExpansion
}
r.Sc.AllowVolumeExpansion = &pattern.AllowExpansion
ginkgo.By("creating a StorageClass " + r.Sc.Name)

View File

@ -54,6 +54,16 @@ func CreateVolume(driver TestDriver, config *PerTestConfig, volType testpatterns
return nil
}
// CopyStorageClass constructs a new StorageClass instance
// with a unique name that is based on namespace + suffix
// using the same storageclass setting from the parameter
func CopyStorageClass(sc *storagev1.StorageClass, ns string, suffix string) *storagev1.StorageClass {
copy := sc.DeepCopy()
copy.ObjectMeta.Name = names.SimpleNameGenerator.GenerateName(ns + "-" + suffix)
copy.ResourceVersion = ""
return copy
}
// GetStorageClass constructs a new StorageClass instance
// with a unique name that is based on namespace + suffix.
func GetStorageClass(

View File

@ -156,7 +156,9 @@ func (v *volumeExpandTestSuite) DefineTests(driver TestDriver, pattern testpatte
defer cleanup()
var err error
gomega.Expect(l.resource.Sc.AllowVolumeExpansion).To(gomega.BeNil())
gomega.Expect(l.resource.Sc.AllowVolumeExpansion).NotTo(gomega.BeNil())
allowVolumeExpansion := *l.resource.Sc.AllowVolumeExpansion
gomega.Expect(allowVolumeExpansion).To(gomega.BeFalse())
ginkgo.By("Expanding non-expandable pvc")
currentPvcSize := l.resource.Pvc.Spec.Resources.Requests[v1.ResourceStorage]
newSize := currentPvcSize.DeepCopy()