Skip to content

Commit e42194b

Browse files
cjc7373apecloud-bot
authored andcommitted
chore: fix a flaky test (#9699)
(cherry picked from commit c2dca51)
1 parent 7e7a7ac commit e42194b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

controllers/apps/component/component_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var _ = Describe("Component Controller", func() {
9999
By("clean resources")
100100

101101
// delete components (and all dependent sub-resources), and component definitions & versions
102-
testapps.ClearComponentResourcesWithRemoveFinalizerOption(&testCtx)
102+
testapps.ClearComponentResources(&testCtx)
103103

104104
// delete rest mocked objects
105105
inNS := client.InNamespace(testCtx.DefaultNamespace)

pkg/testutil/apps/common_util.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,14 @@ func ClearClusterResourcesWithRemoveFinalizerOption(testCtx *testutil.TestContex
373373
ClearResourcesWithRemoveFinalizerOption(testCtx, intctrlutil.ComponentVersionSignature, true, hasLabels)
374374
}
375375

376+
func ClearComponentResources(testCtx *testutil.TestContext) {
377+
inNs := client.InNamespace(testCtx.DefaultNamespace)
378+
hasLabels := client.HasLabels{testCtx.TestObjLabelKey}
379+
ClearResources(testCtx, intctrlutil.ComponentSignature, inNs, hasLabels)
380+
ClearResources(testCtx, intctrlutil.ComponentDefinitionSignature, hasLabels)
381+
ClearResources(testCtx, intctrlutil.ComponentVersionSignature, hasLabels)
382+
}
383+
376384
// ClearComponentResourcesWithRemoveFinalizerOption clears all dependent resources belonging to existing components.
377385
func ClearComponentResourcesWithRemoveFinalizerOption(testCtx *testutil.TestContext) {
378386
inNs := client.InNamespace(testCtx.DefaultNamespace)

0 commit comments

Comments
 (0)