test: fix fuzzer logic for ImageListPullJob status generation#2454
test: fix fuzzer logic for ImageListPullJob status generation#2454rakshaak29 wants to merge 1 commit into
Conversation
Signed-off-by: rakshaak29 <rakshaak29@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR fixes ImageListPullJob fuzzer status generation in test/fuzz/imagelistpulljob.go by correcting rand.Intn upper bounds so the fuzzer can actually produce both 0 and 1 values for key status counters (instead of always 0).
Changes:
- Update
Active,Succeeded, andCompletedstatus field generation fromr.Intn(1)tor.Intn(2)to avoid always returning0. - Improve fuzz input variability for
ImageListPullJobStatus, increasing the chance of exercising additional code paths during fuzzing.
💡 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 @@
## master #2454 +/- ##
==========================================
+ Coverage 48.77% 48.99% +0.21%
==========================================
Files 324 325 +1
Lines 27928 28032 +104
==========================================
+ Hits 13623 13734 +111
+ Misses 12775 12746 -29
- Partials 1530 1552 +22
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:
|
What's changed?
This PR addresses a logical flaw in the fuzzer implementation for
ImageListPullJob(test/fuzz/imagelistpulljob.go) that was restricting test coverage.Previously, the random number generator used
r.Intn(1)to generate theActive,Succeeded, andCompletedstatus fields. According to the Gomath/randspecification,rand.Intn(n)returns a value in the half-open interval[0, n). Therefore,r.Intn(1)always returns0. This entirely prevented the fuzzer from generating test configurations where these status fields had a value of1or greater.This commit changes the bounds to
r.Intn(2), allowing the status variables to properly simulate both0and1states during fuzz testing, ultimately increasing the fuzzer's effectiveness at detecting latent bugs.How to test it?
make testto ensure all tests pass.staticcheck ./test/fuzz/...to verify that theSA4030warning (which initially highlighted thatr.Intn(1)always returns 0) has been cleared.Which issue(s) this PR fixes:
#2453