1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

refactor(TestFindDuplicatePods): inline p4 pod creation

This commit is contained in:
Jan Chaloupka
2025-12-14 13:44:24 +01:00
parent 7a5bf8c2f0
commit 9b50aa91f8

View File

@@ -93,9 +93,6 @@ func TestFindDuplicatePods(t *testing.T) {
// Three Pods in the "dev" Namespace, bound to same ReplicaSet. 2 should be evicted. // Three Pods in the "dev" Namespace, bound to same ReplicaSet. 2 should be evicted.
// A DaemonSet. // A DaemonSet.
p4 := buildTestPodForNode1("p4", func(pod *v1.Pod) {
test.SetDSOwnerRef(pod)
})
// A Pod with local storage. // A Pod with local storage.
p5 := buildTestPodForNode1("p5", func(pod *v1.Pod) { p5 := buildTestPodForNode1("p5", func(pod *v1.Pod) {
test.SetNormalOwnerRef(pod) test.SetNormalOwnerRef(pod)
@@ -217,8 +214,13 @@ func TestFindDuplicatePods(t *testing.T) {
expectedEvictedPodCount: 2, expectedEvictedPodCount: 2,
}, },
{ {
description: "Pods are: part of DaemonSet, with local storage, mirror pod annotation, critical pod annotation - none should be evicted.", description: "Pods are: part of DaemonSet, with local storage, mirror pod annotation, critical pod annotation - none should be evicted.",
pods: []*v1.Pod{p4, p5, p6, p7}, pods: []*v1.Pod{
buildTestPodForNode1("p4", func(pod *v1.Pod) {
test.SetDSOwnerRef(pod)
}),
p5, p6, p7,
},
nodes: []*v1.Node{node1, node2}, nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 0, expectedEvictedPodCount: 0,
}, },
@@ -228,7 +230,10 @@ func TestFindDuplicatePods(t *testing.T) {
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil), buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil), buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p3", "dev", nil), buildTestPodWithRSOwnerRefWithNamespaceForNode1("p3", "dev", nil),
p4, p5, p6, p7, p8, p9, p10, buildTestPodForNode1("p4", func(pod *v1.Pod) {
test.SetDSOwnerRef(pod)
}),
p5, p6, p7, p8, p9, p10,
}, },
nodes: []*v1.Node{node1, node2}, nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 2, expectedEvictedPodCount: 2,