Skip to content

test: add fuzz and stress tests for concurrent safety#49

Merged
samber merged 6 commits into
mainfrom
feat/fuzz-stress-tests
Mar 24, 2026
Merged

test: add fuzz and stress tests for concurrent safety#49
samber merged 6 commits into
mainfrom
feat/fuzz-stress-tests

Conversation

@samber
Copy link
Copy Markdown
Owner

@samber samber commented Mar 24, 2026

  • Add stress_test.go with 17 tests: edge cases, concurrent stress tests
    for all handlers (Fanout, Failover, Pool, Router, FirstMatch, Pipe,
    Recovery, InlineHandler), and composed handler tests
  • Add fuzz_test.go with 5 fuzz targets: FanoutHandle, FailoverHandle,
    PoolHandle, FirstMatchHandle, RouterPredicates
  • Expose known race condition in PoolHandler (rand.Source not thread-safe)
  • All tests pass with -race (Pool test skipped due to known bug)

- Add stress_test.go with 17 tests: edge cases, concurrent stress tests
  for all handlers (Fanout, Failover, Pool, Router, FirstMatch, Pipe,
  Recovery, InlineHandler), and composed handler tests
- Add fuzz_test.go with 5 fuzz targets: FanoutHandle, FailoverHandle,
  PoolHandle, FirstMatchHandle, RouterPredicates
- Expose known race condition in PoolHandler (rand.Source not thread-safe)
- All tests pass with -race (Pool test skipped due to known bug)
Copilot AI review requested due to automatic review settings March 24, 2026 16:44
Copy link
Copy Markdown

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

Adds fuzzing and concurrent stress coverage to validate thread-safety and edge-case behavior across slogmulti handler combinators, and introduces Makefile targets to run fuzzing locally.

Changes:

  • Added stress_test.go with edge-case and high-concurrency stress tests for core handlers and common compositions.
  • Added fuzz_test.go with fuzz targets for handler behavior and router predicates to prevent panics and validate basic invariants.
  • Updated Makefile with fuzz and watch-fuzz targets.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
stress_test.go Adds concurrency stress + edge-case coverage (including documenting the known Pool race).
fuzz_test.go Adds fuzz targets to exercise handlers/predicates across broad input ranges.
Makefile Adds convenience targets for running fuzzing locally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile Outdated
Comment thread stress_test.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.15%. Comparing base (047aba8) to head (93f24e2).

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #49       +/-   ##
===========================================
+ Coverage   29.20%   54.15%   +24.94%     
===========================================
  Files          16       16               
  Lines         493      493               
===========================================
+ Hits          144      267      +123     
+ Misses        340      216      -124     
- Partials        9       10        +1     
Flag Coverage Δ
unittests 54.15% <ø> (+24.94%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

samber added 4 commits March 24, 2026 17:56
- Replace custom rand.Source with math/rand/v2 global (thread-safe)
- Fix slice aliasing: use make+copy instead of append on sub-slices
- Remove randSource field from PoolHandler (no longer needed)
- Bump minimum Go version to 1.22 (required for math/rand/v2)
- Unskip TestStressPoolConcurrent (race is now fixed)
@samber samber merged commit a7bfab4 into main Mar 24, 2026
14 checks passed
@samber samber deleted the feat/fuzz-stress-tests branch March 24, 2026 17:06
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