test: deterministic debounce test via synctest#745
Conversation
5ea2754 to
b916e5c
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the flaky, wall-clock/network-driven debounce integration test (TestGenerateFromEvents) and replaces it with deterministic unit tests for newDebounceChannel using Go’s testing/synctest, addressing nondeterministic timing failures reported in #238.
Changes:
- Replaced
TestGenerateFromEvents(dockertest server + realtime.Sleep) withTestNewDebounceChannelbuilt ontesting/synctest. - Added deterministic subtests covering:
Min == 0passthrough,Minquiet-period coalescing, andMaxcap behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9632402 to
6cbdd3a
Compare
|
@JamBalaya56562 same thing here, no issue or PR numbers in either PR titles or commit message. |
6cbdd3a to
6b64045
Compare
|
Done — dropped the issue number from the title and commit message, thanks! |
6b64045 to
56ac89c
Compare
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56ac89c to
5e508d0
Compare
Address review feedback on PR nginx-proxy#745: remove the verbose doc comment and overly explanatory inline comments, keeping only concise timing markers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The merge with main pulled in TestGetContainersNilStructs, which uses encoding/json, fmt, net/http, strings, dockertest and dockerclient. These imports had been removed together with TestGenerateFromEvents, breaking the build after the merge. Restore them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Separately: now that #748 ( |
Summary
TestGenerateFromEventsdrives the debounce logic through a realdockertestHTTP server and wall-clocktime.Sleepcalls, so the timing of debounce firings races the OS scheduler / timer resolution and the test fails nondeterministically (off-by-one or worse). It reproduces onmainand is especially flaky on Windows. See #238.This PR replaces it with
TestNewDebounceChannel, which exercisesnewDebounceChanneldirectly inside atesting/synctestbubble. The fake clock makes theMinquiet-period coalescing and theMaxcap fire at exact, reproducible virtual times, removing the real network and wall-clock dependence entirely.Changes
internal/generator/generator_test.go: replaceTestGenerateFromEventswithTestNewDebounceChannel. Three deterministic subtests:Min == 0,Minquiet-period coalescing (a burst collapses to one event, firedMinafter the last event),Maxcap (output is forced out atMaxwhile events keep arriving).Notes
newDebounceChannelalready usestime.After, whichsynctestvirtualizes.testing/synctestis stable as of Go 1.25 (go.moddeclaresgo 1.25.5; the CI matrix tests Go 1.25 and 1.26). It is OS-independent, which removes the Windows timer-resolution flakiness at its root.go test -run TestNewDebounceChannel -count=200passes.Fixes #238