Skip to content

Conversation

@perdasilva
Copy link
Contributor

Description

The webhook e2e tests were failing downstream. It seems that waiting for the deployment to be available is not sufficient signal to be sure that the webhook service is working. In this PR, we wrap the creation and testing of the webhook operator test CR with an Eventually to be more tolerant to transient errors of the sort:

failed calling webhook \"mwebhooktest.kb.io\": failed to call webhook: Post \"[https://webhook-operator-webhook-service.webhook-operator.svc:443/mutate-webhook-operators-coreos-io-v1-webhooktest?timeout=10s](https://webhook-operator-webhook-service.webhook-operator.svc/mutate-webhook-operators-coreos-io-v1-webhooktest?timeout=10s)\": dial tcp 10.129.2.15:4343: connect: connection refused

Testing against clusterbot 4.20 techpreview:

$ make experimental-e2e
go test -count=1 -v ./test/experimental-e2e/...
=== RUN   TestNoop
    experimental_e2e_test.go:59: Running experimental-e2e tests
--- PASS: TestNoop (0.00s)
=== RUN   TestWebhookSupport
    experimental_e2e_test.go:64: Test support for bundles with webhooks
    experimental_e2e_test.go:67: By creating install namespace, and necessary rbac resources
    experimental_e2e_test.go:112: By creating the webhook-operator ClusterCatalog
    experimental_e2e_test.go:133: By waiting for the catalog to serve its metadata
    experimental_e2e_test.go:143: By installing the webhook-operator ClusterExtension
    experimental_e2e_test.go:169: By waiting for webhook-operator extension to be installed successfully
    experimental_e2e_test.go:183: By waiting for webhook-operator deployment to be available
    experimental_e2e_test.go:203: By checking an invalid CR is rejected by the validating webhook
    experimental_e2e_test.go:211: By checking a valid CR is mutated by the mutating webhook
    experimental_e2e_test.go:227: By checking a valid CR is converted to v2 by the conversion webhook
--- PASS: TestWebhookSupport (14.61s)
PASS
ok      github.com/operator-framework/operator-controller/test/experimental-e2e 14.623s

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@perdasilva perdasilva requested a review from a team as a code owner July 21, 2025 09:31
@netlify
Copy link

netlify bot commented Jul 21, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit f094654
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/687e451e8677b000088b5855
😎 Deploy Preview https://deploy-preview-2111--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci openshift-ci bot requested review from ankitathomas and grokspawn July 21, 2025 09:31
@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.60%. Comparing base (5786e67) to head (f094654).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2111   +/-   ##
=======================================
  Coverage   73.60%   73.60%           
=======================================
  Files          78       78           
  Lines        7260     7260           
=======================================
  Hits         5344     5344           
  Misses       1566     1566           
  Partials      350      350           
Flag Coverage Δ
e2e 43.67% <ø> (-0.05%) ⬇️
experimental-e2e 56.38% <ø> (ø)
unit 58.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@perdasilva perdasilva force-pushed the webhook-e2e-fixes branch 3 times, most recently from 5b6ca9a to c0a263e Compare July 21, 2025 09:50
@perdasilva perdasilva changed the title 🐛 Make webhook support e2es more robust 🌱 Make webhook support e2es more robust Jul 21, 2025
Comment on lines +137 to +140
if assert.NotNil(ct, cond) {
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
assert.Equal(ct, ocv1.ReasonAvailable, cond.Reason)
}
Copy link
Contributor

@camilamacedo86 camilamacedo86 Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a quick glance, the current code might misleadingly suggest that if cond never becomes non-nil within the timeout, the test would not fail — giving the impression that it could pass silently.

To make this behavior more explicit and ensure that nil conditions are clearly reported during retries, I propose changing the inner logic to:

Suggested change
if assert.NotNil(ct, cond) {
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
assert.Equal(ct, ocv1.ReasonAvailable, cond.Reason)
}
if !assert.NotNil(t, cond) {
// Keep retrying until cond is not nil
return
}
if !assert.Equal(t, metav1.ConditionTrue, cond.Status) {
// Keep retrying until condition status is true
return
}
if !assert.Equal(t, ocv1.ReasonAvailable, cond.Reason) {
// Keep retrying until reason is available
return
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IHMO ^ less flake as well I think

assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
if assert.NotNil(ct, clusterExtension.Status.Install) {
assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

require.EventuallyWithT(t, func(ct *assert.CollectT) {
res, err = v2Client.Get(t.Context(), obj.GetName(), metav1.GetOptions{})
require.NoError(ct, err)
}, pollDuration, pollInterval)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Cool add the EventuallyWithT seems a good thing

}, pollDuration, pollInterval)
t.Cleanup(func() {
require.NoError(t, dynamicClient.Resource(v1Gvr).Namespace(namespace.GetName()).Delete(context.Background(), obj.GetName(), metav1.DeleteOptions{}))
require.NoError(t, v1Client.Delete(context.Background(), obj.GetName(), metav1.DeleteOptions{}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 seems fine for me

require.EventuallyWithT(t, func(ct *assert.CollectT) {
res, err = v1Client.Create(t.Context(), obj, metav1.CreateOptions{})
require.NoError(ct, err)
}, pollDuration, pollInterval)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Cool add the EventuallyWithT seems a good thing

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍
Terrific 🥇

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 21, 2025
@perdasilva
Copy link
Contributor Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2025
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2025
@perdasilva
Copy link
Contributor Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2025
@perdasilva
Copy link
Contributor Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2025
@perdasilva
Copy link
Contributor Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2025
Signed-off-by: Per Goncalves da Silva <[email protected]>
@camilamacedo86
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2025
@tmshort
Copy link
Contributor

tmshort commented Jul 21, 2025

DON'T click the [Squash and merge] button until @grokspawn has a chance to look at tide/prow.

@openshift-ci
Copy link

openshift-ci bot commented Jul 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, grokspawn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [camilamacedo86,grokspawn]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit b5a475a into operator-framework:main Jul 21, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants