tests: fix nil panic in TestDisableSchedulingServiceFallback#10282
tests: fix nil panic in TestDisableSchedulingServiceFallback#10282JmPotato wants to merge 1 commit intotikv:masterfrom
Conversation
Add nil guards for GetPrimaryServer() and GetCluster() inside the Eventually callback, matching the existing pattern used in TestSchedulingServiceFallback. Also replace require assertions (re.NotNil) with nil-check-and-return-false inside the Eventually callback to avoid FailNow panics from non-test goroutines. Close tikv#8926 Signed-off-by: JmPotato <github@ipotato.me>
📝 WalkthroughWalkthroughAdd defensive null checks in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10282 +/- ##
========================================
Coverage 78.80% 78.80%
========================================
Files 523 525 +2
Lines 70529 70824 +295
========================================
+ Hits 55580 55815 +235
- Misses 10955 10996 +41
- Partials 3994 4013 +19
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: okJiang The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
What problem does this PR solve?
Issue Number: Close #8926
TestDisableSchedulingServiceFallbackis flaky due to a nil pointer dereference inside anassert.Eventuallycallback. The test callstc.GetPrimaryServer().GetCluster().IsBackgroundJobsRunning()without nil checks, causing a SIGSEGV panic when eitherGetPrimaryServer()orGetCluster()returns nil during the scheduling server's initialization window.Additionally, the test used
re.NotNil()(arequireassertion) inside anEventuallycallback. SinceEventuallymay run the callback in a goroutine context, callingFailNow()from a non-test goroutine can cause a panic.What is changed and how does it work?
re.NotNil()require assertions inside the firstEventuallycallback with proper nil-check-and-return-false guards, preventingFailNowpanics from non-test goroutines.GetPrimaryServer()andGetCluster()in the secondEventuallycallback before callingIsBackgroundJobsRunning(), matching the existing defensive pattern already used in the sibling testTestSchedulingServiceFallback.Check List
Tests
Release note