From 452b1ff7d9b60b894495275bd93e22a838239822 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Mon, 15 Dec 2025 17:46:54 +0100 Subject: [PATCH] refactor(node_taint_test): add SetPodVolumes and withLocalStorageVolume helpers --- .../node_taint_test.go | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go index 054da381f..d48938859 100644 --- a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go +++ b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go @@ -126,6 +126,20 @@ func withTestTaintToleration1(pod *v1.Pod) { addTolerationToPod(pod, "testTaint", "test", 1, v1.TaintEffectNoSchedule) } +func withLocalStorageVolume(pod *v1.Pod) { + pod.Spec.Volumes = []v1.Volume{ + { + Name: "sample", + VolumeSource: v1.VolumeSource{ + HostPath: &v1.HostPathVolumeSource{Path: "somePath"}, + EmptyDir: &v1.EmptyDirVolumeSource{ + SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI), + }, + }, + }, + } +} + func TestDeletePodsViolatingNodeTaints(t *testing.T) { p1 := buildTestPodWithNormalOwnerRef("p1", nodeName1, withTestTaintToleration1) p2 := buildTestPodWithNormalOwnerRef("p2", nodeName1, nil) @@ -140,19 +154,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) { test.SetPodPriority(pod, utils.SystemCriticalPriority) }) p8 := buildTestPod("p8", nodeName2, test.SetDSOwnerRef) - p9 := buildTestPodWithNormalOwnerRef("p9", nodeName2, func(pod *v1.Pod) { - pod.Spec.Volumes = []v1.Volume{ - { - Name: "sample", - VolumeSource: v1.VolumeSource{ - HostPath: &v1.HostPathVolumeSource{Path: "somePath"}, - EmptyDir: &v1.EmptyDirVolumeSource{ - SizeLimit: resource.NewQuantity(int64(10), resource.BinarySI), - }, - }, - }, - } - }) + p9 := buildTestPodWithNormalOwnerRef("p9", nodeName2, withLocalStorageVolume) p10 := buildTestPodWithNormalOwnerRef("p10", nodeName2, test.SetMirrorPodAnnotation) p11 := buildTestPodWithNormalOwnerRef("p11", nodeName2, nil) p12 := buildTestPodWithNormalOwnerRef("p11", nodeName2, func(pod *v1.Pod) {