@@ -251,6 +251,26 @@ func TestWorkloadReconciler(t *testing.T) {
251
251
},
252
252
},
253
253
},
254
+ "should update the Workload AdmissionCheckState when the Slice status is changed to Forming" : {
255
+ request : baseRequest ,
256
+ objs : []client.Object {
257
+ baseAdmissionCheckWrapper .DeepCopy (),
258
+ baseWorkloadWrapper .Finalizers (SliceControllerName ).DeepCopy (),
259
+ baseSliceWrapper .Clone ().Forming ().Obj (),
260
+ },
261
+ wantWorkloads : []kueue.Workload {
262
+ * baseWorkloadWrapper .Clone ().
263
+ Finalizers (SliceControllerName ).
264
+ AdmissionCheck (kueue.AdmissionCheckState {
265
+ Name : kueue .AdmissionCheckReference (baseAdmissionCheckName ),
266
+ State : kueue .CheckStatePending ,
267
+ LastTransitionTime : metav1 .NewTime (now ),
268
+ Message : fmt .Sprintf (`The Slice %q is being formed` , baseWorkloadName ),
269
+ }).
270
+ Obj (),
271
+ },
272
+ wantSlices : []slice.Slice {* baseSliceWrapper .Clone ().Forming ().Obj ()},
273
+ },
254
274
"should update the Workload AdmissionCheckState when the Slice status is changed to Ready" : {
255
275
request : baseRequest ,
256
276
objs : []client.Object {
@@ -265,7 +285,7 @@ func TestWorkloadReconciler(t *testing.T) {
265
285
Name : kueue .AdmissionCheckReference (baseAdmissionCheckName ),
266
286
State : kueue .CheckStateReady ,
267
287
LastTransitionTime : metav1 .NewTime (now ),
268
- Message : fmt .Sprintf (`The Slice %q has been created and configured ` , baseWorkloadName ),
288
+ Message : fmt .Sprintf (`The Slice %q is fully operational ` , baseWorkloadName ),
269
289
}).
270
290
Obj (),
271
291
},
@@ -279,6 +299,90 @@ func TestWorkloadReconciler(t *testing.T) {
279
299
},
280
300
},
281
301
},
302
+ "should update the Workload AdmissionCheckState when the Slice status is changed to Degraded" : {
303
+ request : baseRequest ,
304
+ objs : []client.Object {
305
+ baseAdmissionCheckWrapper .DeepCopy (),
306
+ baseWorkloadWrapper .Finalizers (SliceControllerName ).DeepCopy (),
307
+ baseSliceWrapper .Clone ().Degraded ().Obj (),
308
+ },
309
+ wantWorkloads : []kueue.Workload {
310
+ * baseWorkloadWrapper .Clone ().
311
+ Finalizers (SliceControllerName ).
312
+ AdmissionCheck (kueue.AdmissionCheckState {
313
+ Name : kueue .AdmissionCheckReference (baseAdmissionCheckName ),
314
+ State : kueue .CheckStateReady ,
315
+ LastTransitionTime : metav1 .NewTime (now ),
316
+ Message : fmt .Sprintf (`The Slice %q is running with reduced capacity or performance` , baseWorkloadName ),
317
+ }).
318
+ Obj (),
319
+ },
320
+ wantSlices : []slice.Slice {* baseSliceWrapper .Clone ().Degraded ().Obj ()},
321
+ wantEvents : []utiltesting.EventRecord {
322
+ {
323
+ Key : client .ObjectKeyFromObject (baseWorkloadWrapper ),
324
+ EventType : corev1 .EventTypeNormal ,
325
+ Reason : AdmissionCheckUpdatedEventType ,
326
+ Message : fmt .Sprintf (`Admission check %q updated state from "Pending" to "Ready"` , baseAdmissionCheckName ),
327
+ },
328
+ },
329
+ },
330
+ "should update the Workload AdmissionCheckState when the Slice status is changed to Deformed" : {
331
+ request : baseRequest ,
332
+ objs : []client.Object {
333
+ baseAdmissionCheckWrapper .DeepCopy (),
334
+ baseWorkloadWrapper .Finalizers (SliceControllerName ).DeepCopy (),
335
+ baseSliceWrapper .Clone ().Deformed ().Obj (),
336
+ },
337
+ wantWorkloads : []kueue.Workload {
338
+ * baseWorkloadWrapper .Clone ().
339
+ Finalizers (SliceControllerName ).
340
+ AdmissionCheck (kueue.AdmissionCheckState {
341
+ Name : kueue .AdmissionCheckReference (baseAdmissionCheckName ),
342
+ State : kueue .CheckStateRejected ,
343
+ LastTransitionTime : metav1 .NewTime (now ),
344
+ Message : fmt .Sprintf (`The Slice %q is being torn down` , baseWorkloadName ),
345
+ }).
346
+ Obj (),
347
+ },
348
+ wantSlices : []slice.Slice {* baseSliceWrapper .Clone ().Deformed ().Obj ()},
349
+ wantEvents : []utiltesting.EventRecord {
350
+ {
351
+ Key : client .ObjectKeyFromObject (baseWorkloadWrapper ),
352
+ EventType : corev1 .EventTypeNormal ,
353
+ Reason : AdmissionCheckUpdatedEventType ,
354
+ Message : fmt .Sprintf (`Admission check %q updated state from "Pending" to "Rejected"` , baseAdmissionCheckName ),
355
+ },
356
+ },
357
+ },
358
+ "should update the Workload AdmissionCheckState when the Slice status is changed to Error" : {
359
+ request : baseRequest ,
360
+ objs : []client.Object {
361
+ baseAdmissionCheckWrapper .DeepCopy (),
362
+ baseWorkloadWrapper .Finalizers (SliceControllerName ).DeepCopy (),
363
+ baseSliceWrapper .Clone ().Error ().Obj (),
364
+ },
365
+ wantWorkloads : []kueue.Workload {
366
+ * baseWorkloadWrapper .Clone ().
367
+ Finalizers (SliceControllerName ).
368
+ AdmissionCheck (kueue.AdmissionCheckState {
369
+ Name : kueue .AdmissionCheckReference (baseAdmissionCheckName ),
370
+ State : kueue .CheckStateRejected ,
371
+ LastTransitionTime : metav1 .NewTime (now ),
372
+ Message : fmt .Sprintf (`The Slice %q is not operational due to an error: Error by test` , baseWorkloadName ),
373
+ }).
374
+ Obj (),
375
+ },
376
+ wantSlices : []slice.Slice {* baseSliceWrapper .Clone ().Error ().Obj ()},
377
+ wantEvents : []utiltesting.EventRecord {
378
+ {
379
+ Key : client .ObjectKeyFromObject (baseWorkloadWrapper ),
380
+ EventType : corev1 .EventTypeNormal ,
381
+ Reason : AdmissionCheckUpdatedEventType ,
382
+ Message : fmt .Sprintf (`Admission check %q updated state from "Pending" to "Rejected"` , baseAdmissionCheckName ),
383
+ },
384
+ },
385
+ },
282
386
"should use the first AdmissionCheck if more than one is found" : {
283
387
request : baseRequest ,
284
388
objs : []client.Object {
@@ -294,7 +398,7 @@ func TestWorkloadReconciler(t *testing.T) {
294
398
Name : kueue .AdmissionCheckReference (baseAdmissionCheckName ),
295
399
State : kueue .CheckStateReady ,
296
400
LastTransitionTime : metav1 .NewTime (now ),
297
- Message : fmt .Sprintf (`The Slice %q has been created and configured ` , baseWorkloadName ),
401
+ Message : fmt .Sprintf (`The Slice %q is fully operational ` , baseWorkloadName ),
298
402
}).
299
403
Obj (),
300
404
},
0 commit comments