fix: delete CRD only after all tests in the class pass#3279
fix: delete CRD only after all tests in the class pass#3279csviri merged 3 commits intooperator-framework:mainfrom
Conversation
|
@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. |
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>
Signed-off-by: xstefank <xstefank122@gmail.com>
Signed-off-by: xstefank <xstefank122@gmail.com>
|
@csviri this is ready for review |
|
thx @xstefank , will take a look tomorrow; but was thinking if we should target |
| @Override | ||
| public void close() { | ||
| // Create a fresh client for cleanup since operator clients may already be closed. | ||
| try (var client = new KubernetesClientBuilder().build()) { |
There was a problem hiding this comment.
Isn't it the role of the infrastructure client to perform these operations?
Fixes #2928