From 2710fd3781d77c44db23c455a17ffbc0632c233d Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Sat, 13 Dec 2025 13:53:59 +0100 Subject: [PATCH] refactor(TestPodLifeTime): extract evictor configuration tests --- .../plugins/podlifetime/pod_lifetime_test.go | 90 +++++++++++-------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/pkg/framework/plugins/podlifetime/pod_lifetime_test.go b/pkg/framework/plugins/podlifetime/pod_lifetime_test.go index 62ce00491..def1cf800 100644 --- a/pkg/framework/plugins/podlifetime/pod_lifetime_test.go +++ b/pkg/framework/plugins/podlifetime/pod_lifetime_test.go @@ -143,45 +143,6 @@ func runPodLifeTimeTest(t *testing.T, tc podLifeTimeTestCase) { func TestPodLifeTime(t *testing.T) { var maxLifeTime uint = 600 testCases := []podLifeTimeTestCase{ - { - description: "Does not evict pvc pods with ignorePvcPods set to true", - args: &PodLifeTimeArgs{ - MaxPodLifeTimeSeconds: &maxLifeTime, - }, - pods: []*v1.Pod{ - buildTestPodWithRSOwnerRefForNode1("p11", olderPodCreationTime, func(pod *v1.Pod) { - pod.Spec.Volumes = []v1.Volume{ - { - Name: "pvc", VolumeSource: v1.VolumeSource{ - PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: "foo"}, - }, - }, - } - }), - }, - nodes: []*v1.Node{buildTestNode1()}, - expectedEvictedPodCount: 0, - ignorePvcPods: true, - }, - { - description: "Evicts pvc pods with ignorePvcPods set to false (or unset)", - args: &PodLifeTimeArgs{ - MaxPodLifeTimeSeconds: &maxLifeTime, - }, - pods: []*v1.Pod{ - buildTestPodWithRSOwnerRefForNode1("p11", olderPodCreationTime, func(pod *v1.Pod) { - pod.Spec.Volumes = []v1.Volume{ - { - Name: "pvc", VolumeSource: v1.VolumeSource{ - PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: "foo"}, - }, - }, - } - }), - }, - nodes: []*v1.Node{buildTestNode1()}, - expectedEvictedPodCount: 1, - }, { description: "1 pod matching label selector should be evicted", args: &PodLifeTimeArgs{ @@ -230,6 +191,57 @@ func TestPodLifeTime(t *testing.T) { } } +func TestPodLifeTime_EvictorConfiguration(t *testing.T) { + var maxLifeTime uint = 600 + testCases := []podLifeTimeTestCase{ + { + description: "Does not evict pvc pods with ignorePvcPods set to true", + args: &PodLifeTimeArgs{ + MaxPodLifeTimeSeconds: &maxLifeTime, + }, + pods: []*v1.Pod{ + buildTestPodWithRSOwnerRefForNode1("p11", olderPodCreationTime, func(pod *v1.Pod) { + pod.Spec.Volumes = []v1.Volume{ + { + Name: "pvc", VolumeSource: v1.VolumeSource{ + PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: "foo"}, + }, + }, + } + }), + }, + nodes: []*v1.Node{buildTestNode1()}, + expectedEvictedPodCount: 0, + ignorePvcPods: true, + }, + { + description: "Evicts pvc pods with ignorePvcPods set to false (or unset)", + args: &PodLifeTimeArgs{ + MaxPodLifeTimeSeconds: &maxLifeTime, + }, + pods: []*v1.Pod{ + buildTestPodWithRSOwnerRefForNode1("p11", olderPodCreationTime, func(pod *v1.Pod) { + pod.Spec.Volumes = []v1.Volume{ + { + Name: "pvc", VolumeSource: v1.VolumeSource{ + PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: "foo"}, + }, + }, + } + }), + }, + nodes: []*v1.Node{buildTestNode1()}, + expectedEvictedPodCount: 1, + }, + } + + for _, tc := range testCases { + t.Run(tc.description, func(t *testing.T) { + runPodLifeTimeTest(t, tc) + }) + } +} + func TestPodLifeTime_EvictionLimits(t *testing.T) { var maxLifeTime uint = 600 testCases := []podLifeTimeTestCase{