-
Notifications
You must be signed in to change notification settings - Fork 42.1k
Refactor scheduler_test.go to use Clientset #70290
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
Refactor scheduler_test.go to use Clientset #70290
Conversation
5280211 to
e3e2aa2
Compare
4a6571a to
65eb6da
Compare
|
/assign @misterikkit |
|
/ok-to-test |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: k82cn, tossmilestone 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 |
Signed-off-by: He Xiaoxi <[email protected]>
65eb6da to
12634bf
Compare
misterikkit
left a comment
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 looks pretty good. I think overall, scheduler_test.go is already somewhat messy, but this PR is not about cleaning that up. Please look into the SelfLink thing, and then I'll approve.
| "//pkg/scheduler/factory:go_default_library", | ||
| "//pkg/scheduler/internal/cache:go_default_library", | ||
| "//pkg/scheduler/internal/cache/fake:go_default_library", | ||
| "//pkg/scheduler/testing:go_default_library", |
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.
❤️
| Name: id, | ||
| UID: types.UID(id), | ||
| SelfLink: schedulertesting.Test.SelfLink(string(v1.ResourcePods), id), | ||
| SelfLink: fmt.Sprintf("/api/v1/%s/%s", string(v1.ResourcePods), id), |
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.
Do the tests pass with this line removed? My understanding is that SelfLink is not important to any of the behavior we are trying to test.
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 have run the test without SelfLink, but it will cause error below:
1030 01:51:38.384380 13145 event.go:259] Could not construct reference to: '&v1.Pod{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"foo", GenerateName:"", Namespace:"", SelfLink:"", UID:"foo", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:""}, Spec:v1.PodSpec{Volumes:[]v1.Volume(nil), InitContainers:[]v1.Container(nil), Containers:[]v1.Container(nil), RestartPolicy:"", TerminationGracePeriodSeconds:(*int64)(nil), ActiveDeadlineSeconds:(*int64)(nil), DNSPolicy:"", NodeSelector:map[string]string(nil), ServiceAccountName:"", DeprecatedServiceAccount:"", AutomountServiceAccountToken:(*bool)(nil), NodeName:"machine1", HostNetwork:false, HostPID:false, HostIPC:false, ShareProcessNamespace:(*bool)(nil), SecurityContext:(*v1.PodSecurityContext)(nil), ImagePullSecrets:[]v1.LocalObjectReference(nil), Hostname:"", Subdomain:"", Affinity:(*v1.Affinity)(nil), SchedulerName:"", Tolerations:[]v1.Toleration(nil), HostAliases:[]v1.HostAlias(nil), PriorityClassName:"", Priority:(*int32)(nil), DNSConfig:(*v1.PodDNSConfig)(nil), ReadinessGates:[]v1.PodReadinessGate(nil), RuntimeClassName:(*string)(nil), EnableServiceLinks:(*bool)(nil)}, Status:v1.PodStatus{Phase:"", Conditions:[]v1.PodCondition(nil), Message:"", Reason:"", NominatedNodeName:"", HostIP:"", PodIP:"", StartTime:(*v1.Time)(nil), InitContainerStatuses:[]v1.ContainerStatus(nil), ContainerStatuses:[]v1.ContainerStatus(nil), QOSClass:""}}' due to: 'selfLink was empty, can't make reference'. Will not report event: 'Normal' 'Scheduled' 'Successfully assigned /foo to machine1'
and the test will hang waiting for the event. So the SelfLink is necessary for test. 😢
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.
Huh, weird. I'd like to look into that eventually.
|
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Use
k8s.io/client-go/kubernetes/fake.Clientsetas the fake k8s client inpkg/scheduler/scheduler_test.go.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #68962
Special notes for your reviewer:
Does this PR introduce a user-facing change?: