@@ -276,4 +276,61 @@ var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-block-vanil
276
276
gomega .Equal (vanillaClusterDistributionWithSpecialChar ),
277
277
"Wrong/empty cluster-distribution name present on CNS" )
278
278
})
279
+
280
+ // Test to verify PVC goes to Pending when cluster-distribution name has more than 128 characters
281
+ // Steps
282
+ // 1. Update cluster-distribution value to more than 128 characters
283
+ // 2. Create a PVC.
284
+ // 3. Expect PVC to go to Pending state.
285
+
286
+ ginkgo .It ("Verify PVC goes to Pending when cluster distribution name has more than 128 characters" , ginkgo .Label (p0 ,
287
+ block , file , vanilla , vc70 ), func () {
288
+ ctx , cancel := context .WithCancel (context .Background ())
289
+ defer cancel ()
290
+
291
+ var pvclaim * v1.PersistentVolumeClaim
292
+ var storageclasspvc * storagev1.StorageClass
293
+ var err error
294
+
295
+ ginkgo .By ("Setting the cluster-distribution name having more than 128 characters" )
296
+ clsDistributionName , err := genrateRandomString (130 )
297
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
298
+ setClusterDistribution (ctx , client , clsDistributionName )
299
+ ginkgo .By ("Restart CSI driver" )
300
+ collectPodLogs (ctx , client , csiSystemNamespace )
301
+ restartSuccess , err := restartCSIDriver (ctx , client , csiNamespace , csiReplicas )
302
+ gomega .Expect (restartSuccess ).To (gomega .BeTrue (), "csi driver restart not successful" )
303
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
304
+
305
+ defer func () {
306
+ // Reset the cluster distribution value to default value "CSI-Vanilla".
307
+ setClusterDistribution (ctx , client , vanillaClusterDistribution )
308
+ }()
309
+
310
+ ginkgo .By ("Creating a PVC" )
311
+ scParameters [scParamDatastoreURL ] = datastoreURL
312
+ storageclasspvc , pvclaim , err = createPVCAndStorageClass (ctx , client ,
313
+ namespace , nil , scParameters , diskSize , nil , "" , false , "" )
314
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
315
+
316
+ defer func () {
317
+ err = fpv .DeletePersistentVolumeClaim (ctx , client , pvclaim .Name , pvclaim .Namespace )
318
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
319
+
320
+ err := client .StorageV1 ().StorageClasses ().Delete (ctx ,
321
+ storageclasspvc .Name , * metav1 .NewDeleteOptions (0 ))
322
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
323
+ }()
324
+
325
+ ginkgo .By ("Expect claim to fail" )
326
+ err = fpv .WaitForPersistentVolumeClaimPhase (ctx ,
327
+ v1 .ClaimPending , client , pvclaim .Namespace , pvclaim .Name , framework .Poll , time .Second * 130 )
328
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
329
+
330
+ expectedErrMsg := "A specified parameter was not correct: createSpecs.metadata.containerCluster.clusterDistribution"
331
+ framework .Logf ("Expected failure message: %+q" , expectedErrMsg )
332
+ errorOccurred := checkEventsforError (client , pvclaim .Namespace ,
333
+ metav1.ListOptions {FieldSelector : fmt .Sprintf ("involvedObject.name=%s" , pvclaim .Name )}, expectedErrMsg )
334
+ gomega .Expect (errorOccurred ).To (gomega .BeTrue ())
335
+ })
279
336
})
0 commit comments