@@ -346,13 +346,34 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
346
346
})
347
347
348
348
Describe ("NodePublishVolume" , func () {
349
+ var req * csi.NodePublishVolumeRequest
350
+
351
+ BeforeEach (func () {
352
+ stagingTargetPath := ""
353
+ if nodeStageSupported {
354
+ stagingTargetPath = sc .StagingPath
355
+ }
356
+
357
+ req = & csi.NodePublishVolumeRequest {
358
+ VolumeId : sc .Config .IDGen .GenerateUniqueValidVolumeID (),
359
+ StagingTargetPath : stagingTargetPath ,
360
+ TargetPath : sc .TargetPath + "/target" ,
361
+ VolumeCapability : TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
362
+ Readonly : false ,
363
+ Secrets : sc .Secrets .NodePublishVolumeSecret ,
364
+ }
365
+ })
366
+
367
+ JustAfterEach (func () {
368
+ if CurrentGinkgoTestDescription ().Failed {
369
+ fmt .Fprintf (GinkgoWriter , "Request was %v\n " , req )
370
+ }
371
+ })
372
+
349
373
It ("should fail when no volume id is provided" , func () {
350
- _ , err := c .NodePublishVolume (
351
- context .Background (),
352
- & csi.NodePublishVolumeRequest {
353
- Secrets : sc .Secrets .NodePublishVolumeSecret ,
354
- },
355
- )
374
+ req .VolumeId = ""
375
+
376
+ _ , err := c .NodePublishVolume (context .Background (), req )
356
377
Expect (err ).To (HaveOccurred ())
357
378
358
379
serverError , ok := status .FromError (err )
@@ -361,13 +382,9 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
361
382
})
362
383
363
384
It ("should fail when no target path is provided" , func () {
364
- _ , err := c .NodePublishVolume (
365
- context .Background (),
366
- & csi.NodePublishVolumeRequest {
367
- VolumeId : sc .Config .IDGen .GenerateUniqueValidVolumeID (),
368
- Secrets : sc .Secrets .NodePublishVolumeSecret ,
369
- },
370
- )
385
+ req .TargetPath = ""
386
+
387
+ _ , err := c .NodePublishVolume (context .Background (), req )
371
388
Expect (err ).To (HaveOccurred ())
372
389
373
390
serverError , ok := status .FromError (err )
@@ -376,15 +393,9 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
376
393
})
377
394
378
395
It ("should fail when no volume capability is provided" , func () {
379
- _ , err := c .NodePublishVolume (
380
- context .Background (),
381
- & csi.NodePublishVolumeRequest {
382
- VolumeId : sc .Config .IDGen .GenerateUniqueValidVolumeID (),
383
- VolumeCapability : nil ,
384
- TargetPath : sc .TargetPath + "/target" ,
385
- Secrets : sc .Secrets .NodePublishVolumeSecret ,
386
- },
387
- )
396
+ req .VolumeCapability = nil
397
+
398
+ _ , err := c .NodePublishVolume (context .Background (), req )
388
399
Expect (err ).To (HaveOccurred ())
389
400
390
401
serverError , ok := status .FromError (err )
@@ -393,20 +404,9 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
393
404
})
394
405
395
406
It ("should fail when the volume is missing" , func () {
396
- stagingPath := ""
397
- if nodeStageSupported {
398
- stagingPath = sc .StagingPath
399
- }
407
+ req .VolumeId = sc .Config .IDGen .GenerateUniqueValidVolumeID ()
400
408
401
- _ , err := c .NodePublishVolume (
402
- context .Background (),
403
- & csi.NodePublishVolumeRequest {
404
- VolumeId : sc .Config .IDGen .GenerateUniqueValidVolumeID (),
405
- VolumeCapability : TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
406
- StagingTargetPath : stagingPath ,
407
- TargetPath : sc .TargetPath + "/target" ,
408
- Secrets : sc .Secrets .NodePublishVolumeSecret ,
409
- })
409
+ _ , err := c .NodePublishVolume (context .Background (), req )
410
410
Expect (err ).To (HaveOccurred ())
411
411
412
412
serverError , ok := status .FromError (err )
0 commit comments