Merge pull request #52148 from wackxu/addmtcase

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add test case  in metadata_test.go

**What this PR does / why we need it**:

Add test case in metadata_test.go

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #55567 

**Release note**:

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-11-13 00:50:11 -08:00 committed by GitHub
commit fe5b8fac86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -94,6 +94,24 @@ func TestPriorityMetadata(t *testing.T) {
Tolerations: tolerations,
},
}
podWithAffinityAndRequests := &v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "container",
Image: "image",
ImagePullPolicy: "Always",
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("200m"),
v1.ResourceMemory: resource.MustParse("2000"),
},
},
},
},
Affinity: podAffinity,
},
}
tests := []struct {
pod *v1.Pod
test string
@ -122,6 +140,15 @@ func TestPriorityMetadata(t *testing.T) {
},
test: "Produce a priorityMetadata with specified requests",
},
{
pod: podWithAffinityAndRequests,
expected: &priorityMetadata{
nonZeroRequest: specifiedReqs,
podTolerations: nil,
affinity: podAffinity,
},
test: "Produce a priorityMetadata with specified requests",
},
}
for _, test := range tests {
ptData := PriorityMetadata(test.pod, nil)