Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow upgrade test to run on all cloudproviders #82760

Merged
merged 1 commit into from Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion test/e2e/upgrades/storage/BUILD
Expand Up @@ -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",
Expand Down
36 changes: 9 additions & 27 deletions test/e2e/upgrades/storage/persistent_volumes.go
Expand Up @@ -22,17 +22,14 @@ 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"
)

// 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.
Expand All @@ -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)
Expand All @@ -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))
}
}

Expand Down