Skip to content

De-flake TestExecSource on Windows - #491

Merged
ppkarwasz merged 1 commit into
trunkfrom
deflake-test-exec-source
Aug 25, 2026
Merged

De-flake TestExecSource on Windows#491
ppkarwasz merged 1 commit into
trunkfrom
deflake-test-exec-source

Conversation

@ppkarwasz

Copy link
Copy Markdown
Member

TestExecSource.testBatchTimeout fails intermittently on the Windows runner (e.g. this run). Three causes, all Windows-specific or Windows-amplified:

  1. Fixed sleeps lose to PowerShell start-up. The tests slept a fixed 1.5–2.5 s before draining the channel; PowerShell cold-start on a loaded runner regularly takes longer. The tests now await the source counter (Awaitility, up to 30 s) via a new package-private ExecSource#getSourceCounter(), following the SyslogTcpSource precedent. This also cuts ~20 s of unconditional sleeping from the suite (~41 s → ~15 s).
  2. Write/read race. The input file was written after source.start(), but the Windows command Get-Content <file> | Select-Object -Last 10 is a one-shot read: it sees whatever happens to be in the file when PowerShell gets to it. The file is now fully written before the source starts.
  3. Wrong semantics on Windows. Because the one-shot command exits, events were delivered by the EOF flush rather than the 750 ms batch timeout the test is meant to exercise. Get-Content -Tail 10 -Wait is the real tail -f equivalent: the process stays alive and only the timed flush delivers the events.

Also replaces the hard-coded /tmp path, which only worked on Windows by accident, with a real temporary file.

Fixed sleeps lose to PowerShell start-up times on loaded CI runners:
await the source counter instead.
`Get-Content -Wait` keeps the process alive like `tail -f`,
so the batch timeout, not the EOF flush, delivers the events.
Writing the input file before the source starts removes the race
with the one-shot read of the old command.

Assisted-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zsFn1f2B32vcNoCeZSfn7
@ppkarwasz
ppkarwasz enabled auto-merge (squash) August 25, 2026 11:22
@ppkarwasz
ppkarwasz merged commit 373de83 into trunk Aug 25, 2026
11 checks passed
@ppkarwasz
ppkarwasz deleted the deflake-test-exec-source branch August 25, 2026 11:46
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.

1 participant