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

refactor(TestFindDuplicatePods): inline p1 pod creation

This commit is contained in:
Jan Chaloupka
2025-12-14 13:37:23 +01:00
parent 0aee6cff48
commit 180548cc1a

View File

@@ -92,7 +92,6 @@ func TestFindDuplicatePods(t *testing.T) {
node6 := test.BuildTestNode("n6", 200, 200, 10, nil)
// Three Pods in the "dev" Namespace, bound to same ReplicaSet. 2 should be evicted.
p1 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil)
p2 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil)
p3 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p3", "dev", nil)
// A DaemonSet.
@@ -183,13 +182,19 @@ func TestFindDuplicatePods(t *testing.T) {
}{
{
description: "Three pods in the `dev` Namespace, bound to same ReplicaSet. 1 should be evicted.",
pods: []*v1.Pod{p1, p2, p3},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 1,
},
{
description: "Three pods in the `dev` Namespace, bound to same ReplicaSet, but ReplicaSet kind is excluded. 0 should be evicted.",
pods: []*v1.Pod{p1, p2, p3},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 0,
excludeOwnerKinds: []string{"ReplicaSet"},
@@ -202,7 +207,10 @@ func TestFindDuplicatePods(t *testing.T) {
},
{
description: "Three Pods in the `dev` Namespace, three Pods in the `test` Namespace. Bound to ReplicaSet with same name. 4 should be evicted.",
pods: []*v1.Pod{p1, p2, p3, p8, p9, p10},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p8, p9, p10,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 2,
},
@@ -214,7 +222,10 @@ func TestFindDuplicatePods(t *testing.T) {
},
{
description: "Test all Pods: 4 should be evicted.",
pods: []*v1.Pod{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p4, p5, p6, p7, p8, p9, p10,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 2,
},
@@ -238,7 +249,10 @@ func TestFindDuplicatePods(t *testing.T) {
},
{
description: "Three pods in the `dev` Namespace, bound to same ReplicaSet. Only node available has a taint, and nodeFit set to true. 0 should be evicted.",
pods: []*v1.Pod{p1, p2, p3},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
},
nodes: []*v1.Node{node1, node3},
expectedEvictedPodCount: 0,
nodefit: true,
@@ -252,21 +266,30 @@ func TestFindDuplicatePods(t *testing.T) {
},
{
description: "Three pods in the `node-fit` Namespace, bound to same ReplicaSet. Only node available is not schedulable, and nodeFit set to true. 0 should be evicted.",
pods: []*v1.Pod{p1, p2, p3},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
},
nodes: []*v1.Node{node1, node5},
expectedEvictedPodCount: 0,
nodefit: true,
},
{
description: "Three pods in the `node-fit` Namespace, bound to same ReplicaSet. Only node available does not have enough CPU, and nodeFit set to true. 0 should be evicted.",
pods: []*v1.Pod{p1, p2, p3, p19},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p19,
},
nodes: []*v1.Node{node1, node6},
expectedEvictedPodCount: 0,
nodefit: true,
},
{
description: "Three pods in the `node-fit` Namespace, bound to same ReplicaSet. Only node available has enough CPU, and nodeFit set to true. 1 should be evicted.",
pods: []*v1.Pod{p1, p2, p3, p20},
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p20,
},
nodes: []*v1.Node{node1, node6},
expectedEvictedPodCount: 1,
nodefit: true,