@@ -733,6 +733,34 @@ func TestTaintBasedEvictions(t *testing.T) {
733
733
t .Errorf ("Failed to create node, err: %v" , err )
734
734
}
735
735
}
736
+
737
+ // Regularly send heartbeat event to APIServer so that the cluster doesn't enter fullyDisruption mode.
738
+ // TODO(Huang-Wei): use "NodeDisruptionExclusion" feature to simply the below logic when it's beta.
739
+ var heartbeatChans []chan struct {}
740
+ for i := 0 ; i < nodeCount ; i ++ {
741
+ heartbeatChans = append (heartbeatChans , make (chan struct {}))
742
+ }
743
+ for i := 0 ; i < nodeCount ; i ++ {
744
+ // Spin up <nodeCount> goroutines to send heartbeat event to APIServer periodically.
745
+ go func (i int ) {
746
+ for {
747
+ select {
748
+ case <- heartbeatChans [i ]:
749
+ return
750
+ case <- time .Tick (2 * time .Second ):
751
+ nodes [i ].Status .Conditions = []v1.NodeCondition {
752
+ {
753
+ Type : v1 .NodeReady ,
754
+ Status : v1 .ConditionTrue ,
755
+ LastHeartbeatTime : metav1 .Now (),
756
+ },
757
+ }
758
+ updateNodeStatus (cs , nodes [i ])
759
+ }
760
+ }
761
+ }(i )
762
+ }
763
+
736
764
neededNode := nodes [1 ]
737
765
if test .pod != nil {
738
766
test .pod .Name = fmt .Sprintf ("testpod-%d" , i )
@@ -759,6 +787,13 @@ func TestTaintBasedEvictions(t *testing.T) {
759
787
}
760
788
}
761
789
790
+ for i := 0 ; i < nodeCount ; i ++ {
791
+ // Stop the neededNode's heartbeat goroutine.
792
+ if neededNode .Name == fmt .Sprintf ("node-%d" , i ) {
793
+ heartbeatChans [i ] <- struct {}{}
794
+ break
795
+ }
796
+ }
762
797
neededNode .Status .Conditions = test .nodeConditions
763
798
// Update node condition.
764
799
err = updateNodeStatus (cs , neededNode )
@@ -788,6 +823,10 @@ func TestTaintBasedEvictions(t *testing.T) {
788
823
}
789
824
cleanupPods (cs , t , []* v1.Pod {test .pod })
790
825
}
826
+ // Close all heartbeat channels.
827
+ for i := 0 ; i < nodeCount ; i ++ {
828
+ close (heartbeatChans [i ])
829
+ }
791
830
cleanupNodes (cs , t )
792
831
waitForSchedulerCacheCleanup (context .scheduler , t )
793
832
})
0 commit comments