diff --git a/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go b/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go index cec8f0dd734..b67341a3cc5 100644 --- a/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go +++ b/pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go @@ -328,21 +328,18 @@ func TestPostFilter(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cs := clientsetfake.NewSimpleClientset() + // index the potential victim pods in the fake client so that the victims deletion logic does not fail + podItems := []v1.Pod{} + for _, pod := range tt.pods { + podItems = append(podItems, *pod) + } + cs := clientsetfake.NewSimpleClientset(&v1.PodList{Items: podItems}) informerFactory := informers.NewSharedInformerFactory(cs, 0) podInformer := informerFactory.Core().V1().Pods().Informer() podInformer.GetStore().Add(tt.pod) for i := range tt.pods { podInformer.GetStore().Add(tt.pods[i]) } - // As we use a bare clientset above, it's needed to add a reactor here - // to not fail Victims deletion logic. - cs.PrependReactor("patch", "pods", func(action clienttesting.Action) (bool, runtime.Object, error) { - return true, nil, nil - }) - cs.PrependReactor("delete", "pods", func(action clienttesting.Action) (bool, runtime.Object, error) { - return true, nil, nil - }) // Register NodeResourceFit as the Filter & PreFilter plugin. registeredPlugins := []st.RegisterPluginFunc{ st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),