Skip to content

chore(e2e): Use DeferCleanup for the remaining cleanup in parallel tests - #1634

Open
Gabrielandre02 wants to merge 1 commit into
redhat-developer:masterfrom
Gabrielandre02:e2e-defercleanup-parallel-remaining
Open

Gabrielandre02 wants to merge 1 commit into
redhat-developer:masterfrom
Gabrielandre02:e2e-defercleanup-parallel-remaining

Conversation

@Gabrielandre02

Copy link
Copy Markdown
Contributor

What does this PR do?

Refs #1464

This covers the parallel specs that #1531 to #1538 left out because their cleanup needed case-by-case handling. In 12 files, cleanup that was done with defer in the spec body, or kept in a spec variable and called from AfterEach, is now registered with DeferCleanup right after the resource is created.

  • 1-035, 1-120, 1-124, 1-144 ingress: defer in the spec body becomes DeferCleanup.
  • 1-046, 1-083, 1-124, 1-144 webhook: the namespace cleanup funcs and the cleanupfuncs slice go away with the if x != nil checks in AfterEach. 1-083 used to call its cleanup twice (defer and AfterEach), now it runs once.
  • 1-042: DeleteNamespace moves from a defer in AfterEach to a DeferCleanup after the namespace is created.
  • 1-040: role deletion and the port-forward stop are registered after the namespace cleanup, so they still run first, while the Argo CD pods are up.
  • 1-121: the ImageUpdater CR deletion is registered after the CR is created, so it still runs before the namespace is deleted.
  • 1-133: ensureTestPriorityClass registers the PriorityClass deletion itself, so createdPriorityClassNames goes away. The PriorityClasses are created before the namespace, so they are still deleted after it.
  • 1-141: the git server and repo cleanups are registered when they are started. They were spec variables that were never reset, so a spec could call the cleanup left by an earlier spec.

DeferCleanup runs after AfterEach, so OutputDebugOnFail still runs before the namespaces are deleted. In 1-121 it used to run after the namespace was deleted, so the debug output now includes the namespace contents.

defer cancel() (port-forward and context), defer resp.Body.Close() and defer conn.Close() stay as they are: they release local resources, not cluster state.

PR acceptance criteria:

  • Documentation was updated and verified using make serve-docs: not applicable, no docs change.
  • Unit tests were updated: not applicable, E2E only.
  • E2E tests were updated

What type of PR is this?

/kind cleanup

Special notes to the reviewer:

go vet ./test/openshift/e2e/ginkgo/parallel/ is clean and the package compiles. I did not run the E2E specs locally (no cluster). 1-141 is labelled openshift, so it only runs in the Prow jobs.

The sequential specs will come in separate PRs.

Signed-off-by: gabriel.carmo <admin@gabrielandre.com.br>
@openshift-ci openshift-ci Bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process. label Dec 4, 2026
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated end-to-end test cleanup to run through the test framework’s lifecycle across namespace, resource, and port-forward scenarios.
    • Failure diagnostics remain available where applicable.

The E2E tests now register namespace and resource cleanup with Ginkgo’s DeferCleanup. Several tests remove shared cleanup variables and cleanup calls from AfterEach; resource-specific cleanup callbacks remain in place.

Changes: Ginkgo E2E cleanup lifecycle

Layer / File(s) Summary
Namespace cleanup registration
test/openshift/e2e/ginkgo/parallel/1-035_validate_argocd_secret_repopulate_test.go, 1-040_validate_quoted_RBAC_group_names_test.go, 1-042_restricted_pss_compliant_test.go, 1-046_validate_application_tracking_test.go, 1-083_validate_kustomize_namereference_test.go, 1-121_validate_image_updater_test.go, 1-124_validate_networkpolicies_test.go, 1-133_validate_priorityclassname_test.go, 1-141_source_hydrator.go, 1-144_validate_image_updater_webhook_test.go, 1-144_validate_ingress_test.go
Namespace cleanup is registered with DeferCleanup after namespace creation. Tests remove shared cleanup state and associated AfterEach cleanup calls.
Created-resource cleanup registration
test/openshift/e2e/ginkgo/parallel/1-040_validate_quoted_RBAC_group_names_test.go, 1-120_repo_server_system_ca_trust.go, 1-121_validate_image_updater_test.go, 1-133_validate_priorityclassname_test.go, 1-141_source_hydrator.go
Cleanup for roles, ConfigMaps, Secrets, ImageUpdater resources, PriorityClasses, Git servers, and repositories is registered with Ginkgo. The RBAC test deletes the role before stopping its port-forward.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Other

Suggested reviewers: jgwest, olivergondza, anandrkskd, chengfang

Merge Risk: Minimal · up to 5802c

This PR only changes how E2E tests register their cleanup and does not affect production behavior. No concrete problems were found, and the change is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the remaining parallel e2e test cleanup moves to Ginkgo DeferCleanup. The raw summary and objectives confirm that the changes in the 12 files match this. The title is …
Description check Passed The description states the purpose of the PR. It covers the 12 parallel spec files, the cleanup moved to DeferCleanup, the cases that keep defer for local resources, the reasoning for the per-file cha…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the remaining parallel e2e test cleanup moves to Ginkgo DeferCleanup. The raw summary and objectives confirm that the changes in the 12 files match this. The title is 72 characters, within a typical length limit, and uses a conventional commit prefix.

Full details: Description check

Explanation

The description states the purpose of the PR. It covers the 12 parallel spec files, the cleanup moved to DeferCleanup, the cases that keep defer for local resources, the reasoning for the per-file changes, and the testing status. It matches the changeset in the raw summary.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8bb6395 and 5802ca0.

Files selected for processing: 12

  • test/openshift/e2e/ginkgo/parallel/1-035_validate_argocd_secret_repopulate_test.go
  • test/openshift/e2e/ginkgo/parallel/1-040_validate_quoted_RBAC_group_names_test.go
  • test/openshift/e2e/ginkgo/parallel/1-042_restricted_pss_compliant_test.go
  • test/openshift/e2e/ginkgo/parallel/1-046_validate_application_tracking_test.go
  • test/openshift/e2e/ginkgo/parallel/1-083_validate_kustomize_namereference_test.go
  • test/openshift/e2e/ginkgo/parallel/1-120_repo_server_system_ca_trust.go
  • test/openshift/e2e/ginkgo/parallel/1-121_validate_image_updater_test.go
  • test/openshift/e2e/ginkgo/parallel/1-124_validate_networkpolicies_test.go
  • test/openshift/e2e/ginkgo/parallel/1-133_validate_priorityclassname_test.go
  • test/openshift/e2e/ginkgo/parallel/1-141_source_hydrator.go
  • test/openshift/e2e/ginkgo/parallel/1-144_validate_image_updater_webhook_test.go
  • test/openshift/e2e/ginkgo/parallel/1-144_validate_ingress_test.go
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@openshift-ci

openshift-ci Bot commented Dec 4, 2026

Copy link
Copy Markdown

Hi @Gabrielandre02. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jgwest

jgwest commented Dec 4, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@openshift-ci

openshift-ci Bot commented Dec 4, 2026

Copy link
Copy Markdown

@Gabrielandre02: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v4.18-kuttl-sequential 5802ca0 link false /test v4.18-kuttl-sequential

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process. ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants