fix: delete CRD only after all tests in the class pass#3279
Open
xstefank wants to merge 1 commit intooperator-framework:mainfrom
Open
fix: delete CRD only after all tests in the class pass#3279xstefank wants to merge 1 commit intooperator-framework:mainfrom
xstefank wants to merge 1 commit intooperator-framework:mainfrom
Conversation
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. |
Contributor
There was a problem hiding this comment.
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
KubernetesClientBuilderto enable creating a fresh Kubernetes client during cleanup - Introduced a new static inner class
CrdCleanupthat implementsExtensionContext.Store.CloseableResourceto handle cleanup at the class scope level - Moved CRD deletion logic from the
after()method (called after each test) to theCrdCleanup.close()method (called when the class scope closes) - Registered
CrdCleanupin 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
kubernetesClienttoinfrastructureKubernetesClientfor better code readability
Signed-off-by: xstefank <xstefank122@gmail.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2928