@@ -278,9 +278,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
278278 var (
279279 k8sClient client.Client
280280 activeNamespaces map [string ]struct {}
281- catalogName string
282- packageName string
283- crdSuffix string
281+ singleownImage string
284282 )
285283
286284 BeforeEach (func (ctx SpecContext ) {
@@ -292,29 +290,8 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
292290 helpers .RequireImageRegistry (ctx )
293291 k8sClient = env .Get ().K8sClient
294292 activeNamespaces = map [string ]struct {}{}
295-
296- // Generate unique CRD suffix for parallel execution
297- crdSuffix = rand .String (4 )
298-
299- // Build in-cluster bundle and catalog
300- singleownImage := image .LocationFor ("quay.io/olmtest/webhook-operator:v0.0.5" )
301- packageName = fmt .Sprintf ("singleown-operator-both-%s" , crdSuffix )
302- By (fmt .Sprintf ("using singleown operator image: %s, CRD suffix: %s, package: %s" , singleownImage , crdSuffix , packageName ))
303-
304- replacements := map [string ]string {
305- "{{ TEST-BUNDLE }}" : "" ,
306- "{{ NAMESPACE }}" : "" ,
307- "{{ TEST-CONTROLLER }}" : singleownImage ,
308- "{{ CRD-SUFFIX }}" : crdSuffix ,
309- "{{ PACKAGE-NAME }}" : packageName ,
310- }
311-
312- var nsName , opName string
313- _ , nsName , catalogName , opName = helpers .NewCatalogAndClusterBundles (ctx , replacements ,
314- singleownindex .AssetNames , singleownindex .Asset ,
315- singleownbundle .AssetNames , singleownbundle .Asset ,
316- )
317- By (fmt .Sprintf ("singleown bundle %q and catalog %q built successfully in namespace %q" , opName , catalogName , nsName ))
293+ singleownImage = image .LocationFor ("quay.io/olmtest/webhook-operator:v0.0.5" )
294+ By (fmt .Sprintf ("using singleown operator image: %s" , singleownImage ))
318295 })
319296
320297 AfterEach (func (ctx SpecContext ) {
@@ -360,6 +337,28 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
360337 activeNamespaces [watchNamespace ] = struct {}{}
361338 }
362339
340+ // Build the in-cluster bundle and catalog with unique names for each scenario.
341+ // This avoids conflicts between tests, since we don’t wait for a full cleanup
342+ // before starting the next one. Sometimes, deleting resources and namespaces
343+ // can take longer than expected.
344+ crdSuffix := rand .String (4 )
345+ packageName := fmt .Sprintf ("singleown-operator-both-%s" , crdSuffix )
346+ By (fmt .Sprintf ("building singleown operator assets for %s scenario: image=%s, CRD suffix=%s, package=%s" , sc .label , singleownImage , crdSuffix , packageName ))
347+
348+ replacements := map [string ]string {
349+ "{{ TEST-BUNDLE }}" : "" ,
350+ "{{ NAMESPACE }}" : "" ,
351+ "{{ TEST-CONTROLLER }}" : singleownImage ,
352+ "{{ CRD-SUFFIX }}" : crdSuffix , // Unique CRD suffix per scenario
353+ "{{ PACKAGE-NAME }}" : packageName ,
354+ }
355+
356+ _ , nsName , catalogName , opName := helpers .NewCatalogAndClusterBundles (ctx , replacements ,
357+ singleownindex .AssetNames , singleownindex .Asset ,
358+ singleownbundle .AssetNames , singleownbundle .Asset ,
359+ )
360+ By (fmt .Sprintf ("singleown bundle %q and catalog %q built successfully in namespace %q for %s scenario" , opName , catalogName , nsName , sc .label ))
361+
363362 By (fmt .Sprintf ("ensuring no ClusterExtension for %s before %s scenario" , packageName , sc .label ))
364363 crdName := fmt .Sprintf ("webhooktests-%s.webhook.operators.coreos.io" , crdSuffix )
365364 helpers .EnsureCleanupClusterExtension (context .Background (), packageName , crdName )
@@ -433,6 +432,13 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
433432 DeferCleanup (func () {
434433 By (fmt .Sprintf ("cleanup: deleting ClusterExtension %s" , ce .Name ))
435434 _ = k8sClient .Delete (context .Background (), ce , client .PropagationPolicy (metav1 .DeletePropagationForeground ))
435+ if crdName != "" {
436+ crd := & apiextensionsv1.CustomResourceDefinition {}
437+ if err := k8sClient .Get (context .Background (), client.ObjectKey {Name : crdName }, crd ); err == nil {
438+ By (fmt .Sprintf ("cleanup: deleting CRD %s" , crdName ))
439+ _ = k8sClient .Delete (context .Background (), crd )
440+ }
441+ }
436442 })
437443
438444 By (fmt .Sprintf ("waiting for the ClusterExtension %s to be installed for %s scenario" , ceName , sc .label ))
@@ -459,19 +465,6 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
459465 }
460466 g .Expect (found ).To (BeTrue (), "failed to find deployment with olm.targetNamespaces annotation" )
461467 }).WithTimeout (5 * time .Minute ).WithPolling (3 * time .Second ).Should (Succeed ())
462-
463- By (fmt .Sprintf ("cleaning up resources created for %s scenario to allow next scenario" , sc .label ))
464- deletePolicy := metav1 .DeletePropagationForeground
465- Expect (k8sClient .Delete (ctx , ce , client .PropagationPolicy (deletePolicy ))).To (Succeed (), "failed to delete ClusterExtension %q" , ceName )
466- helpers .EnsureCleanupClusterExtension (context .Background (), packageName , crdName )
467-
468- Expect (k8sClient .Delete (ctx , crb , client .PropagationPolicy (deletePolicy ))).To (Succeed (), "failed to delete ClusterRoleBinding %q" , crbName )
469- Expect (k8sClient .Delete (ctx , sa , client .PropagationPolicy (deletePolicy ))).To (Succeed (), "failed to delete ServiceAccount %q" , saName )
470-
471- if watchNSObj != nil {
472- Expect (k8sClient .Delete (ctx , watchNSObj , client .PropagationPolicy (deletePolicy ))).To (Succeed (), "failed to delete watch namespace %q" , watchNamespace )
473- }
474- Expect (k8sClient .Delete (ctx , installNS , client .PropagationPolicy (deletePolicy ))).To (Succeed (), "failed to delete install namespace %q" , installNamespace )
475468 }
476469 })
477470})
0 commit comments