Skip to content

Commit 3b17212

Browse files
authored
test: fix the crp watcher flakiness (#86)
Signed-off-by: Zhiying Lin <zhiyingl456@gmail.com>
1 parent 9456ab8 commit 3b17212

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/controllers/clusterresourceplacementwatcher/watcher_integration_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ var _ = Describe("Test ClusterResourcePlacement Watcher", Serial, func() {
7979
}, eventuallyTimeout, interval).Should(BeTrue(), "placementController should receive the CRP name when creating CRP")
8080

8181
By("By resetting the placement queue")
82-
fakePlacementController.ResetQueue()
82+
// Reset the queue to avoid the multiple create events triggered.
83+
Consistently(func() error {
84+
if fakePlacementController.Key() == testCRPName {
85+
By("By finding the key and resetting the placement queue")
86+
fakePlacementController.ResetQueue()
87+
}
88+
return nil
89+
}, consistentlyDuration, interval).Should(Succeed(), "placementController queue should be stable empty after resetting")
8390
})
8491

8592
Context("When updating clusterResourcePlacement", func() {
@@ -123,7 +130,7 @@ var _ = Describe("Test ClusterResourcePlacement Watcher", Serial, func() {
123130
By("By checking placement controller queue")
124131
Consistently(func() bool {
125132
return fakePlacementController.Key() == ""
126-
}, consistentlyDuration, interval).Should(BeTrue(), "watcher should ignore the update status event and not enqueue the request into the placementController queue")
133+
}, consistentlyDuration, interval).Should(BeTrue(), "watcher should ignore the update status event and not enqueue the request into the placementController queue, got CRP %+v", createdCRP)
127134
})
128135
})
129136

0 commit comments

Comments
 (0)