Skip to content

fix flaky insert debounce test#1146

Merged
bgentry merged 1 commit intomasterfrom
bg/flaky-insert-debounce
Feb 13, 2026
Merged

fix flaky insert debounce test#1146
bgentry merged 1 commit intomasterfrom
bg/flaky-insert-debounce

Conversation

@bgentry
Copy link
Contributor

@bgentry bgentry commented Feb 13, 2026

Test_Client_InsertNotificationsAreDeduplicatedAndDebounced was flaky because it depended on wall-clock timing near the 1s FetchCooldown boundary. In slower CI runs, repeated queue1 inserts could cross that boundary and legitimately emit a second river_insert notification.

client_test.go:6737: received insert notification when it should have been debounced {topic:river_insert payload:{Queue:queue1}}

To fix this, drive limiter time with client.baseService.Time.StubNowUTC(...) instead of sleeping on real time. Keep repeated queue1 inserts inside the cooldown window, then advance just past cooldown and assert queue1 notifies again. This matches how maybeNotifyInsertForQueues calls insertNotifyLimiter.ShouldTrigger and keeps queue-level debounce behavior deterministic while still verifying that queue2 and queue3 are unaffected.

`Test_Client_InsertNotificationsAreDeduplicatedAndDebounced` was flaky
because it depended on wall-clock timing near the 1s `FetchCooldown`
boundary. In slower CI runs, repeated `queue1` inserts could cross that
boundary and legitimately emit a second `river_insert` notification.

```
client_test.go:6737: received insert notification when it should have been debounced {topic:river_insert payload:{Queue:queue1}}
```

Drive limiter time with `client.baseService.Time.StubNowUTC(...)`
instead of sleeping on real time. Keep repeated `queue1` inserts inside
the cooldown window, then advance just past cooldown and assert `queue1`
notifies again. This matches how `maybeNotifyInsertForQueues` calls
`insertNotifyLimiter.ShouldTrigger` and keeps queue-level debounce
behavior deterministic while still verifying that `queue2` and `queue3`
are unaffected.
@bgentry bgentry requested a review from brandur February 13, 2026 16:41
@bgentry bgentry merged commit c449b62 into master Feb 13, 2026
14 checks passed
@bgentry bgentry deleted the bg/flaky-insert-debounce branch February 13, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants