Merge pull request #123575 from Huang-Wei/pod-scheduling-readiness-stable
Graduate PodSchedulingReadiness to stable
This commit is contained in:
@@ -2563,88 +2563,6 @@ func TestDropHostUsers(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestDropSchedulingGates(t *testing.T) {
|
||||
podWithSchedulingGates := func() *api.Pod {
|
||||
return &api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
SchedulingGates: []api.PodSchedulingGate{
|
||||
{Name: "foo"},
|
||||
{Name: "bar"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
podWithoutSchedulingGates := func() *api.Pod { return &api.Pod{} }
|
||||
|
||||
podInfo := []struct {
|
||||
description string
|
||||
hasSchedulingGatesField bool
|
||||
pod func() *api.Pod
|
||||
}{
|
||||
{
|
||||
description: "has SchedulingGates field",
|
||||
hasSchedulingGatesField: true,
|
||||
pod: podWithSchedulingGates,
|
||||
},
|
||||
{
|
||||
description: "does not have SchedulingGates field",
|
||||
hasSchedulingGatesField: false,
|
||||
pod: podWithoutSchedulingGates,
|
||||
},
|
||||
{
|
||||
description: "is nil",
|
||||
hasSchedulingGatesField: false,
|
||||
pod: func() *api.Pod { return nil },
|
||||
},
|
||||
}
|
||||
|
||||
for _, enabled := range []bool{true, false} {
|
||||
for _, oldPodInfo := range podInfo {
|
||||
for _, newPodInfo := range podInfo {
|
||||
oldPodHasSchedulingGates, oldPod := oldPodInfo.hasSchedulingGatesField, oldPodInfo.pod()
|
||||
newPodHasSchedulingGates, newPod := newPodInfo.hasSchedulingGatesField, newPodInfo.pod()
|
||||
if newPod == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
t.Run(fmt.Sprintf("feature enabled=%v, old pod %v, new pod %v", enabled, oldPodInfo.description, newPodInfo.description), func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodSchedulingReadiness, enabled)()
|
||||
var oldPodSpec *api.PodSpec
|
||||
if oldPod != nil {
|
||||
oldPodSpec = &oldPod.Spec
|
||||
}
|
||||
dropDisabledFields(&newPod.Spec, nil, oldPodSpec, nil)
|
||||
// Old Pod should never be changed.
|
||||
if diff := cmp.Diff(oldPod, oldPodInfo.pod()); diff != "" {
|
||||
t.Errorf("old pod changed: %v", diff)
|
||||
}
|
||||
switch {
|
||||
case enabled || oldPodHasSchedulingGates:
|
||||
// New Pod should not be changed if the feature is enabled, or if the old Pod had schedulingGates.
|
||||
if diff := cmp.Diff(newPod, newPodInfo.pod()); diff != "" {
|
||||
t.Errorf("new pod changed: %v", diff)
|
||||
}
|
||||
case newPodHasSchedulingGates:
|
||||
// New Pod should be changed.
|
||||
if reflect.DeepEqual(newPod, newPodInfo.pod()) {
|
||||
t.Errorf("new pod was not changed")
|
||||
}
|
||||
// New Pod should not have SchedulingGates field.
|
||||
if diff := cmp.Diff(newPod, podWithoutSchedulingGates()); diff != "" {
|
||||
t.Errorf("new pod has SchedulingGates field: %v", diff)
|
||||
}
|
||||
default:
|
||||
// New pod should not need to be changed.
|
||||
if diff := cmp.Diff(newPod, newPodInfo.pod()); diff != "" {
|
||||
t.Errorf("new pod changed: %v", diff)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateTopologySpreadConstraintLabelSelectorOption(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
Reference in New Issue
Block a user