mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Cleanup the default_preemption_test by indexing the potential victim pods
This commit is contained in:
parent
818e180300
commit
b3e9d8ef4c
@ -328,21 +328,18 @@ func TestPostFilter(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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)
|
informerFactory := informers.NewSharedInformerFactory(cs, 0)
|
||||||
podInformer := informerFactory.Core().V1().Pods().Informer()
|
podInformer := informerFactory.Core().V1().Pods().Informer()
|
||||||
podInformer.GetStore().Add(tt.pod)
|
podInformer.GetStore().Add(tt.pod)
|
||||||
for i := range tt.pods {
|
for i := range tt.pods {
|
||||||
podInformer.GetStore().Add(tt.pods[i])
|
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.
|
// Register NodeResourceFit as the Filter & PreFilter plugin.
|
||||||
registeredPlugins := []st.RegisterPluginFunc{
|
registeredPlugins := []st.RegisterPluginFunc{
|
||||||
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
st.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
|
Loading…
Reference in New Issue
Block a user