FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: delete CRD only after all tests in the class pass by xstefank · Pull Request #3279 · operator-framework/java-operator-sdk · GitHub

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

Merged
csviri merged 3 commits into
operator-framework:mainfrom
xstefank:2928
Apr 10, 2026
Merged

fix: delete CRD only after all tests in the class pass#3279
csviri merged 3 commits into
operator-framework:mainfrom
xstefank:2928

Conversation

xstefank commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2928

Copilot AI review requested due to automatic review settings April 8, 2026 14:01
openshift-ci Bot requested review from csviri and metacosm April 8, 2026 14:01

xstefank commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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>
xstefank added 2 commits April 9, 2026 08:29
Signed-off-by: xstefank <xstefank122@gmail.com>
Signed-off-by: xstefank <xstefank122@gmail.com>

xstefank commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

@csviri this is ready for review

csviri commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

thx @xstefank , will take a look tomorrow; but was thinking if we should target next branch, since it is change in the behavior (not super important though)

csviri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

nice! LGTM

csviri merged commit 2318d4a into operator-framework:main Apr 10, 2026
27 checks passed
@Override
public void close() {
// Create a fresh client for cleanup since operator clients may already be closed.
try (var client = new KubernetesClientBuilder().build()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Isn't it the role of the infrastructure client to perform these operations?

xstefank Apr 24, 2026
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

no, because this method runs after @After method that closes the infrastructure client.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

4 participants


Back | FazBrowse Home | New Git URL