@@ -353,9 +353,10 @@ func TestControlPlaneIsScaling(t *testing.T) {
353
353
"replicas" : int64 (2 ),
354
354
},
355
355
"status" : map [string ]interface {}{
356
- "replicas" : int64 (2 ),
357
- "updatedReplicas" : int64 (2 ),
358
- "readyReplicas" : int64 (2 ),
356
+ "replicas" : int64 (2 ),
357
+ "updatedReplicas" : int64 (2 ),
358
+ "readyReplicas" : int64 (2 ),
359
+ "unavailableReplicas" : int64 (0 ),
359
360
},
360
361
}},
361
362
wantScaling : false ,
@@ -370,53 +371,117 @@ func TestControlPlaneIsScaling(t *testing.T) {
370
371
wantScaling : true ,
371
372
},
372
373
{
373
- name : "should return true if status. replicas is not set on control plane" ,
374
+ name : "should return true if status replicas is not set on control plane" ,
374
375
obj : & unstructured.Unstructured {Object : map [string ]interface {}{
375
376
"spec" : map [string ]interface {}{
376
377
"replicas" : int64 (2 ),
377
378
},
378
- "status" : map [string ]interface {}{},
379
+ "status" : map [string ]interface {}{
380
+ "updatedReplicas" : int64 (2 ),
381
+ "readyReplicas" : int64 (2 ),
382
+ "unavailableReplicas" : int64 (0 ),
383
+ },
379
384
}},
380
385
wantScaling : true ,
381
386
},
382
387
{
383
- name : "should return true if spec and status replicas do not match" ,
388
+ name : "should return true if spec replicas and status replicas do not match" ,
384
389
obj : & unstructured.Unstructured {Object : map [string ]interface {}{
385
390
"spec" : map [string ]interface {}{
386
391
"replicas" : int64 (2 ),
387
392
},
388
393
"status" : map [string ]interface {}{
389
- "replicas" : int64 (1 ),
390
- "updatedReplicas" : int64 (2 ),
391
- "readyReplicas" : int64 (2 ),
394
+ "replicas" : int64 (1 ),
395
+ "updatedReplicas" : int64 (2 ),
396
+ "readyReplicas" : int64 (2 ),
397
+ "unavailableReplicas" : int64 (0 ),
392
398
},
393
399
}},
394
400
wantScaling : true ,
395
401
},
396
402
{
397
- name : "should return true if spec and status updatedReplicas do not match " ,
403
+ name : "should return true if status updatedReplicas is not set on control plane " ,
398
404
obj : & unstructured.Unstructured {Object : map [string ]interface {}{
399
405
"spec" : map [string ]interface {}{
400
406
"replicas" : int64 (2 ),
401
407
},
402
408
"status" : map [string ]interface {}{
403
- "replicas" : int64 (2 ),
404
- "updatedReplicas" : int64 (1 ),
405
- "readyReplicas" : int64 (2 ),
409
+ "replicas" : int64 (2 ),
410
+ "readyReplicas" : int64 (2 ),
411
+ "unavailableReplicas" : int64 (0 ),
412
+ },
413
+ }},
414
+ wantScaling : true ,
415
+ },
416
+ {
417
+ name : "should return true if spec replicas and status updatedReplicas do not match" ,
418
+ obj : & unstructured.Unstructured {Object : map [string ]interface {}{
419
+ "spec" : map [string ]interface {}{
420
+ "replicas" : int64 (2 ),
421
+ },
422
+ "status" : map [string ]interface {}{
423
+ "replicas" : int64 (2 ),
424
+ "updatedReplicas" : int64 (1 ),
425
+ "readyReplicas" : int64 (2 ),
426
+ "unavailableReplicas" : int64 (0 ),
406
427
},
407
428
}},
408
429
wantScaling : true ,
409
430
},
410
431
{
411
- name : "should return true if spec and status readyReplicas do not match" ,
432
+ name : "should return true if status readyReplicas is not set on control plane" ,
433
+ obj : & unstructured.Unstructured {Object : map [string ]interface {}{
434
+ "spec" : map [string ]interface {}{
435
+ "replicas" : int64 (2 ),
436
+ },
437
+ "status" : map [string ]interface {}{
438
+ "replicas" : int64 (2 ),
439
+ "updatedReplicas" : int64 (2 ),
440
+ "unavailableReplicas" : int64 (0 ),
441
+ },
442
+ }},
443
+ wantScaling : true ,
444
+ },
445
+ {
446
+ name : "should return true if spec replicas and status readyReplicas do not match" ,
447
+ obj : & unstructured.Unstructured {Object : map [string ]interface {}{
448
+ "spec" : map [string ]interface {}{
449
+ "replicas" : int64 (2 ),
450
+ },
451
+ "status" : map [string ]interface {}{
452
+ "replicas" : int64 (2 ),
453
+ "updatedReplicas" : int64 (2 ),
454
+ "readyReplicas" : int64 (1 ),
455
+ "unavailableReplicas" : int64 (0 ),
456
+ },
457
+ }},
458
+ wantScaling : true ,
459
+ },
460
+ {
461
+ name : "should return false if status unavailableReplicas is not set on control plane" ,
412
462
obj : & unstructured.Unstructured {Object : map [string ]interface {}{
413
463
"spec" : map [string ]interface {}{
414
464
"replicas" : int64 (2 ),
415
465
},
416
466
"status" : map [string ]interface {}{
417
467
"replicas" : int64 (2 ),
418
468
"updatedReplicas" : int64 (2 ),
419
- "readyReplicas" : int64 (1 ),
469
+ "readyReplicas" : int64 (2 ),
470
+ },
471
+ }},
472
+ wantScaling : false ,
473
+ },
474
+ {
475
+ name : "should return true if status unavailableReplicas is > 0" ,
476
+ obj : & unstructured.Unstructured {Object : map [string ]interface {}{
477
+ "spec" : map [string ]interface {}{
478
+ "replicas" : int64 (2 ),
479
+ },
480
+ "status" : map [string ]interface {}{
481
+ "replicas" : int64 (2 ),
482
+ "updatedReplicas" : int64 (2 ),
483
+ "readyReplicas" : int64 (2 ),
484
+ "unavailableReplicas" : int64 (1 ),
420
485
},
421
486
}},
422
487
wantScaling : true ,
0 commit comments