From f05d4b7f1c5590501c4b471daff74c0b0998413c Mon Sep 17 00:00:00 2001 From: wackxu Date: Fri, 8 Sep 2017 14:58:38 +0800 Subject: [PATCH] add test case --- .../algorithm/priorities/metadata_test.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugin/pkg/scheduler/algorithm/priorities/metadata_test.go b/plugin/pkg/scheduler/algorithm/priorities/metadata_test.go index b8fd653ba24..5cea6b6ce79 100644 --- a/plugin/pkg/scheduler/algorithm/priorities/metadata_test.go +++ b/plugin/pkg/scheduler/algorithm/priorities/metadata_test.go @@ -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)