1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-28 06:29:29 +01:00

refactor(TestPodAntiAffinity): inline p1

This commit is contained in:
Jan Chaloupka
2025-12-15 13:48:01 +01:00
parent a400a66d51
commit 87f675a2cd

View File

@@ -117,7 +117,6 @@ func buildTestPodNonEvictableForNode1() *v1.Pod {
func TestPodAntiAffinity(t *testing.T) { func TestPodAntiAffinity(t *testing.T) {
p1 := buildTestPodP1ForNode1()
p2 := buildTestPodP2ForNode1() p2 := buildTestPodP2ForNode1()
p3 := buildTestPodP3ForNode1() p3 := buildTestPodP3ForNode1()
p4 := buildTestPodP4ForNode1() p4 := buildTestPodP4ForNode1()
@@ -176,7 +175,9 @@ func TestPodAntiAffinity(t *testing.T) {
}{ }{
{ {
description: "Maximum pods to evict - 0", description: "Maximum pods to evict - 0",
pods: []*v1.Pod{p1, p2, p3, p4}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
p2, p3, p4},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
}, },
@@ -185,7 +186,9 @@ func TestPodAntiAffinity(t *testing.T) {
{ {
description: "Maximum pods to evict - 3", description: "Maximum pods to evict - 3",
maxPodsToEvictPerNode: &uint3, maxPodsToEvictPerNode: &uint3,
pods: []*v1.Pod{p1, p2, p3, p4}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
p2, p3, p4},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
}, },
@@ -194,7 +197,9 @@ func TestPodAntiAffinity(t *testing.T) {
{ {
description: "Maximum pods to evict (maxPodsToEvictPerNamespace=3) - 3", description: "Maximum pods to evict (maxPodsToEvictPerNamespace=3) - 3",
maxNoOfPodsToEvictPerNamespace: &uint3, maxNoOfPodsToEvictPerNamespace: &uint3,
pods: []*v1.Pod{p1, p2, p3, p4}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
p2, p3, p4},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
}, },
@@ -204,7 +209,9 @@ func TestPodAntiAffinity(t *testing.T) {
description: "Maximum pods to evict (maxNoOfPodsToEvictTotal)", description: "Maximum pods to evict (maxNoOfPodsToEvictTotal)",
maxNoOfPodsToEvictPerNamespace: &uint3, maxNoOfPodsToEvictPerNamespace: &uint3,
maxNoOfPodsToEvictTotal: &uint1, maxNoOfPodsToEvictTotal: &uint1,
pods: []*v1.Pod{p1, p2, p3, p4}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
p2, p3, p4},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
}, },
@@ -221,7 +228,9 @@ func TestPodAntiAffinity(t *testing.T) {
{ {
description: "Evicts pod that conflicts with critical pod (but does not evict critical pod)", description: "Evicts pod that conflicts with critical pod (but does not evict critical pod)",
maxPodsToEvictPerNode: &uint1, maxPodsToEvictPerNode: &uint1,
pods: []*v1.Pod{p1, nonEvictablePod}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
nonEvictablePod},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
}, },
@@ -230,7 +239,9 @@ func TestPodAntiAffinity(t *testing.T) {
{ {
description: "Evicts pod that conflicts with critical pod (but does not evict critical pod)", description: "Evicts pod that conflicts with critical pod (but does not evict critical pod)",
maxPodsToEvictPerNode: &uint1, maxPodsToEvictPerNode: &uint1,
pods: []*v1.Pod{p1, nonEvictablePod}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
nonEvictablePod},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
}, },
@@ -277,7 +288,9 @@ func TestPodAntiAffinity(t *testing.T) {
{ {
description: "Won't evict pods because only other node doesn't have enough resources", description: "Won't evict pods because only other node doesn't have enough resources",
maxPodsToEvictPerNode: &uint3, maxPodsToEvictPerNode: &uint3,
pods: []*v1.Pod{p1, p2, p3, p4}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
p2, p3, p4},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
test.BuildTestNode(nodeName4, 2, 2, 1, nil), test.BuildTestNode(nodeName4, 2, 2, 1, nil),
@@ -287,7 +300,9 @@ func TestPodAntiAffinity(t *testing.T) {
}, },
{ {
description: "Evict pod violating anti-affinity among different node (all pods have anti-affinity)", description: "Evict pod violating anti-affinity among different node (all pods have anti-affinity)",
pods: []*v1.Pod{p1, p11}, pods: []*v1.Pod{
buildTestPodP1ForNode1(),
p11},
nodes: []*v1.Node{ nodes: []*v1.Node{
buildTestNode1(), buildTestNode1(),
test.BuildTestNode(nodeName5, 200, 3000, 10, setNodeMainRegionLabel), test.BuildTestNode(nodeName5, 200, 3000, 10, setNodeMainRegionLabel),