From 5ad695166adb629880cfba58a417693c4602af35 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Mon, 15 Dec 2025 13:22:12 +0100 Subject: [PATCH] refactor(TestPodAntiAffinity): ensure p7 is created only through apply argument --- .../pod_antiaffinity_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go index 94f4b2b01..23c86c790 100644 --- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go +++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go @@ -93,7 +93,12 @@ func TestPodAntiAffinity(t *testing.T) { test.SetPodAntiAffinity(pod, "foo1", "bar1") test.SetPodPriority(pod, 50) }) - p7 := buildTestPodForNode1("p7", nil) + p7 := buildTestPodForNode1("p7", func(pod *v1.Pod) { + test.SetNormalOwnerRef(pod) + pod.Labels = map[string]string{"foo1": "bar1"} + test.SetPodAntiAffinity(pod, "foo", "bar") + test.SetPodPriority(pod, 0) + }) p8 := buildTestPodForNode1("p8", nil) p9 := buildTestPodForNode1("p9", nil) p10 := buildTestPodForNode1("p10", nil) @@ -105,22 +110,16 @@ func TestPodAntiAffinity(t *testing.T) { nonEvictablePod := buildTestPodForNode1("non-evict", func(pod *v1.Pod) { pod.Spec.Priority = &criticalPriority }) - p7.Labels = map[string]string{"foo1": "bar1"} p11.Labels = map[string]string{"foo": "bar"} nonEvictablePod.Labels = map[string]string{"foo": "bar"} - test.SetNormalOwnerRef(p7) test.SetNormalOwnerRef(p9) test.SetNormalOwnerRef(p10) test.SetNormalOwnerRef(p11) // set pod anti affinity - test.SetPodAntiAffinity(p7, "foo", "bar") test.SetPodAntiAffinity(p9, "foo", "bar") test.SetPodAntiAffinity(p10, "foo", "bar") - // set pod priority - test.SetPodPriority(p7, 0) - // Set pod node selectors p8.Spec.NodeSelector = map[string]string{ "datacenter": "west",