@@ -21,6 +21,8 @@ import (
21
21
"testing"
22
22
23
23
"k8s.io/utils/ptr"
24
+
25
+ policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
24
26
)
25
27
26
28
func TestResourceBindingSpec_TargetContains (t * testing.T ) {
@@ -172,6 +174,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
172
174
},
173
175
EvictEvent : GracefulEvictionTask {
174
176
FromCluster : "m1" ,
177
+ PurgeMode : policyv1alpha1 .Immediately ,
175
178
Reason : EvictionReasonTaintUntolerated ,
176
179
Message : "graceful eviction" ,
177
180
Producer : EvictionProducerTaintManager ,
@@ -181,6 +184,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
181
184
GracefulEvictionTasks : []GracefulEvictionTask {
182
185
{
183
186
FromCluster : "m1" ,
187
+ PurgeMode : policyv1alpha1 .Immediately ,
184
188
Replicas : ptr.To [int32 ](1 ),
185
189
Reason : EvictionReasonTaintUntolerated ,
186
190
Message : "graceful eviction" ,
@@ -196,6 +200,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
196
200
},
197
201
EvictEvent : GracefulEvictionTask {
198
202
FromCluster : "m2" ,
203
+ PurgeMode : policyv1alpha1 .Never ,
199
204
Reason : EvictionReasonTaintUntolerated ,
200
205
Message : "graceful eviction" ,
201
206
Producer : EvictionProducerTaintManager ,
@@ -205,6 +210,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
205
210
GracefulEvictionTasks : []GracefulEvictionTask {
206
211
{
207
212
FromCluster : "m2" ,
213
+ PurgeMode : policyv1alpha1 .Never ,
208
214
Replicas : ptr.To [int32 ](2 ),
209
215
Reason : EvictionReasonTaintUntolerated ,
210
216
Message : "graceful eviction" ,
@@ -220,6 +226,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
220
226
},
221
227
EvictEvent : GracefulEvictionTask {
222
228
FromCluster : "m3" ,
229
+ PurgeMode : policyv1alpha1 .Graciously ,
223
230
Reason : EvictionReasonTaintUntolerated ,
224
231
Message : "graceful eviction" ,
225
232
Producer : EvictionProducerTaintManager ,
@@ -229,6 +236,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
229
236
GracefulEvictionTasks : []GracefulEvictionTask {
230
237
{
231
238
FromCluster : "m3" ,
239
+ PurgeMode : policyv1alpha1 .Graciously ,
232
240
Replicas : ptr.To [int32 ](3 ),
233
241
Reason : EvictionReasonTaintUntolerated ,
234
242
Message : "graceful eviction" ,
@@ -245,6 +253,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
245
253
},
246
254
EvictEvent : GracefulEvictionTask {
247
255
FromCluster : "m3" ,
256
+ PurgeMode : policyv1alpha1 .Graciously ,
248
257
Reason : EvictionReasonTaintUntolerated ,
249
258
Message : "graceful eviction" ,
250
259
Producer : EvictionProducerTaintManager ,
@@ -257,6 +266,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
257
266
},
258
267
{
259
268
FromCluster : "m3" ,
269
+ PurgeMode : policyv1alpha1 .Graciously ,
260
270
Replicas : ptr.To [int32 ](3 ),
261
271
Reason : EvictionReasonTaintUntolerated ,
262
272
Message : "graceful eviction" ,
@@ -286,6 +296,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
286
296
},
287
297
EvictEvent : GracefulEvictionTask {
288
298
FromCluster : "m1" ,
299
+ PurgeMode : policyv1alpha1 .Graciously ,
289
300
Replicas : ptr.To [int32 ](1 ),
290
301
Reason : EvictionReasonTaintUntolerated ,
291
302
Message : "graceful eviction v2" ,
@@ -309,7 +320,11 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
309
320
for _ , test := range tests {
310
321
tc := test
311
322
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 )))
313
328
314
329
if ! reflect .DeepEqual (tc .InputSpec .Clusters , tc .ExpectSpec .Clusters ) {
315
330
t .Fatalf ("expect clusters: %v, but got: %v" , tc .ExpectSpec .Clusters , tc .InputSpec .Clusters )
0 commit comments