mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
refactor: replace pod.Spec.Priority with test.SetPodPriority in plugin tests
This commit is contained in:
@@ -512,7 +512,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPod("p14", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p14", n1.Name, func(pod *v1.Pod) {
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Spec.Priority = &highPriority
|
test.SetPodPriority(pod, highPriority)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
priorityThreshold: &lowPriority,
|
priorityThreshold: &lowPriority,
|
||||||
@@ -523,7 +523,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
buildTestPod("p15", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p15", n1.Name, func(pod *v1.Pod) {
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
setPodEvictAnnotation(pod)
|
setPodEvictAnnotation(pod)
|
||||||
pod.Spec.Priority = &highPriority
|
test.SetPodPriority(pod, highPriority)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
priorityThreshold: &lowPriority,
|
priorityThreshold: &lowPriority,
|
||||||
@@ -557,7 +557,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPod("p17", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p17", n1.Name, func(pod *v1.Pod) {
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Spec.Priority = &highPriority
|
test.SetPodPriority(pod, highPriority)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
evictSystemCriticalPods: true,
|
evictSystemCriticalPods: true,
|
||||||
@@ -570,7 +570,7 @@ func TestDefaultEvictorFilter(t *testing.T) {
|
|||||||
buildTestPod("p17", n1.Name, func(pod *v1.Pod) {
|
buildTestPod("p17", n1.Name, func(pod *v1.Pod) {
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
setPodEvictAnnotation(pod)
|
setPodEvictAnnotation(pod)
|
||||||
pod.Spec.Priority = &highPriority
|
test.SetPodPriority(pod, highPriority)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
evictSystemCriticalPods: true,
|
evictSystemCriticalPods: true,
|
||||||
|
|||||||
@@ -115,8 +115,7 @@ func TestHighNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
// These won't be evicted.
|
// These won't be evicted.
|
||||||
test.BuildTestPod("p3", 400, 0, n2NodeName, test.SetDSOwnerRef),
|
test.BuildTestPod("p3", 400, 0, n2NodeName, test.SetDSOwnerRef),
|
||||||
@@ -168,8 +167,7 @@ func TestHighNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
// These won't be evicted.
|
// These won't be evicted.
|
||||||
test.BuildTestPod("p3", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p3", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
|
|||||||
@@ -109,8 +109,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
test.BuildTestPod("p6", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
test.BuildTestPod("p6", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -172,8 +171,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
test.BuildTestPod("p8", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
test.BuildTestPod("p8", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -250,8 +248,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
test.BuildTestPod("p8", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
test.BuildTestPod("p8", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -328,8 +325,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -397,8 +393,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -480,8 +475,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -561,8 +555,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -651,8 +644,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
test.SetPodExtendedResourceRequest(pod, extendedResource, 1)
|
test.SetPodExtendedResourceRequest(pod, extendedResource, 1)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 0, 0, n2NodeName, func(pod *v1.Pod) {
|
test.BuildTestPod("p9", 0, 0, n2NodeName, func(pod *v1.Pod) {
|
||||||
test.SetRSOwnerRef(pod)
|
test.SetRSOwnerRef(pod)
|
||||||
@@ -813,8 +805,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
nodemetricses: []*v1beta1.NodeMetrics{
|
nodemetricses: []*v1beta1.NodeMetrics{
|
||||||
@@ -890,8 +881,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
nodemetricses: []*v1beta1.NodeMetrics{
|
nodemetricses: []*v1beta1.NodeMetrics{
|
||||||
@@ -993,8 +983,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 0, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 0, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -1055,8 +1044,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -1124,8 +1112,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 3000, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 3000, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -1236,8 +1223,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 0, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 0, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -1299,8 +1285,7 @@ func TestLowNodeUtilization(t *testing.T) {
|
|||||||
test.BuildTestPod("p8", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
test.BuildTestPod("p8", 400, 0, n1NodeName, func(pod *v1.Pod) {
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
test.BuildTestPod("p9", 400, 0, n2NodeName, test.SetRSOwnerRef),
|
||||||
},
|
},
|
||||||
@@ -1594,8 +1579,7 @@ func withCriticalPod(pod *v1.Pod) {
|
|||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
test.SetNormalOwnerRef(pod)
|
test.SetNormalOwnerRef(pod)
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLowNodeUtilizationWithPrometheusMetrics(t *testing.T) {
|
func TestLowNodeUtilizationWithPrometheusMetrics(t *testing.T) {
|
||||||
|
|||||||
@@ -167,8 +167,7 @@ func TestFindDuplicatePods(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
buildTestPodForNode("p7", nodeName1, func(pod *v1.Pod) {
|
buildTestPodForNode("p7", nodeName1, func(pod *v1.Pod) {
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{
|
nodes: []*v1.Node{
|
||||||
@@ -205,8 +204,7 @@ func TestFindDuplicatePods(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
buildTestPodForNode("p7", nodeName1, func(pod *v1.Pod) {
|
buildTestPodForNode("p7", nodeName1, func(pod *v1.Pod) {
|
||||||
pod.Namespace = "kube-system"
|
pod.Namespace = "kube-system"
|
||||||
priority := utils.SystemCriticalPriority
|
test.SetPodPriority(pod, utils.SystemCriticalPriority)
|
||||||
pod.Spec.Priority = &priority
|
|
||||||
}),
|
}),
|
||||||
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p8", "test", nil),
|
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p8", "test", nil),
|
||||||
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p9", "test", nil),
|
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p9", "test", nil),
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func buildTestPodP2ForNode1() *v1.Pod {
|
|||||||
func buildTestPodNonEvictableForNode1() *v1.Pod {
|
func buildTestPodNonEvictableForNode1() *v1.Pod {
|
||||||
criticalPriority := utils.SystemCriticalPriority
|
criticalPriority := utils.SystemCriticalPriority
|
||||||
return buildTestPodForNode1("non-evict", func(pod *v1.Pod) {
|
return buildTestPodForNode1("non-evict", func(pod *v1.Pod) {
|
||||||
pod.Spec.Priority = &criticalPriority
|
test.SetPodPriority(pod, criticalPriority)
|
||||||
setLabelsFooBar(pod)
|
setLabelsFooBar(pod)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user