@@ -213,14 +213,23 @@ func (p *provisioningTestSuite) DefineTests(driver TestDriver, pattern testpatte
213
213
214
214
dc := l .config .Framework .DynamicClient
215
215
vsc := sDriver .GetSnapshotClass (l .config )
216
- dataSource , cleanupFunc := prepareSnapshotDataSourceForProvisioning (l .config .ClientNodeSelection , l .cs , dc , l .pvc , l .sc , vsc )
216
+ testConfig := convertTestConfig (l .config )
217
+ expectedContent := fmt .Sprintf ("Hello from namespace %s" , f .Namespace .Name )
218
+ dataSource , cleanupFunc := prepareSnapshotDataSourceForProvisioning (f , testConfig , l .cs , dc , l .pvc , l .sc , vsc , pattern .VolMode , expectedContent )
217
219
defer cleanupFunc ()
218
220
219
221
l .pvc .Spec .DataSource = dataSource
220
222
l .testCase .PvCheck = func (claim * v1.PersistentVolumeClaim ) {
221
223
ginkgo .By ("checking whether the created volume has the pre-populated data" )
222
- command := fmt .Sprintf ("grep '%s' /mnt/test/initialData" , claim .Namespace )
223
- RunInPodWithVolume (l .cs , claim .Namespace , claim .Name , "pvc-snapshot-tester" , command , l .config .ClientNodeSelection )
224
+ tests := []volume.Test {
225
+ {
226
+ Volume : * createVolumeSource (claim .Name , false /* readOnly */ ),
227
+ Mode : pattern .VolMode ,
228
+ File : "index.html" ,
229
+ ExpectedContent : expectedContent ,
230
+ },
231
+ }
232
+ volume .TestVolumeClient (f , testConfig , nil , "" , tests )
224
233
}
225
234
l .testCase .TestDynamicProvisioning ()
226
235
})
@@ -698,12 +707,15 @@ func verifyPVCsPending(client clientset.Interface, pvcs []*v1.PersistentVolumeCl
698
707
}
699
708
700
709
func prepareSnapshotDataSourceForProvisioning (
701
- node e2epod.NodeSelection ,
710
+ f * framework.Framework ,
711
+ config volume.TestConfig ,
702
712
client clientset.Interface ,
703
713
dynamicClient dynamic.Interface ,
704
714
initClaim * v1.PersistentVolumeClaim ,
705
715
class * storagev1.StorageClass ,
706
716
snapshotClass * unstructured.Unstructured ,
717
+ mode v1.PersistentVolumeMode ,
718
+ injectContent string ,
707
719
) (* v1.TypedLocalObjectReference , func ()) {
708
720
var err error
709
721
if class != nil {
@@ -717,20 +729,19 @@ func prepareSnapshotDataSourceForProvisioning(
717
729
framework .ExpectNoError (err )
718
730
719
731
// write namespace to the /mnt/test (= the volume).
720
- ginkgo .By ("[Initialize dataSource]write data to volume" )
721
- command := fmt .Sprintf ("echo '%s' > /mnt/test/initialData" , updatedClaim .GetNamespace ())
722
- RunInPodWithVolume (client , updatedClaim .Namespace , updatedClaim .Name , "pvc-snapshot-writer" , command , node )
723
-
724
- err = e2epv .WaitForPersistentVolumeClaimPhase (v1 .ClaimBound , client , updatedClaim .Namespace , updatedClaim .Name , framework .Poll , framework .ClaimProvisionTimeout )
725
- framework .ExpectNoError (err )
726
-
727
- ginkgo .By ("[Initialize dataSource]checking the initClaim" )
728
- // Get new copy of the initClaim
729
- _ , err = client .CoreV1 ().PersistentVolumeClaims (updatedClaim .Namespace ).Get (context .TODO (), updatedClaim .Name , metav1.GetOptions {})
730
- framework .ExpectNoError (err )
732
+ tests := []volume.Test {
733
+ {
734
+ Volume : * createVolumeSource (updatedClaim .Name , false /* readOnly */ ),
735
+ Mode : mode ,
736
+ File : "index.html" ,
737
+ ExpectedContent : injectContent ,
738
+ },
739
+ }
740
+ volume .InjectContent (f , config , nil , "" , tests )
731
741
732
742
ginkgo .By ("[Initialize dataSource]creating a SnapshotClass" )
733
743
snapshotClass , err = dynamicClient .Resource (snapshotClassGVR ).Create (snapshotClass , metav1.CreateOptions {})
744
+ framework .ExpectNoError (err )
734
745
735
746
ginkgo .By ("[Initialize dataSource]creating a snapshot" )
736
747
snapshot := getSnapshot (updatedClaim .Name , updatedClaim .Namespace , snapshotClass .GetName ())
0 commit comments