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

Enable volume expansion tests for generic ephemeral volumes #110180

Merged
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
14 changes: 8 additions & 6 deletions test/e2e/storage/framework/testpattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ var (
}
// DefaultFsGenericEphemeralVolume is TestPattern for "Generic Ephemeral-volume (default fs)"
DefaultFsGenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (default fs)",
VolType: GenericEphemeralVolume,
Name: "Generic Ephemeral-volume (default fs)",
VolType: GenericEphemeralVolume,
AllowExpansion: true,
}
// DefaultFsPreprovisionedPV is TestPattern for "Pre-provisioned PV (default fs)"
DefaultFsPreprovisionedPV = TestPattern{
Expand Down Expand Up @@ -299,10 +300,11 @@ var (
}
// BlockVolModeGenericEphemeralVolume is for generic ephemeral inline volumes in raw block mode.
BlockVolModeGenericEphemeralVolume = TestPattern{
Name: "Generic Ephemeral-volume (block volmode) (late-binding)",
VolType: GenericEphemeralVolume,
VolMode: v1.PersistentVolumeBlock,
BindingMode: storagev1.VolumeBindingWaitForFirstConsumer,
Name: "Generic Ephemeral-volume (block volmode) (late-binding)",
VolType: GenericEphemeralVolume,
VolMode: v1.PersistentVolumeBlock,
BindingMode: storagev1.VolumeBindingWaitForFirstConsumer,
AllowExpansion: true,
}

// Definitions for snapshot case
Expand Down
61 changes: 61 additions & 0 deletions test/e2e/storage/testsuites/ephemeral.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,67 @@ func (p *ephemeralTestSuite) DefineTests(driver storageframework.TestDriver, pat
l.testCase.TestEphemeral()
})

ginkgo.It("should support expansion of pvcs created for ephemeral pvcs", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Online expansion? (line 224 skips if driver doesn't support online expansion)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be redundant because ephemeral volumes are typically always online.

if pattern.VolType != storageframework.GenericEphemeralVolume {
e2eskipper.Skipf("Skipping %s test for expansion", pattern.VolType)
}

init()
defer cleanup()

if !driver.GetDriverInfo().Capabilities[storageframework.CapOnlineExpansion] {
e2eskipper.Skipf("Driver %q does not support online volume expansion - skipping", driver.GetDriverInfo().Name)
}

l.testCase.ReadOnly = false
l.testCase.RunningPodCheck = func(pod *v1.Pod) interface{} {
podName := pod.Name
framework.Logf("Running volume expansion checks %s", podName)

outerPodVolumeSpecName := ""
for i := range pod.Spec.Volumes {
volume := pod.Spec.Volumes[i]
if volume.Ephemeral != nil {
outerPodVolumeSpecName = volume.Name
break
}
}
pvcName := fmt.Sprintf("%s-%s", podName, outerPodVolumeSpecName)
pvc, err := f.ClientSet.CoreV1().PersistentVolumeClaims(pod.Namespace).Get(context.TODO(), pvcName, metav1.GetOptions{})
framework.ExpectNoError(err, "error getting ephemeral pvc")

ginkgo.By("Expanding current pvc")
currentPvcSize := pvc.Spec.Resources.Requests[v1.ResourceStorage]
newSize := currentPvcSize.DeepCopy()
newSize.Add(resource.MustParse("1Gi"))
framework.Logf("currentPvcSize %s, requested new size %s", currentPvcSize.String(), newSize.String())

newPVC, err := ExpandPVCSize(pvc, newSize, f.ClientSet)
framework.ExpectNoError(err, "While updating pvc for more size")
pvc = newPVC
gomega.Expect(pvc).NotTo(gomega.BeNil())

pvcSize := pvc.Spec.Resources.Requests[v1.ResourceStorage]
if pvcSize.Cmp(newSize) != 0 {
framework.Failf("error updating pvc %s from %s to %s size", pvc.Name, currentPvcSize.String(), newSize.String())
}

ginkgo.By("Waiting for cloudprovider resize to finish")
err = WaitForControllerVolumeResize(pvc, f.ClientSet, totalResizeWaitPeriod)
framework.ExpectNoError(err, "While waiting for pvc resize to finish")

ginkgo.By("Waiting for file system resize to finish")
pvc, err = WaitForFSResize(pvc, f.ClientSet)
framework.ExpectNoError(err, "while waiting for fs resize to finish")

pvcConditions := pvc.Status.Conditions
framework.ExpectEqual(len(pvcConditions), 0, "pvc should not have conditions")
return nil
}
l.testCase.TestEphemeral()

})

ginkgo.It("should support two pods which have the same volume definition", func() {
init()
defer cleanup()
Expand Down