mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Cleanup the default_preemption_test by indexing the potential victim pods
This commit is contained in:
		@@ -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),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user