Skip to content

chore(e2e): Use DeferCleanup for namespace cleanup kept in spec variables in sequential tests - #1635

Open
Gabrielandre02 wants to merge 1 commit into
redhat-developer:masterfrom
Gabrielandre02:e2e-defercleanup-sequential-namespaces
Open

Gabrielandre02 wants to merge 1 commit into
redhat-developer:masterfrom
Gabrielandre02:e2e-defercleanup-sequential-namespaces

Conversation

@Gabrielandre02

Copy link
Copy Markdown
Contributor

What does this PR do?

Refs #1464

In 9 sequential specs the namespace cleanup funcs were kept in spec variables and called from AfterEach, often behind if x != nil checks. They are now registered with DeferCleanup right after each namespace is created, so the spec variables and the checks go away. AfterEach keeps only OutputDebugOnFail, which still runs before the namespaces are deleted.

  • 1-020, 1-025, 1-116, 1-122 namespace, 1-132 sensitive annotation masking: namespaces created in the spec body.
  • 1-084, 1-092: the namespace is created in BeforeEach, so the DeferCleanup is registered there, replacing the defer cleanupFunc() in AfterEach.
  • 1-010: the Application deletion is registered after the Application is created.
  • 1-108: the deletion of test-gitops-ns, which the Application creates, is registered once the namespace exists. It still ignores NotFound, because the spec deletes and recreates it.

DeferCleanup runs in reverse order of registration. In 1-025, 1-108, 1-116 and 1-132 that is the order AfterEach used. Two specs change order:

  • 1-010 now deletes the Application before its target namespace, rather than after.
  • 1-122 now deletes the source namespace before the Argo CD namespace, rather than after.

Left for a follow-up, because their cleanup needs case-by-case handling: 1-027 (its namespace is created by an Application with automated sync, and the order would change), specs that restore the Subscription in AfterEach, specs that remove finalizers or restore the default instance in AfterEach, and specs with defer func() {...}() in the spec body.

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/sequential/ is clean and the package compiles. I did not run the E2E specs locally (no cluster).

Independent of #1634, which covers the parallel specs.

…bles in sequential tests

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

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8bb6395 and 580f05b.

Files selected for processing: 9

  • test/openshift/e2e/ginkgo/sequential/1-010_validate-ootb-manage-other-namespace_test.go
  • test/openshift/e2e/ginkgo/sequential/1-020_validate_redis_ha_nonha_test.go
  • test/openshift/e2e/ginkgo/sequential/1-025-validate-managed-by-change_test.go
  • test/openshift/e2e/ginkgo/sequential/1-084_validate_prune_templates.go
  • test/openshift/e2e/ginkgo/sequential/1-092_validate_workload_status_monitoring_alert.go
  • test/openshift/e2e/ginkgo/sequential/1-108_alternate_cluster_roles_cluster_scoped_instance_test.go
  • test/openshift/e2e/ginkgo/sequential/1-116_annotation-based-tracking_test.go
  • test/openshift/e2e/ginkgo/sequential/1-122_validate_namespace_test.go
  • test/openshift/e2e/ginkgo/sequential/1-132_validate_sensitive_annotation_masking_test.go

@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

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