Skip to content

fix: delete CRD only after all tests in the class pass#3279

Open
xstefank wants to merge 1 commit intooperator-framework:mainfrom
xstefank:2928
Open

fix: delete CRD only after all tests in the class pass#3279
xstefank wants to merge 1 commit intooperator-framework:mainfrom
xstefank:2928

Conversation

@xstefank
Copy link
Copy Markdown
Collaborator

@xstefank xstefank commented Apr 8, 2026

Fixes #2928

Copilot AI review requested due to automatic review settings April 8, 2026 14:01
@openshift-ci openshift-ci bot requested review from csviri and metacosm April 8, 2026 14:01
@xstefank
Copy link
Copy Markdown
Collaborator Author

xstefank commented Apr 8, 2026

@csviri I wasn't sure if you mean after all tests or after test class, so I did a after a test class first, but I can move it to after testsuite.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #2928 by deferring CRD (Custom Resource Definition) deletion from after each test method to after all tests in a class have completed. Previously, CRDs were deleted after each test, causing issues when a deleted CRD remained in a "deleting" state and caused subsequent tests to fail.

Changes:

  • Added import for KubernetesClientBuilder to enable creating a fresh Kubernetes client during cleanup
  • Introduced a new static inner class CrdCleanup that implements ExtensionContext.Store.CloseableResource to handle cleanup at the class scope level
  • Moved CRD deletion logic from the after() method (called after each test) to the CrdCleanup.close() method (called when the class scope closes)
  • Registered CrdCleanup in the extension context store at class scope to ensure it's invoked once per test class
  • Improved exception handling during CRD deletion with a try-catch wrapper
  • Clarified variable naming from kubernetesClient to infrastructureKubernetesClient for better code readability

Signed-off-by: xstefank <xstefank122@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Junit extension] Delete CRD only after All test not each

2 participants