Skip to content

Commit

Permalink
Run unit test with DSMaxSurgeFlag enabled and disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisantoshgudimetla committed May 10, 2021
1 parent ceeb05a commit 6f35e1a
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions pkg/controller/daemon/daemon_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,33 +847,37 @@ func TestDaemonSetPodCreateExpectationsError(t *testing.T) {
}

func TestSimpleDaemonSetUpdatesStatusAfterLaunchingPods(t *testing.T) {
for _, strategy := range updateStrategies() {
ds := newDaemonSet("foo")
ds.Spec.UpdateStrategy = *strategy
manager, podControl, clientset, err := newTestController(ds)
if err != nil {
t.Fatalf("error creating DaemonSets controller: %v", err)
}
dsMaxSurgeFeatureFlags := []bool{false, true}
for _, isEnabled := range dsMaxSurgeFeatureFlags {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DaemonSetUpdateSurge, isEnabled)()
for _, strategy := range updateStrategies() {
ds := newDaemonSet("foo")
ds.Spec.UpdateStrategy = *strategy
manager, podControl, clientset, err := newTestController(ds)
if err != nil {
t.Fatalf("error creating DaemonSets controller: %v", err)
}

var updated *apps.DaemonSet
clientset.PrependReactor("update", "daemonsets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
if action.GetSubresource() != "status" {
var updated *apps.DaemonSet
clientset.PrependReactor("update", "daemonsets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
if action.GetSubresource() != "status" {
return false, nil, nil
}
if u, ok := action.(core.UpdateAction); ok {
updated = u.GetObject().(*apps.DaemonSet)
}
return false, nil, nil
}
if u, ok := action.(core.UpdateAction); ok {
updated = u.GetObject().(*apps.DaemonSet)
}
return false, nil, nil
})
})

manager.dsStore.Add(ds)
addNodes(manager.nodeStore, 0, 5, nil)
expectSyncDaemonSets(t, manager, ds, podControl, 5, 0, 0)
manager.dsStore.Add(ds)
addNodes(manager.nodeStore, 0, 5, nil)
expectSyncDaemonSets(t, manager, ds, podControl, 5, 0, 0)

// Make sure the single sync() updated Status already for the change made
// during the manage() phase.
if got, want := updated.Status.CurrentNumberScheduled, int32(5); got != want {
t.Errorf("Status.CurrentNumberScheduled = %v, want %v", got, want)
// Make sure the single sync() updated Status already for the change made
// during the manage() phase.
if got, want := updated.Status.CurrentNumberScheduled, int32(5); got != want {
t.Errorf("Status.CurrentNumberScheduled = %v, want %v", got, want)
}
}
}
}
Expand Down

0 comments on commit 6f35e1a

Please sign in to comment.