-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for pkg/scheduler/scheduler.go #5645
Added tests for pkg/scheduler/scheduler.go #5645
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5645 +/- ##
==========================================
+ Coverage 35.19% 37.03% +1.83%
==========================================
Files 645 648 +3
Lines 44869 45079 +210
==========================================
+ Hits 15792 16693 +901
+ Misses 27846 27118 -728
- Partials 1231 1268 +37
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/assign |
pkg/scheduler/scheduler_test.go
Outdated
if tt.expectSchedule { | ||
assert.Len(t, patchActions, len(tt.expectedPatches), "Expected %d patch actions, got %d", len(tt.expectedPatches), len(patchActions)) | ||
for i, expectedPatch := range tt.expectedPatches { | ||
if i < len(patchActions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this judgment?
In addition, the judgment logic of the TestDoScheduleClusterBinding and TestDoScheduleBinding functions is different. Can the TestDoScheduleClusterBinding and TestDoScheduleBinding functions directly determine the binding field obtained at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove those judgements and refractor both tests to be consistent.
if (err != nil) != tt.expectError { | ||
t.Errorf("scheduleResourceBindingWithClusterAffinities() error = %v, expectError %v", err, tt.expectError) | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is not judged later. The test method can be the same as that of the TestScheduleResourceBindingWithClusterAffinity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks~, It's a big mr.
The name of the new test method is different from that of the existing test function.
Signed-off-by: Anuj Agrawal <[email protected]> Added tests for pkg/scheduler/scheduler.go Signed-off-by: Anuj Agrawal <[email protected]>
Yes it is big and the scheduler package is hard to test. |
681e490
to
9a0abbf
Compare
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
You can consider splitting pr. |
I had a question. As i have used mocks, if i spilt the file than the CI tests might fail. That's the reason i tried to make a single PR for a single file. How can i tackle it? |
We need to look at what error caused the ci failure. Generally, CI failures are recorded in clear logs to tell us how to modify them. |
Hi @anujagrawal699, do we still need this pr? |
No, i'll close it. Thanks. |
Description:
This PR significantly enhances the unit tests for the scheduler package. The improvements aim to increase code reliability, maintainability, and test coverage for various scheduler functions.
Modifications:
Key Improvements:
doSchedule
,doScheduleBinding
, anddoScheduleClusterBinding
functions.scheduleResourceBindingWithClusterAffinity
andscheduleResourceBindingWithClusterAffinities
.scheduleClusterResourceBindingWithClusterAffinity
andscheduleClusterResourceBindingWithClusterAffinities
.patchScheduleResultForResourceBinding
.scheduleNext
method.recordScheduleResultEventForResourceBinding
.placementChanged
function.TestCreateScheduler
Test Coverage:
What type of PR is this?
/kind feature
Which issue(s) this PR fixes:
Fixes a part of #5470
Does this PR introduce a user-facing change?: