Skip to content

Fix flaky tests on Windows and slow runners - #572

Merged
andrew merged 4 commits into
git-pkgs:mainfrom
simonchrz:fix/flaky-tests
Oct 24, 2026
Merged

andrew merged 4 commits into
git-pkgs:mainfrom
simonchrz:fix/flaky-tests

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Five tests failed now and then in CI, mostly on Windows.

  • TestJobStoreCreateAndGet and the other job store and mirror API tests left their mirror job running after the test, and Windows couldn't remove the temp directory while the job wrote to it. JobStore.Wait waits for jobs, and the tests cancel theirs and wait.
  • TestScanFetchRouteNotMountedWhenScanningDisabled: Shutdown closed the database without waiting for the background loops it had cancelled, and the stats loop never stopped, so a pass still running kept proxy.db open. Shutdown now waits up to 30 seconds for them and for mirror jobs, which also keeps real shutdowns from querying a closed database.
  • TestRelayStopsAtLimit saw a response end after 33 KB of 4 MB without an error. The relay passed on any copy error other than the size limit as a complete response; it now cuts the connection, so git fails instead. I couldn't reproduce the early end locally. The test upstream now reads the request body as git's server does, and the test prints the relay's log if it fails again.
  • TestSlowFetchAfterPushIsWaitedFor relied on the ref check finishing within two seconds. It now holds the fetch and ends RefreshWait through a test hook, and takes about 1.5 s instead of 4. When the check and RefreshWait end together, ensureFresh now waits for the fetch instead of picking one at random.
  • TestStalledFetchAfterPushServesCachedCopy got a 502 once on Windows, and the CI log doesn't show why. Failing gitcache tests now print the cache's log, so the next failure will.

The job store tests left their jobs running after the test, and on
Windows the test's directories could not be removed while a job was
still writing to them. JobStore.Wait now waits for jobs to return, and
the tests cancel their jobs and wait for them.
Shutdown cancelled the eviction, retention, reclaim, backfill and stats
loops but closed storage and the database without waiting for them, and
the stats loop never stopped. A pass still running kept the database
open, which on Windows left proxy.db locked after a server test. Shutdown
now waits up to 30 seconds for them, and for mirror jobs.
A response that ended early for another reason than the size limit was
passed on as complete. TestRelayStopsAtLimit failed that way in CI. The
test upstream now reads the request body as a git server does, and the
test prints the relay's log when it fails.
TestSlowFetchAfterPushIsWaitedFor relied on the ref check finishing
within two seconds, which a slow Windows runner missed. The test now
holds the fetch and ends RefreshWait itself. When the check and the wait
end together, ensureFresh now waits for the fetch rather than picking
either at random. Failing gitcache tests print the cache's log.
@andrew
andrew merged commit b855c5b into git-pkgs:main Oct 24, 2026
6 checks passed
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