Fix flaky TestCatFileBatch/QueryTerminated test#37159
Fix flaky TestCatFileBatch/QueryTerminated test#37159silverwind merged 6 commits intogo-gitea:mainfrom
TestCatFileBatch/QueryTerminated test#37159Conversation
Widen timing margins from 20-40ms to 500ms. The test asserts on specific error types (`os.ErrClosed` vs `io.EOF`) depending on whether pipe close or pipe read wins the race. On slow CI runners the original 20ms margin was too tight, causing the close path to lose the race and return EOF instead of ErrClosed. Co-Authored-By: silverwind <me@silverwind.io> Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces flakiness in TestCatFileBatch/QueryTerminated by widening timing margins in a race-sensitive test so CI scheduling variance is less likely to flip the observed error (os.ErrClosed vs io.EOF).
Changes:
- Increased the “reader slower than close” delay to more reliably produce
os.ErrClosed. - Increased the “close slower than reader” delay to more reliably produce
io.EOF.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use a function hook and channels instead of time.Sleep delays for deterministic test synchronization. Eliminates all timing dependencies. Co-Authored-By: silverwind <me@silverwind.io> Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: silverwind <me@silverwind.io> Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
|
@silverwind This change makes sense to me, especially the idea of controlling the race between I just have a question about the implementation:
Overall, replacing the previous timing-based approach with hooks + channels makes the test much clearer and more deterministic. Nice improvement! |
527dc3a to
c2a340a
Compare
c07f823 to
f9d8bab
Compare
f9d8bab to
f60e52a
Compare
|
Above comment seems like AI spam, but I still checked it and there's nothing addressable in it. |
`TestCatFileBatch/QueryTerminated` relied on timing to distinguish `os.ErrClosed` vs `io.EOF` error paths. Replace `time.Sleep`-based synchronization with a channel-based hook on pipe close, making both error paths fully deterministic regardless of CI runner speed. Ref: https://github.com/go-gitea/gitea/actions/runs/24193070536/job/70615366804 Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Backport #37159 by @silverwind `TestCatFileBatch/QueryTerminated` relied on timing to distinguish `os.ErrClosed` vs `io.EOF` error paths. Replace `time.Sleep`-based synchronization with a channel-based hook on pipe close, making both error paths fully deterministic regardless of CI runner speed. Ref: https://github.com/go-gitea/gitea/actions/runs/24193070536/job/70615366804 --- This PR was written with the help of Claude Opus 4.6 Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* main: Add comment for the design of "user activity time" (go-gitea#37195) fix(api): handle missing base branch in PR commits API (go-gitea#37193) Refactor htmx and fetch-action related code (go-gitea#37186) Fix encoding for Matrix Webhooks (go-gitea#37190) Always show owner/repo name in compare page dropdowns (go-gitea#37172) fix(api): handle fork-only commits in compare API (go-gitea#37185) Improve Contributing docs and set a release schedule (go-gitea#37109) Update Nix flake (go-gitea#37183) Remove outdated RunUser logic (go-gitea#37180) Refactor flash message and remove SanitizeHTML template func (go-gitea#37179) Indicate form field readonly via background (go-gitea#37175) Remove dead CSS rules (go-gitea#37173) Fix flaky `TestCatFileBatch/QueryTerminated` test (go-gitea#37159) Implement logout redirection for reverse proxy auth setups (go-gitea#36085) Add missing `//nolint:depguard` (go-gitea#37162)
TestCatFileBatch/QueryTerminatedrelied on timing to distinguishos.ErrClosedvsio.EOFerror paths. Replacetime.Sleep-based synchronization with a channel-based hook on pipe close, making both error paths fully deterministic regardless of CI runner speed.Ref: https://github.com/go-gitea/gitea/actions/runs/24193070536/job/70615366804
This PR was written with the help of Claude Opus 4.6