mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Run unit test with DSMaxSurgeFlag enabled and disabled
This commit is contained in:
parent
ceeb05a3d7
commit
6f35e1aea0
@ -847,33 +847,37 @@ func TestDaemonSetPodCreateExpectationsError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSimpleDaemonSetUpdatesStatusAfterLaunchingPods(t *testing.T) {
|
func TestSimpleDaemonSetUpdatesStatusAfterLaunchingPods(t *testing.T) {
|
||||||
for _, strategy := range updateStrategies() {
|
dsMaxSurgeFeatureFlags := []bool{false, true}
|
||||||
ds := newDaemonSet("foo")
|
for _, isEnabled := range dsMaxSurgeFeatureFlags {
|
||||||
ds.Spec.UpdateStrategy = *strategy
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DaemonSetUpdateSurge, isEnabled)()
|
||||||
manager, podControl, clientset, err := newTestController(ds)
|
for _, strategy := range updateStrategies() {
|
||||||
if err != nil {
|
ds := newDaemonSet("foo")
|
||||||
t.Fatalf("error creating DaemonSets controller: %v", err)
|
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
|
var updated *apps.DaemonSet
|
||||||
clientset.PrependReactor("update", "daemonsets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
clientset.PrependReactor("update", "daemonsets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
if action.GetSubresource() != "status" {
|
if action.GetSubresource() != "status" {
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
|
if u, ok := action.(core.UpdateAction); ok {
|
||||||
|
updated = u.GetObject().(*apps.DaemonSet)
|
||||||
|
}
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
}
|
})
|
||||||
if u, ok := action.(core.UpdateAction); ok {
|
|
||||||
updated = u.GetObject().(*apps.DaemonSet)
|
|
||||||
}
|
|
||||||
return false, nil, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
manager.dsStore.Add(ds)
|
manager.dsStore.Add(ds)
|
||||||
addNodes(manager.nodeStore, 0, 5, nil)
|
addNodes(manager.nodeStore, 0, 5, nil)
|
||||||
expectSyncDaemonSets(t, manager, ds, podControl, 5, 0, 0)
|
expectSyncDaemonSets(t, manager, ds, podControl, 5, 0, 0)
|
||||||
|
|
||||||
// Make sure the single sync() updated Status already for the change made
|
// Make sure the single sync() updated Status already for the change made
|
||||||
// during the manage() phase.
|
// during the manage() phase.
|
||||||
if got, want := updated.Status.CurrentNumberScheduled, int32(5); got != want {
|
if got, want := updated.Status.CurrentNumberScheduled, int32(5); got != want {
|
||||||
t.Errorf("Status.CurrentNumberScheduled = %v, want %v", got, want)
|
t.Errorf("Status.CurrentNumberScheduled = %v, want %v", got, want)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user