test: add cases to test that no images present on node or kubelet's NodeStatusMaxImages flag is set to 0.

This commit is contained in:
Jianfei Bai
2019-08-20 16:00:49 +08:00
parent 1719ce7883
commit 60a27031b2
2 changed files with 63 additions and 0 deletions

View File

@@ -108,6 +108,8 @@ func TestImageLocalityPriority(t *testing.T) {
},
}
nodeWithNoImages := v1.NodeStatus{}
tests := []struct {
pod *v1.Pod
pods []*v1.Pod
@@ -160,6 +162,25 @@ func TestImageLocalityPriority(t *testing.T) {
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: schedulerapi.MaxPriority}, {Host: "machine2", Score: 0}},
name: "if exceed limit, use limit",
},
{
// Pod: gcr.io/2000 gcr.io/10
// Node1
// Image: gcr.io/2000:latest 2000MB
// Score: 10 * (2000M/3 - 23M)/(1000M - 23M) = 6
// Node2
// Image: gcr.io/10:latest 10MB
// Score: 0 (10M/2 < 23M, min-threshold)
// Node3
// Image:
// Score: 0
pod: &v1.Pod{Spec: testMinMax},
nodes: []*v1.Node{makeImageNode("machine1", node403002000), makeImageNode("machine2", node25010), makeImageNode("machine3", nodeWithNoImages)},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 6}, {Host: "machine2", Score: 0}, {Host: "machine3", Score: 0}},
name: "if exceed limit, use limit (with node which has no images present)",
},
}
for _, test := range tests {