Skip to content

Commit 1ed6722

Browse files
committed
Increase test coverage for start with warmup race.
1 parent 8c7b12f commit 1ed6722

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/internal/controller/controller_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,13 +1494,14 @@ var _ = Describe("controller", func() {
14941494
defer cancel()
14951495

14961496
ctrl.CacheSyncTimeout = time.Second
1497+
numWatches := 10
14971498

14981499
var watchStartedCount atomic.Int32
1499-
ctrl.startWatches = []source.TypedSource[reconcile.Request]{
1500-
source.Func(func(ctx context.Context, _ workqueue.TypedRateLimitingInterface[reconcile.Request]) error {
1500+
for range numWatches {
1501+
ctrl.startWatches = append(ctrl.startWatches, source.Func(func(ctx context.Context, _ workqueue.TypedRateLimitingInterface[reconcile.Request]) error {
15011502
watchStartedCount.Add(1)
15021503
return nil
1503-
}),
1504+
}))
15041505
}
15051506

15061507
By("calling Warmup and Start concurrently")
@@ -1518,7 +1519,7 @@ var _ = Describe("controller", func() {
15181519

15191520
<-blockOnWarmupChan
15201521

1521-
Expect(watchStartedCount.Load()).To(Equal(int32(1)), "source should only be started once")
1522+
Expect(watchStartedCount.Load()).To(Equal(int32(numWatches)), "source should only be started once")
15221523
Expect(ctrl.startWatches).To(BeNil(), "startWatches should be reset to nil after they are started")
15231524
})
15241525

0 commit comments

Comments
 (0)