(t *testing.T)
| 571 | } |
| 572 | |
| 573 | func TestApplyUpdateStrategyConfig(t *testing.T) { |
| 574 | testCases := []struct { |
| 575 | description string |
| 576 | ds Daemonset |
| 577 | dsSpec gpuv1.DaemonsetsSpec |
| 578 | errorExpected bool |
| 579 | expectedDs Daemonset |
| 580 | }{ |
| 581 | { |
| 582 | description: "empty daemonset spec configuration", |
| 583 | ds: NewDaemonset(), |
| 584 | dsSpec: gpuv1.DaemonsetsSpec{}, |
| 585 | errorExpected: false, |
| 586 | expectedDs: NewDaemonset(), |
| 587 | }, |
| 588 | { |
| 589 | description: "invalid update strategy string, no rolling update fields configured", |
| 590 | ds: NewDaemonset(), |
| 591 | dsSpec: gpuv1.DaemonsetsSpec{UpdateStrategy: "invalid"}, |
| 592 | errorExpected: false, |
| 593 | expectedDs: NewDaemonset(), |
| 594 | }, |
| 595 | { |
| 596 | description: "RollingUpdate update strategy string, no rolling update fields configured", |
| 597 | ds: NewDaemonset(), |
| 598 | dsSpec: gpuv1.DaemonsetsSpec{UpdateStrategy: "RollingUpdate"}, |
| 599 | errorExpected: false, |
| 600 | expectedDs: NewDaemonset(), |
| 601 | }, |
| 602 | { |
| 603 | description: "RollingUpdate update strategy string, daemonset is driver pod", |
| 604 | ds: NewDaemonset().WithName(commonDriverDaemonsetName), |
| 605 | dsSpec: gpuv1.DaemonsetsSpec{ |
| 606 | UpdateStrategy: "RollingUpdate", |
| 607 | RollingUpdate: &gpuv1.RollingUpdateSpec{ |
| 608 | MaxUnavailable: "1", |
| 609 | }}, |
| 610 | errorExpected: false, |
| 611 | expectedDs: NewDaemonset().WithName(commonDriverDaemonsetName), |
| 612 | }, |
| 613 | { |
| 614 | description: "RollingUpdate update strategy string, integer maxUnavailable", |
| 615 | ds: NewDaemonset(), |
| 616 | dsSpec: gpuv1.DaemonsetsSpec{ |
| 617 | UpdateStrategy: "RollingUpdate", |
| 618 | RollingUpdate: &gpuv1.RollingUpdateSpec{ |
| 619 | MaxUnavailable: "1", |
| 620 | }}, |
| 621 | errorExpected: false, |
| 622 | expectedDs: NewDaemonset().WithUpdateStrategy(appsv1.DaemonSetUpdateStrategy{ |
| 623 | Type: appsv1.RollingUpdateDaemonSetStrategyType, |
| 624 | RollingUpdate: &appsv1.RollingUpdateDaemonSet{MaxUnavailable: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}}, |
| 625 | }), |
| 626 | }, |
| 627 | { |
| 628 | description: "RollingUpdate update strategy string, percentage maxUnavailable", |
| 629 | ds: NewDaemonset(), |
| 630 | dsSpec: gpuv1.DaemonsetsSpec{ |
nothing calls this directly
no test coverage detected