Skip to content

perf: inject sleep function to speed up AWS provider tests (~200x)#739

Merged
ArangoGutierrez merged 2 commits intomainfrom
fix/fast-unit-tests
Mar 26, 2026
Merged

perf: inject sleep function to speed up AWS provider tests (~200x)#739
ArangoGutierrez merged 2 commits intomainfrom
fix/fast-unit-tests

Conversation

@ArangoGutierrez
Copy link
Copy Markdown
Collaborator

Summary

  • Add injectable sleep func(time.Duration) field to Provider struct, defaulting to time.Sleep in production
  • Add WithSleep functional option for test injection
  • Replace all time.Sleep() calls in create.go and delete.go with p.sleep()
  • Inject noopSleep (no-op) in all test files to eliminate real wall-clock delays

Impact

  • AWS provider unit tests: ~433s → ~2s (~200x speedup)
  • Ginkgo suite alone: ~97s → 0.5s
  • Zero behavior change in production (default remains time.Sleep)

Test plan

  • All 84 Ginkgo specs pass
  • All standalone Go tests pass
  • Full project go test ./... passes (only E2E skipped due to missing env)
  • Verified TestDeleteRetryBackoff tracks sleep calls correctly with injected function

Replace all time.Sleep calls in Provider with injectable p.sleep field,
defaulting to time.Sleep in production and noopSleep in tests. This
eliminates ~430s of real wall-clock delays in unit tests (retry backoff,
NAT gateway polling, verification delays) bringing the AWS provider
test suite from ~433s down to ~2s.

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 25, 2026

Pull Request Test Coverage Report for Build 23530118464

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 56.346%

Totals Coverage Status
Change from base Build 23494167457: 0.03%
Covered Lines: 3729
Relevant Lines: 6618

💛 - Coveralls

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
@ArangoGutierrez ArangoGutierrez merged commit 4b517ca into main Mar 26, 2026
23 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