Skip to content

internal: server/git, Fix TestGitServer_Timeout flakiness on Windows CI#2129

Open
aymanbagabas wants to merge 1 commit into
go-git:mainfrom
aymanbagabas:fix-git-server-timeout-flaky
Open

internal: server/git, Fix TestGitServer_Timeout flakiness on Windows CI#2129
aymanbagabas wants to merge 1 commit into
go-git:mainfrom
aymanbagabas:fix-git-server-timeout-flaky

Conversation

@aymanbagabas
Copy link
Copy Markdown
Member

Fixes a flaky TestGitServer_Timeout reported by @AriehSchneier in #2053.

The test compares an elapsed duration measured on the client goroutine against the server's idle timeout, but the server arms its deadline on a separate goroutine. On loaded Windows runners the server can arm the deadline before the client captures start := time.Now(), causing elapsed to fall short.

This change anchors the two clocks by sending a 1-byte probe before timing: pkt-line decoding needs 4 bytes for the length header, so the server consumes the byte and re-enters Read, arming a fresh idle deadline at approximately the same wall-clock moment as the client's start. Recording start before the Write keeps any scheduling latency on the elapsed side, making the lower-bound assertion robust.

Note: the server-side proposal in #2053 (deferring the initial updateDeadline() to first Read) does not eliminate the race because serverConn.Read already calls updateDeadline() at the start of every read.

cc @AriehSchneier

The test measured elapsed time from the client goroutine while the
server arms its idle deadline on a separate goroutine. On loaded
Windows CI runners, the server could arm the deadline before the
client captured start := time.Now(), causing elapsed to fall short
of the configured Timeout and tripping the lower-bound assertion.

Anchor the two clocks by sending a 1-byte probe before timing:
pkt-line decoding needs 4 bytes for the length header, so the server
consumes the byte and re-enters Read, arming a fresh idle deadline at
approximately the same wall-clock moment as the client's start.
Recording start before the Write ensures elapsed includes any
scheduling latency, making the lower-bound robust.

Assisted-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Ayman Bagabas <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates TestGitServer_Timeout to reduce timing flakiness on Windows CI by aligning the client-side elapsed measurement with the server’s idle deadline refresh.

Changes:

  • Sends a one-byte probe before waiting for the idle timeout.
  • Starts elapsed timing before the probe write so scheduling/write latency is included.
  • Updates the test comments to document the timing rationale.
Show a summary per file
File Description
internal/server/git/git_test.go Adjusts the timeout test to anchor server/client timing before asserting the idle timeout lower bound.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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.

3 participants