@@ -1549,8 +1549,6 @@ func Test_Running_agent(t *testing.T) {
15491549 t .Run ("agent_receives_termination_signal_while_waiting_for_all_pods_to_be_terminated" , func (t * testing.T ) {
15501550 t .Parallel ()
15511551
1552- rebootTriggerred := make (chan bool , 1 )
1553-
15541552 podsToCreate := []* corev1.Pod {
15551553 {
15561554 ObjectMeta : metav1.ObjectMeta {
@@ -1568,6 +1566,19 @@ func Test_Running_agent(t *testing.T) {
15681566 fakeClient := fake .NewSimpleClientset (podsToCreate [0 ], testNode ())
15691567 addEvictionSupport (t , fakeClient )
15701568
1569+ podDeletionAttemptCh := make (chan struct {}, 1 )
1570+
1571+ actionF := func (action k8stesting.Action ) (bool , runtime.Object , error ) {
1572+ podDeletionAttemptCh <- struct {}{}
1573+
1574+ // Never actually remove any pod.
1575+ return true , nil , nil
1576+ }
1577+
1578+ fakeClient .PrependReactor ("create" , "pods/eviction" , actionF )
1579+
1580+ rebootTriggerred := make (chan bool , 1 )
1581+
15711582 testConfig , node , _ := validTestConfig (t , testNode ())
15721583 testConfig .Clientset = fakeClient
15731584 testConfig .PodDeletionGracePeriod = 30 * time .Second
@@ -1589,6 +1600,9 @@ func Test_Running_agent(t *testing.T) {
15891600
15901601 okToReboot (ctx , t , testConfig .Clientset .CoreV1 ().Nodes (), node .Name )
15911602
1603+ // Wait until we try to delete a pod.
1604+ <- podDeletionAttemptCh
1605+
15921606 cancel ()
15931607
15941608 select {
@@ -2017,6 +2031,10 @@ func addEvictionSupport(t *testing.T, clientset *fake.Clientset) {
20172031 GroupVersion : "policy/v1" ,
20182032 }
20192033 clientset .Resources = append (clientset .Resources , coreResources , policyResources )
2034+
2035+ clientset .PrependReactor ("create" , "pods" , func (action k8stesting.Action ) (bool , runtime.Object , error ) {
2036+ return action .GetSubresource () == "eviction" , nil , nil
2037+ })
20202038}
20212039
20222040func testPodControllerReference () []metav1.OwnerReference {
0 commit comments