@@ -355,6 +355,65 @@ func testGetNextUpgradePods(t *testing.T, factoryPods FactoryPods, factorySideca
355
355
exceptNeedUpgradeCount : 0 ,
356
356
exceptNotUpgradableCount : 100 ,
357
357
},
358
+ {
359
+ name : "only maxUnavailable(5%), and pods(count=5, upgraded=0, upgradedAndReady=0)" ,
360
+ getPods : func () []* corev1.Pod {
361
+ pods := factoryPods (5 , 0 , 0 )
362
+ return Random (pods )
363
+ },
364
+ getSidecarset : func () * appsv1alpha1.SidecarSet {
365
+ sidecarSet := factorySidecar ()
366
+ sidecarSet .Spec .UpdateStrategy .MaxUnavailable = & intstr.IntOrString {
367
+ Type : intstr .String ,
368
+ StrVal : "5%" ,
369
+ }
370
+ return sidecarSet
371
+ },
372
+ exceptNeedUpgradeCount : 1 ,
373
+ exceptNotUpgradableCount : 0 ,
374
+ },
375
+ {
376
+ name : "maxUnavailable(5) partition(99%), and pods(count=5, upgraded=0, upgradedAndReady=0)" ,
377
+ getPods : func () []* corev1.Pod {
378
+ pods := factoryPods (5 , 0 , 0 )
379
+ return Random (pods )
380
+ },
381
+ getSidecarset : func () * appsv1alpha1.SidecarSet {
382
+ sidecarSet := factorySidecar ()
383
+ sidecarSet .Spec .UpdateStrategy .MaxUnavailable = & intstr.IntOrString {
384
+ Type : intstr .Int ,
385
+ IntVal : 5 ,
386
+ }
387
+ sidecarSet .Spec .UpdateStrategy .Partition = & intstr.IntOrString {
388
+ Type : intstr .String ,
389
+ StrVal : "99%" ,
390
+ }
391
+ return sidecarSet
392
+ },
393
+ exceptNeedUpgradeCount : 1 ,
394
+ exceptNotUpgradableCount : 0 ,
395
+ },
396
+ {
397
+ name : "maxUnavailable(5) partition(1%), and pods(count=5, upgraded=0, upgradedAndReady=0)" ,
398
+ getPods : func () []* corev1.Pod {
399
+ pods := factoryPods (5 , 0 , 0 )
400
+ return Random (pods )
401
+ },
402
+ getSidecarset : func () * appsv1alpha1.SidecarSet {
403
+ sidecarSet := factorySidecar ()
404
+ sidecarSet .Spec .UpdateStrategy .MaxUnavailable = & intstr.IntOrString {
405
+ Type : intstr .Int ,
406
+ IntVal : 5 ,
407
+ }
408
+ sidecarSet .Spec .UpdateStrategy .Partition = & intstr.IntOrString {
409
+ Type : intstr .String ,
410
+ StrVal : "1%" ,
411
+ }
412
+ return sidecarSet
413
+ },
414
+ exceptNeedUpgradeCount : 4 ,
415
+ exceptNotUpgradableCount : 0 ,
416
+ },
358
417
}
359
418
strategy := NewStrategy ()
360
419
for _ , cs := range cases {
0 commit comments