1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 21:31:18 +01:00

refactor(TestFindDuplicatePods): inline p2 pod creation

This commit is contained in:
Jan Chaloupka
2025-12-14 13:39:56 +01:00
parent 180548cc1a
commit df06442830

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.
p2 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil)
p3 := buildTestPodWithRSOwnerRefWithNamespaceForNode1("p3", "dev", nil)
// A DaemonSet.
p4 := buildTestPodForNode1("p4", func(pod *v1.Pod) {
@@ -184,7 +183,8 @@ func TestFindDuplicatePods(t *testing.T) {
description: "Three pods in the `dev` Namespace, bound to same ReplicaSet. 1 should be evicted.",
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 1,
@@ -193,7 +193,8 @@ func TestFindDuplicatePods(t *testing.T) {
description: "Three pods in the `dev` Namespace, bound to same ReplicaSet, but ReplicaSet kind is excluded. 0 should be evicted.",
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 0,
@@ -209,7 +210,8 @@ 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{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p8, p9, p10,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3, p8, p9, p10,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 2,
@@ -224,7 +226,8 @@ func TestFindDuplicatePods(t *testing.T) {
description: "Test all Pods: 4 should be evicted.",
pods: []*v1.Pod{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p4, p5, p6, p7, p8, p9, p10,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3, p4, p5, p6, p7, p8, p9, p10,
},
nodes: []*v1.Node{node1, node2},
expectedEvictedPodCount: 2,
@@ -251,7 +254,8 @@ 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{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3,
},
nodes: []*v1.Node{node1, node3},
expectedEvictedPodCount: 0,
@@ -268,7 +272,8 @@ 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{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3,
},
nodes: []*v1.Node{node1, node5},
expectedEvictedPodCount: 0,
@@ -278,7 +283,8 @@ func TestFindDuplicatePods(t *testing.T) {
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{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p19,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3, p19,
},
nodes: []*v1.Node{node1, node6},
expectedEvictedPodCount: 0,
@@ -288,7 +294,8 @@ func TestFindDuplicatePods(t *testing.T) {
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{
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p1", "dev", nil),
p2, p3, p20,
buildTestPodWithRSOwnerRefWithNamespaceForNode1("p2", "dev", nil),
p3, p20,
},
nodes: []*v1.Node{node1, node6},
expectedEvictedPodCount: 1,