@@ -292,6 +292,41 @@ var _ = Describe("GCE PD CSI Driver", func() {
292
292
}()
293
293
})
294
294
295
+ It ("Should create and delete disk with labels" , func () {
296
+ Expect (testContexts ).ToNot (BeEmpty ())
297
+ testContext := getRandomTestContext ()
298
+
299
+ p , z , _ := testContext .Instance .GetIdentity ()
300
+ client := testContext .Client
301
+
302
+ // Create Disk
303
+ volName := testNamePrefix + string (uuid .NewUUID ())
304
+ params := map [string ]string {
305
+ common .ParameterKeyLabels : "key1=value1,key2=value2" ,
306
+ }
307
+ volID , err := client .CreateVolume (volName , params , defaultSizeGb , nil )
308
+ Expect (err ).To (BeNil (), "CreateVolume failed with error: %v" , err )
309
+
310
+ // Validate Disk Created
311
+ cloudDisk , err := computeService .Disks .Get (p , z , volName ).Do ()
312
+ Expect (err ).To (BeNil (), "Could not get disk from cloud directly" )
313
+ Expect (cloudDisk .Type ).To (ContainSubstring (standardDiskType ))
314
+ Expect (cloudDisk .Status ).To (Equal (readyState ))
315
+ Expect (cloudDisk .SizeGb ).To (Equal (defaultSizeGb ))
316
+ Expect (cloudDisk .Labels ).To (Equal (params [common .ParameterKeyLabels ]))
317
+ Expect (cloudDisk .Name ).To (Equal (volName ))
318
+
319
+ defer func () {
320
+ // Delete Disk
321
+ client .DeleteVolume (volID )
322
+ Expect (err ).To (BeNil (), "DeleteVolume failed" )
323
+
324
+ // Validate Disk Deleted
325
+ _ , err = computeService .Disks .Get (p , z , volName ).Do ()
326
+ Expect (gce .IsGCEError (err , "notFound" )).To (BeTrue (), "Expected disk to not be found" )
327
+ }()
328
+ })
329
+
295
330
// Test volume already exists idempotency
296
331
297
332
// Test volume with op pending
0 commit comments