Allow upgrade test to run on all cloudproviders

This commit is contained in:
Hemant Kumar 2019-09-16 14:27:48 -04:00
parent 2183a84feb
commit 72729fc4f2
2 changed files with 9 additions and 28 deletions

View File

@ -20,7 +20,6 @@ go_library(
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/log:go_default_library",
"//test/e2e/framework/pod:go_default_library",
"//test/e2e/framework/volume:go_default_library",
"//test/e2e/storage/utils:go_default_library",
"//test/e2e/upgrades:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",

View File

@ -22,7 +22,6 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
"k8s.io/kubernetes/test/e2e/framework/volume"
"github.com/onsi/ginkgo"
"k8s.io/kubernetes/test/e2e/upgrades"
@ -30,9 +29,7 @@ import (
// PersistentVolumeUpgradeTest test that a pv is available before and after a cluster upgrade.
type PersistentVolumeUpgradeTest struct {
pvSource *v1.PersistentVolumeSource
pv *v1.PersistentVolume
pvc *v1.PersistentVolumeClaim
pvc *v1.PersistentVolumeClaim
}
// Name returns the tracking name of the test.
@ -45,33 +42,21 @@ const (
pvReadCmd string = "cat " + pvTestFile
)
func (t *PersistentVolumeUpgradeTest) deleteGCEVolume(pvSource *v1.PersistentVolumeSource) error {
return framework.DeletePDWithRetry(pvSource.GCEPersistentDisk.PDName)
}
// Setup creates a pv and then verifies that a pod can consume it. The pod writes data to the volume.
func (t *PersistentVolumeUpgradeTest) Setup(f *framework.Framework) {
var err error
// TODO: generalize this to other providers
framework.SkipUnlessProviderIs("gce", "gke")
framework.SkipUnlessProviderIs("gce", "gke", "openstack", "aws", "vsphere", "azure")
ns := f.Namespace.Name
ginkgo.By("Initializing PV source")
t.pvSource, _ = volume.CreateGCEVolume()
pvConfig := framework.PersistentVolumeConfig{
NamePrefix: "pv-upgrade",
PVSource: *t.pvSource,
Prebind: nil,
ginkgo.By("Creating a PVC")
pvcConfig := framework.PersistentVolumeClaimConfig{
StorageClassName: nil,
}
emptyStorageClass := ""
pvcConfig := framework.PersistentVolumeClaimConfig{StorageClassName: &emptyStorageClass}
ginkgo.By("Creating the PV and PVC")
t.pv, t.pvc, err = framework.CreatePVPVC(f.ClientSet, pvConfig, pvcConfig, ns, true)
t.pvc = framework.MakePersistentVolumeClaim(pvcConfig, ns)
t.pvc, err = framework.CreatePVC(f.ClientSet, ns, t.pvc)
framework.ExpectNoError(err)
framework.ExpectNoError(framework.WaitOnPVandPVC(f.ClientSet, ns, t.pv, t.pvc))
ginkgo.By("Consuming the PV before upgrade")
t.testPod(f, pvWriteCmd+";"+pvReadCmd)
@ -87,12 +72,9 @@ func (t *PersistentVolumeUpgradeTest) Test(f *framework.Framework, done <-chan s
// Teardown cleans up any remaining resources.
func (t *PersistentVolumeUpgradeTest) Teardown(f *framework.Framework) {
errs := framework.PVPVCCleanup(f.ClientSet, f.Namespace.Name, t.pv, t.pvc)
if err := t.deleteGCEVolume(t.pvSource); err != nil {
errs = append(errs, err)
}
errs := framework.PVPVCCleanup(f.ClientSet, f.Namespace.Name, nil, t.pvc)
if len(errs) > 0 {
e2elog.Failf("Failed to delete 1 or more PVs/PVCs and/or the GCE volume. Errors: %v", utilerrors.NewAggregate(errs))
e2elog.Failf("Failed to delete 1 or more PVs/PVCs. Errors: %v", utilerrors.NewAggregate(errs))
}
}