Skip to content
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

Merged

Conversation

xchapter7x
Copy link
Contributor

@xchapter7x xchapter7x commented May 10, 2018

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:

This PR will leverage subtests on the existing table tests for the scheduler units.
Some refactoring of error/status messages and functions to align with new approach.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. labels May 10, 2018
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 10, 2018
@xchapter7x xchapter7x changed the title [WIP] use subtest for table units (pkg/scheduler/algorithmprovider) use subtest for table units (pkg/scheduler/algorithmprovider) May 10, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 10, 2018
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) {

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

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) {

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) {

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.

@misterikkit
Copy link

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 11, 2018
@xchapter7x xchapter7x force-pushed the pkg-scheduler-algorithmprovider branch 2 times, most recently from ed647a8 to f02ab73 Compare June 1, 2018 14:47
@xchapter7x
Copy link
Contributor Author

/assign @misterikkit
this PR should be in a good spot if you have a moment to take a look. thanks.

Copy link

@misterikkit misterikkit left a 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

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.

See https://godoc.org/testing#T.FailNow

t.Run(pn, func(t *testing.T) {
p, err := factory.GetAlgorithmProvider(pn)
if err != nil {
t.Errorf("Error retrieving provider: %v", err)

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)
@xchapter7x xchapter7x force-pushed the pkg-scheduler-algorithmprovider branch from f02ab73 to f415558 Compare June 8, 2018 15:44
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 8, 2018
@misterikkit
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2018
@k82cn
Copy link
Member

k82cn commented Jun 12, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2018
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit 15902d9 into kubernetes:master Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants