diff --git a/test/e2e/storage/testsuites/provisioning.go b/test/e2e/storage/testsuites/provisioning.go index 481dce871f5..3867cd73af1 100644 --- a/test/e2e/storage/testsuites/provisioning.go +++ b/test/e2e/storage/testsuites/provisioning.go @@ -213,14 +213,23 @@ func (p *provisioningTestSuite) DefineTests(driver TestDriver, pattern testpatte dc := l.config.Framework.DynamicClient vsc := sDriver.GetSnapshotClass(l.config) - dataSource, cleanupFunc := prepareSnapshotDataSourceForProvisioning(l.config.ClientNodeSelection, l.cs, dc, l.pvc, l.sc, vsc) + testConfig := convertTestConfig(l.config) + expectedContent := fmt.Sprintf("Hello from namespace %s", f.Namespace.Name) + dataSource, cleanupFunc := prepareSnapshotDataSourceForProvisioning(f, testConfig, l.cs, dc, l.pvc, l.sc, vsc, pattern.VolMode, expectedContent) defer cleanupFunc() l.pvc.Spec.DataSource = dataSource l.testCase.PvCheck = func(claim *v1.PersistentVolumeClaim) { ginkgo.By("checking whether the created volume has the pre-populated data") - command := fmt.Sprintf("grep '%s' /mnt/test/initialData", claim.Namespace) - RunInPodWithVolume(l.cs, claim.Namespace, claim.Name, "pvc-snapshot-tester", command, l.config.ClientNodeSelection) + tests := []volume.Test{ + { + Volume: *createVolumeSource(claim.Name, false /* readOnly */), + Mode: pattern.VolMode, + File: "index.html", + ExpectedContent: expectedContent, + }, + } + volume.TestVolumeClient(f, testConfig, nil, "", tests) } l.testCase.TestDynamicProvisioning() }) @@ -698,12 +707,15 @@ func verifyPVCsPending(client clientset.Interface, pvcs []*v1.PersistentVolumeCl } func prepareSnapshotDataSourceForProvisioning( - node e2epod.NodeSelection, + f *framework.Framework, + config volume.TestConfig, client clientset.Interface, dynamicClient dynamic.Interface, initClaim *v1.PersistentVolumeClaim, class *storagev1.StorageClass, snapshotClass *unstructured.Unstructured, + mode v1.PersistentVolumeMode, + injectContent string, ) (*v1.TypedLocalObjectReference, func()) { var err error if class != nil { @@ -717,20 +729,19 @@ func prepareSnapshotDataSourceForProvisioning( framework.ExpectNoError(err) // write namespace to the /mnt/test (= the volume). - ginkgo.By("[Initialize dataSource]write data to volume") - command := fmt.Sprintf("echo '%s' > /mnt/test/initialData", updatedClaim.GetNamespace()) - RunInPodWithVolume(client, updatedClaim.Namespace, updatedClaim.Name, "pvc-snapshot-writer", command, node) - - err = e2epv.WaitForPersistentVolumeClaimPhase(v1.ClaimBound, client, updatedClaim.Namespace, updatedClaim.Name, framework.Poll, framework.ClaimProvisionTimeout) - framework.ExpectNoError(err) - - ginkgo.By("[Initialize dataSource]checking the initClaim") - // Get new copy of the initClaim - _, err = client.CoreV1().PersistentVolumeClaims(updatedClaim.Namespace).Get(context.TODO(), updatedClaim.Name, metav1.GetOptions{}) - framework.ExpectNoError(err) + tests := []volume.Test{ + { + Volume: *createVolumeSource(updatedClaim.Name, false /* readOnly */), + Mode: mode, + File: "index.html", + ExpectedContent: injectContent, + }, + } + volume.InjectContent(f, config, nil, "", tests) ginkgo.By("[Initialize dataSource]creating a SnapshotClass") snapshotClass, err = dynamicClient.Resource(snapshotClassGVR).Create(snapshotClass, metav1.CreateOptions{}) + framework.ExpectNoError(err) ginkgo.By("[Initialize dataSource]creating a snapshot") snapshot := getSnapshot(updatedClaim.Name, updatedClaim.Namespace, snapshotClass.GetName())