@@ -21,6 +21,8 @@ import (
2121 "testing"
2222
2323 "k8s.io/utils/ptr"
24+
25+ policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
2426)
2527
2628func TestResourceBindingSpec_TargetContains (t * testing.T ) {
@@ -172,6 +174,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
172174 },
173175 EvictEvent : GracefulEvictionTask {
174176 FromCluster : "m1" ,
177+ PurgeMode : policyv1alpha1 .Immediately ,
175178 Reason : EvictionReasonTaintUntolerated ,
176179 Message : "graceful eviction" ,
177180 Producer : EvictionProducerTaintManager ,
@@ -181,6 +184,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
181184 GracefulEvictionTasks : []GracefulEvictionTask {
182185 {
183186 FromCluster : "m1" ,
187+ PurgeMode : policyv1alpha1 .Immediately ,
184188 Replicas : ptr.To [int32 ](1 ),
185189 Reason : EvictionReasonTaintUntolerated ,
186190 Message : "graceful eviction" ,
@@ -196,6 +200,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
196200 },
197201 EvictEvent : GracefulEvictionTask {
198202 FromCluster : "m2" ,
203+ PurgeMode : policyv1alpha1 .Never ,
199204 Reason : EvictionReasonTaintUntolerated ,
200205 Message : "graceful eviction" ,
201206 Producer : EvictionProducerTaintManager ,
@@ -205,6 +210,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
205210 GracefulEvictionTasks : []GracefulEvictionTask {
206211 {
207212 FromCluster : "m2" ,
213+ PurgeMode : policyv1alpha1 .Never ,
208214 Replicas : ptr.To [int32 ](2 ),
209215 Reason : EvictionReasonTaintUntolerated ,
210216 Message : "graceful eviction" ,
@@ -220,6 +226,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
220226 },
221227 EvictEvent : GracefulEvictionTask {
222228 FromCluster : "m3" ,
229+ PurgeMode : policyv1alpha1 .Graciously ,
223230 Reason : EvictionReasonTaintUntolerated ,
224231 Message : "graceful eviction" ,
225232 Producer : EvictionProducerTaintManager ,
@@ -229,6 +236,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
229236 GracefulEvictionTasks : []GracefulEvictionTask {
230237 {
231238 FromCluster : "m3" ,
239+ PurgeMode : policyv1alpha1 .Graciously ,
232240 Replicas : ptr.To [int32 ](3 ),
233241 Reason : EvictionReasonTaintUntolerated ,
234242 Message : "graceful eviction" ,
@@ -245,6 +253,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
245253 },
246254 EvictEvent : GracefulEvictionTask {
247255 FromCluster : "m3" ,
256+ PurgeMode : policyv1alpha1 .Graciously ,
248257 Reason : EvictionReasonTaintUntolerated ,
249258 Message : "graceful eviction" ,
250259 Producer : EvictionProducerTaintManager ,
@@ -257,6 +266,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
257266 },
258267 {
259268 FromCluster : "m3" ,
269+ PurgeMode : policyv1alpha1 .Graciously ,
260270 Replicas : ptr.To [int32 ](3 ),
261271 Reason : EvictionReasonTaintUntolerated ,
262272 Message : "graceful eviction" ,
@@ -286,6 +296,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
286296 },
287297 EvictEvent : GracefulEvictionTask {
288298 FromCluster : "m1" ,
299+ PurgeMode : policyv1alpha1 .Graciously ,
289300 Replicas : ptr.To [int32 ](1 ),
290301 Reason : EvictionReasonTaintUntolerated ,
291302 Message : "graceful eviction v2" ,
@@ -309,7 +320,11 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
309320 for _ , test := range tests {
310321 tc := test
311322 t .Run (tc .Name , func (t * testing.T ) {
312- tc .InputSpec .GracefulEvictCluster (tc .EvictEvent .FromCluster , NewTaskOptions (WithProducer (tc .EvictEvent .Producer ), WithReason (tc .EvictEvent .Reason ), WithMessage (tc .EvictEvent .Message )))
323+ tc .InputSpec .GracefulEvictCluster (tc .EvictEvent .FromCluster , NewTaskOptions (
324+ WithPurgeMode (tc .EvictEvent .PurgeMode ),
325+ WithProducer (tc .EvictEvent .Producer ),
326+ WithReason (tc .EvictEvent .Reason ),
327+ WithMessage (tc .EvictEvent .Message )))
313328
314329 if ! reflect .DeepEqual (tc .InputSpec .Clusters , tc .ExpectSpec .Clusters ) {
315330 t .Fatalf ("expect clusters: %v, but got: %v" , tc .ExpectSpec .Clusters , tc .InputSpec .Clusters )
0 commit comments