-
Notifications
You must be signed in to change notification settings - Fork 39.6k
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
use subtest for table units (pkg/scheduler/algorithmprovider) #63662
use subtest for table units (pkg/scheduler/algorithmprovider) #63662
Conversation
for _, pf := range p.PriorityFunctionKeys.List() { | ||
if !factory.IsPriorityFunctionRegistered(pf) { | ||
t.Errorf("priority function %s is not registered but is used in the %s algorithm provider", pf, pn) | ||
t.Run(fmt.Sprintf("providername/%s", pn), func(t *testing.T) { |
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.
"providername/" does not disambiguate anything here, but I think adding the "priority" and "predicate" names below is useful to disambiguate "sibling" subtests. I suggest removing "providername/"
p, err := factory.GetAlgorithmProvider(pn) | ||
if err != nil { | ||
t.Errorf("error retrieving provider: %v", err) | ||
return |
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.
t.Errorf();return can be replace with t.Fatalf()
} | ||
} | ||
for _, pf := range p.PriorityFunctionKeys.List() { | ||
t.Run(fmt.Sprintf("priorityfunctionkey/%s", pf), func(t *testing.T) { |
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 suggest removing "key" from the subtest name. Same on line 65.
t.Errorf("Failed to find predicate: 'PodToleratesNodeTaints'") | ||
break | ||
} | ||
t.Run(fmt.Sprintf("providername/%s", pn), func(t *testing.T) { |
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.
This test has an interesting structure. As you've currently written it, you will generate pairs of subtests with the same name. I think it would make sense to replace "providername" with a description of what the two loops are testing. Maybe call them "before_apply" and "after_apply"?
Also, I think the provider name should come first so that the sub-test names are similar to those in TestAlgorithmProviders.
/ok-to-test |
ed647a8
to
f02ab73
Compare
/assign @misterikkit |
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.
Looking good! just a couple comments.
p, err := factory.GetAlgorithmProvider(pn) | ||
if err != nil { | ||
t.Fatalf("error retrieving provider: %v", err) | ||
return |
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.
t.Fatalf causes the func to return, so return
is not needed.
t.Run(pn, func(t *testing.T) { | ||
p, err := factory.GetAlgorithmProvider(pn) | ||
if err != nil { | ||
t.Errorf("Error retrieving provider: %v", err) |
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.
replace Errorf ... return
with Fatalf
implement PR feedback replace errorf + return with fatalf kubernetes#63662 (comment) kubernetes#63662 (comment)
f02ab73
to
f415558
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: k82cn, misterikkit, xchapter7x The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Review the full test history for this PR. Silence the bot with an |
1 similar comment
/retest Review the full test history for this PR. Silence the bot with an |
Automatic merge from submit-queue (batch tested with PRs 64285, 63660, 63661, 63662, 64883). If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it: Update scheduler's unit table tests to use subtest
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Special notes for your reviewer:
breaks up PR: #63281
/ref #63267
Release note: