Skip to content

perf: reduce CI test time from ~97s to ~5s#9

Merged
BadgerOps merged 2 commits into
masterfrom
ci-speed-improvements
Feb 25, 2026
Merged

perf: reduce CI test time from ~97s to ~5s#9
BadgerOps merged 2 commits into
masterfrom
ci-speed-improvements

Conversation

@BadgerOps

Copy link
Copy Markdown
Owner

Summary

  • The internal/download package tests took ~92 seconds (of ~97s total test step), making it the sole CI bottleneck
  • Made retry backoff injectable on Client via a BackoffFunc field so tests use zero-delay backoff instead of real exponential sleeps (1-3s per retry)
  • Rewrote slow test HTTP handlers to respect request context cancellation, so httptest.Server.Close() returns immediately instead of blocking on in-flight handler goroutines
  • Reduced unnecessary time.Sleep durations in concurrency and cancellation tests

Before → After (download package)

Test Before After
TestDownloadFileTimeout 60.0s 0.2s
TestDownloadFileContextCancellation 10.1s 0.06s
TestDownloadFileRetry 4.5s 0.0s
TestDownloadFileChecksumMismatch 3.8s 0.0s
TestDownloadFileServerError 3.4s 0.0s
TestDownloadFileSizeValidation 3.7s 0.0s
TestPoolWithChecksumValidation 3.4s 0.0s
TestPoolContextCancellation 2.0s 0.05s
Package total 92s 0.9s

No production code behavior changes — BackoffFunc defaults to the existing calculateBackoffDelay.

Test plan

  • All 13 packages pass locally (go test -count=1 ./...)
  • go vet ./... clean
  • CI passes on this PR

🤖 Generated with Claude Code

BadgerOps and others added 2 commits February 24, 2026 19:57
The download package tests were the CI bottleneck, consuming ~92s of the
~97s unit test step. Three root causes:

1. TestDownloadFileTimeout had a 60s server-side sleep. The client
   context timed out in 1s, but httptest.Server.Close() blocked waiting
   for the handler goroutine. Fixed by making the handler respect the
   request context so it exits immediately on cancellation.

2. TestDownloadFileContextCancellation sent 100 chunks with 100ms
   sleeps (10s total). Reduced to 50 chunks at 10ms with context-aware
   select loops.

3. Multiple retry tests (ServerError, ChecksumMismatch, SizeValidation,
   Retry) used real exponential backoff sleeps (1-3s each). Made the
   backoff function injectable on Client via a BackoffFunc field, with
   test helper that sets zero-delay backoff.

Also reduced TestPoolContextCancellation and TestPoolConcurrency server
delays proportionally.

All 13 packages still pass. No production code behavior changes — the
BackoffFunc field defaults to the existing calculateBackoffDelay.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@BadgerOps BadgerOps merged commit 3665d74 into master Feb 25, 2026
6 checks passed
@BadgerOps BadgerOps deleted the ci-speed-improvements branch February 25, 2026 02:43
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