Skip to content

Commit d59e968

Browse files
committed
UPSTREAM: <carry>: make webhook case in parallel as possible
1 parent 1f66d6f commit d59e968

File tree

2 files changed

+84
-18
lines changed

2 files changed

+84
-18
lines changed

openshift/tests-extension/.openshift-tests-extension/openshift_payload_olmv1.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,10 @@
514514
"environmentSelector": {}
515515
},
516516
{
517-
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks should have a working validating webhook",
518-
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working validating webhook",
517+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks - serial tests should be tolerant to tls secret deletion [Serial]",
518+
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should be tolerant to tls secret deletion",
519519
"labels": {
520-
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working validating webhook": {}
520+
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should be tolerant to tls secret deletion": {}
521521
},
522522
"resources": {
523523
"isolation": {}
@@ -527,10 +527,10 @@
527527
"environmentSelector": {}
528528
},
529529
{
530-
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks should have a working mutating webhook [Serial]",
531-
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working mutating webhook",
530+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks - parallel tests should have a working validating webhook",
531+
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working validating webhook",
532532
"labels": {
533-
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working mutating webhook": {}
533+
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working validating webhook": {}
534534
},
535535
"resources": {
536536
"isolation": {}
@@ -540,10 +540,10 @@
540540
"environmentSelector": {}
541541
},
542542
{
543-
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks should have a working conversion webhook [Serial]",
544-
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working conversion webhook",
543+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks - parallel tests should have a working mutating webhook",
544+
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working mutating webhook",
545545
"labels": {
546-
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working conversion webhook": {}
546+
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working mutating webhook": {}
547547
},
548548
"resources": {
549549
"isolation": {}
@@ -553,10 +553,10 @@
553553
"environmentSelector": {}
554554
},
555555
{
556-
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks should be tolerant to tls secret deletion [Serial]",
557-
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should be tolerant to tls secret deletion",
556+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks - parallel tests should have a working conversion webhook",
557+
"originalName": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working conversion webhook",
558558
"labels": {
559-
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should be tolerant to tls secret deletion": {}
559+
"original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working conversion webhook": {}
560560
},
561561
"resources": {
562562
"isolation": {}

openshift/tests-extension/test/webhooks.go

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ const (
3939
webhookServiceCert = "webhook-operator-controller-manager-service-cert"
4040
)
4141

42-
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks",
43-
Ordered, Serial, func() {
42+
// Parallel webhook tests - can run concurrently
43+
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks - parallel tests",
44+
Ordered, func() {
4445
var (
4546
k8sClient client.Client
4647
dynamicClient dynamic.Interface
@@ -62,8 +63,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi
6263
By("requiring image-registry to be available")
6364
helpers.RequireImageRegistry(ctx)
6465

65-
By("ensuring no ClusterExtension and CRD from a previous run")
66-
helpers.EnsureCleanupClusterExtension(ctx, webhookOperatorPackageName, webhookOperatorCRDName)
66+
// Note: No cleanup here - allows parallel tests to coexist with shared CRD
6767

6868
// Build webhook operator bundle and catalog using the consolidated helper
6969
// Note: {{ TEST-BUNDLE }} and {{ NAMESPACE }} will be auto-filled
@@ -129,7 +129,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi
129129
}).WithTimeout(2 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
130130
})
131131

132-
It("should have a working mutating webhook [Serial]", Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working mutating webhook"), func(ctx SpecContext) {
132+
It("should have a working mutating webhook", Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working mutating webhook"), func(ctx SpecContext) {
133133
By("creating a valid webhook")
134134
mutatingWebhookResourceName := "mutating-webhook-test"
135135
resource := newWebhookTest(mutatingWebhookResourceName, webhookOperatorInstallNamespace, true)
@@ -151,7 +151,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi
151151
}))
152152
})
153153

154-
It("should have a working conversion webhook [Serial]", Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working conversion webhook"), func(ctx SpecContext) {
154+
It("should have a working conversion webhook", Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should have a working conversion webhook"), func(ctx SpecContext) {
155155
By("creating a conversion webhook test resource")
156156
conversionWebhookResourceName := "conversion-webhook-test"
157157
resourceV1 := newWebhookTest(conversionWebhookResourceName, webhookOperatorInstallNamespace, true)
@@ -174,6 +174,72 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi
174174
},
175175
}))
176176
})
177+
})
178+
179+
// Serial webhook test - must run after parallel tests complete
180+
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks - serial tests",
181+
Ordered, Serial, func() {
182+
var (
183+
k8sClient client.Client
184+
dynamicClient dynamic.Interface
185+
webhookOperatorInstallNamespace string
186+
catalogName string
187+
)
188+
189+
BeforeEach(func(ctx SpecContext) {
190+
By("initializing Kubernetes client")
191+
k8sClient = env.Get().K8sClient
192+
restCfg := env.Get().RestCfg
193+
var err error
194+
dynamicClient, err = dynamic.NewForConfig(restCfg)
195+
Expect(err).ToNot(HaveOccurred(), "failed to create dynamic client")
196+
197+
By("requiring OLMv1 capability on OpenShift")
198+
helpers.RequireOLMv1CapabilityOnOpenshift()
199+
200+
By("requiring image-registry to be available")
201+
helpers.RequireImageRegistry(ctx)
202+
203+
By("ensuring no ClusterExtension and CRD from previous parallel tests")
204+
helpers.EnsureCleanupClusterExtension(ctx, webhookOperatorPackageName, webhookOperatorCRDName)
205+
206+
// Build webhook operator bundle and catalog using the consolidated helper
207+
// Note: {{ TEST-BUNDLE }} and {{ NAMESPACE }} will be auto-filled
208+
209+
replacements := map[string]string{
210+
"{{ TEST-BUNDLE }}": "", // Auto-filled
211+
"{{ NAMESPACE }}": "", // Auto-filled
212+
"{{ TEST-CONTROLLER }}": image.LocationFor("quay.io/olmtest/webhook-operator:v0.0.5"),
213+
}
214+
215+
var nsName, opName string
216+
_, nsName, catalogName, opName = helpers.NewCatalogAndClusterBundles(ctx, replacements,
217+
webhookindex.AssetNames, webhookindex.Asset,
218+
webhookbundle.AssetNames, webhookbundle.Asset,
219+
)
220+
By(fmt.Sprintf("webhook bundle %q and catalog %q built successfully in namespace %q", opName, catalogName, nsName))
221+
222+
// Create ClusterExtension in a separate namespace
223+
// setupWebhookOperator now registers its own DeferCleanup handlers internally
224+
webhookOperatorInstallNamespace = fmt.Sprintf("webhook-operator-%s", rand.String(5))
225+
setupWebhookOperator(ctx, k8sClient, webhookOperatorInstallNamespace, catalogName)
226+
})
227+
228+
AfterEach(func(ctx SpecContext) {
229+
if CurrentSpecReport().Failed() {
230+
By("dumping pod logs for debugging")
231+
helpers.GetAllPodLogs(ctx, webhookOperatorInstallNamespace)
232+
helpers.DescribePods(ctx, webhookOperatorInstallNamespace)
233+
helpers.DescribeAllClusterCatalogs(ctx)
234+
helpers.DescribeAllClusterExtensions(ctx, webhookOperatorInstallNamespace)
235+
By("dumping webhook diagnostics")
236+
// Additional diagnostics specific for this test
237+
helpers.RunAndPrint(ctx, "get", "mutatingwebhookconfigurations.admissionregistration.k8s.io", "-oyaml")
238+
helpers.RunAndPrint(ctx, "get", "validatingwebhookconfigurations.admissionregistration.k8s.io", "-oyaml")
239+
}
240+
// Note: cleanup is now handled by DeferCleanup in BeforeEach, which ensures
241+
// cleanup runs even if BeforeEach or the test fails
242+
})
177243

178244
It("should be tolerant to tls secret deletion [Serial]", Label("original-name:[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA][Skipped:Disconnected][Serial] OLMv1 operator with webhooks should be tolerant to tls secret deletion"), func(ctx SpecContext) {
179245
certificateSecretName := webhookServiceCert

0 commit comments

Comments
 (0)