Skip to content

Commit bcff8bf

Browse files
authored
Merge pull request kubernetes#86283 from haosdent/clean-e2e-framework-pv
e2e: move funs of framework/pv to e2e/storage
2 parents 305377a + dbc9929 commit bcff8bf

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

test/e2e/framework/pv/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ go_library(
1616
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
1717
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
1818
"//test/e2e/framework:go_default_library",
19-
"//test/e2e/framework/pod:go_default_library",
2019
"//vendor/github.com/onsi/ginkgo:go_default_library",
2120
],
2221
)

test/e2e/framework/pv/pv.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
storageutil "k8s.io/kubernetes/pkg/apis/storage/v1/util"
3232
"k8s.io/kubernetes/pkg/volume/util"
3333
"k8s.io/kubernetes/test/e2e/framework"
34-
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
3534
)
3635

3736
const (
@@ -678,12 +677,6 @@ func deletePD(pdName string) error {
678677
return framework.TestContext.CloudConfig.Provider.DeletePD(pdName)
679678
}
680679

681-
// MakeWritePod returns a pod definition based on the namespace. The pod references the PVC's
682-
// name.
683-
func MakeWritePod(ns string, pvc *v1.PersistentVolumeClaim) *v1.Pod {
684-
return e2epod.MakePod(ns, nil, []*v1.PersistentVolumeClaim{pvc}, true, "touch /mnt/volume1/SUCCESS && (id -G | grep -E '\\b777\\b')")
685-
}
686-
687680
// WaitForPVClaimBoundPhase waits until all pvcs phase set to bound
688681
func WaitForPVClaimBoundPhase(client clientset.Interface, pvclaims []*v1.PersistentVolumeClaim, timeout time.Duration) ([]*v1.PersistentVolume, error) {
689682
persistentvolumes := make([]*v1.PersistentVolume, len(pvclaims))
@@ -776,19 +769,6 @@ func DeletePVSource(pvSource *v1.PersistentVolumeSource) error {
776769
return framework.TestContext.CloudConfig.Provider.DeletePVSource(pvSource)
777770
}
778771

779-
// GetBoundPV returns a PV details.
780-
func GetBoundPV(client clientset.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolume, error) {
781-
// Get new copy of the claim
782-
claim, err := client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(pvc.Name, metav1.GetOptions{})
783-
if err != nil {
784-
return nil, err
785-
}
786-
787-
// Get the bound PV
788-
pv, err := client.CoreV1().PersistentVolumes().Get(claim.Spec.VolumeName, metav1.GetOptions{})
789-
return pv, err
790-
}
791-
792772
// GetDefaultStorageClassName returns default storageClass or return error
793773
func GetDefaultStorageClassName(c clientset.Interface) (string, error) {
794774
list, err := c.StorageV1().StorageClasses().List(metav1.ListOptions{})

test/e2e/storage/persistent_volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ var _ = utils.SIGDescribe("PersistentVolumes", func() {
280280
// (and test) succeed.
281281
ginkgo.It("should test that a PV becomes Available and is clean after the PVC is deleted.", func() {
282282
ginkgo.By("Writing to the volume.")
283-
pod := e2epv.MakeWritePod(ns, pvc)
283+
pod := e2epod.MakePod(ns, nil, []*v1.PersistentVolumeClaim{pvc}, true, "touch /mnt/volume1/SUCCESS && (id -G | grep -E '\\b777\\b')")
284284
pod, err = c.CoreV1().Pods(ns).Create(pod)
285285
framework.ExpectNoError(err)
286286
framework.ExpectNoError(e2epod.WaitForPodSuccessInNamespace(c, pod.Name, ns))

test/e2e/storage/testsuites/provisioning.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,26 @@ func (t StorageClassTest) TestDynamicProvisioning() *v1.PersistentVolume {
293293
return pv
294294
}
295295

296+
// getBoundPV returns a PV details.
297+
func getBoundPV(client clientset.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolume, error) {
298+
// Get new copy of the claim
299+
claim, err := client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(pvc.Name, metav1.GetOptions{})
300+
if err != nil {
301+
return nil, err
302+
}
303+
304+
// Get the bound PV
305+
pv, err := client.CoreV1().PersistentVolumes().Get(claim.Spec.VolumeName, metav1.GetOptions{})
306+
return pv, err
307+
}
308+
296309
// checkProvisioning verifies that the claim is bound and has the correct properities
297310
func (t StorageClassTest) checkProvisioning(client clientset.Interface, claim *v1.PersistentVolumeClaim, class *storagev1.StorageClass) *v1.PersistentVolume {
298311
err := e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, client, claim.Namespace, claim.Name, framework.Poll, framework.ClaimProvisionTimeout)
299312
framework.ExpectNoError(err)
300313

301314
ginkgo.By("checking the claim")
302-
pv, err := e2epv.GetBoundPV(client, claim)
315+
pv, err := getBoundPV(client, claim)
303316
framework.ExpectNoError(err)
304317

305318
// Check sizes
@@ -372,7 +385,7 @@ func PVWriteReadSingleNodeCheck(client clientset.Interface, claim *v1.Persistent
372385
pod = nil // Don't stop twice.
373386

374387
// Get a new copy of the PV
375-
volume, err := e2epv.GetBoundPV(client, claim)
388+
volume, err := getBoundPV(client, claim)
376389
framework.ExpectNoError(err)
377390

378391
ginkgo.By(fmt.Sprintf("checking the created volume has the correct mount options, is readable and retains data on the same node %q", actualNodeName))

0 commit comments

Comments
 (0)