test: add fuzz and stress tests for concurrent safety#49
Merged
Conversation
- 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)
There was a problem hiding this comment.
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.gowith edge-case and high-concurrency stress tests for core handlers and common compositions. - Added
fuzz_test.gowith fuzz targets for handler behavior and router predicates to prevent panics and validate basic invariants. - Updated
Makefilewithfuzzandwatch-fuzztargets.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
for all handlers (Fanout, Failover, Pool, Router, FirstMatch, Pipe,
Recovery, InlineHandler), and composed handler tests
PoolHandle, FirstMatchHandle, RouterPredicates