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

[Scheduler] refactor TestPriorityQueue_Update #122524

Merged
merged 1 commit into from Jan 10, 2024

Conversation

AxeZhan
Copy link
Member

@AxeZhan AxeZhan commented Dec 29, 2023

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This this separated from #122234 , for a better review.
#122234 (comment)

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 29, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 29, 2023
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/assign

pkg/scheduler/internal/queue/scheduling_queue_test.go Outdated Show resolved Hide resolved
// each test will call Update() with oldPod and newPod returned from it.
prepareFunc func(q *PriorityQueue) (oldPod, newPod *v1.Pod)
// validateFunc is the function called after the test calls Update(), to validate the pod is updated as expected.
validateFunc func(pInfo *framework.QueuedPodInfo) bool
Copy link
Member

@sanposhiho sanposhiho Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to be a function? I mean, can we change it to wantUpdatedPod: *framework.QueuePodInfo or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can, I added wantUpdatedPod to the return value of prepareFunc, as we'll use the updatedPod for validate.

@AxeZhan AxeZhan force-pushed the testPQupdate branch 2 times, most recently from 14cb465 to 52f94ea Compare January 3, 2024 05:50
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last from me, otherwise LGTM. Leave /approve to @alculquicondor.

pkg/scheduler/internal/queue/scheduling_queue_test.go Outdated Show resolved Hide resolved
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 4, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1c1d4df3996c340f3eaa79489bb44834dc99d03e

pkg/scheduler/internal/queue/scheduling_queue_test.go Outdated Show resolved Hide resolved
Comment on lines 987 to 988
if diff := cmp.Diff(wantUpdatedPod, pInfo, cmpopts.IgnoreFields(framework.QueuedPodInfo{}, "Timestamp", "InitialAttemptTimestamp")); diff != "" {
t.Errorf("Unexpected updated pod diff (-want, +got): %s", diff)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comparison that useful? What in the QueuedPodInfo is important to check?
Can we skip the fields that are not interesting so that we can build the wantQueuedPodInfo without the need of a function?
I don't particularly like the idea of prepare as it makes the test quite hard to read.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, this comparison is to check if update action takes effect.
In this test, all the update action we do is for pod's annotations

				updatedPod := medPriorityPodInfo.Pod.DeepCopy()
				updatedPod.Annotations["foo"] = "test"

So I think maybe we can just check the newpod with the pod we got from queue?

if diff := cmp.Diff(newPod, pInfo.PodInfo.Pod); diff != ""

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 5, 2024
@alculquicondor
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, AxeZhan

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 Jan 5, 2024
@AxeZhan
Copy link
Member Author

AxeZhan commented Jan 8, 2024

/retest

@AxeZhan
Copy link
Member Author

AxeZhan commented Jan 9, 2024

ping @sanposhiho @alculquicondor
needs a new lgtm

@alculquicondor
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 9, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7a10a9e19ec11aadcfbd6d5150d685e5a218b2cf

@sanposhiho
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot merged commit c74cd5f into kubernetes:master Jan 10, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Jan 10, 2024
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants