mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Add unit test which checks Gated is set/unset properly
This commit is contained in:
parent
72524fa574
commit
9a8197d0c3
@ -44,6 +44,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/schedulinggates"
|
||||
"k8s.io/kubernetes/pkg/scheduler/metrics"
|
||||
st "k8s.io/kubernetes/pkg/scheduler/testing"
|
||||
"k8s.io/kubernetes/pkg/scheduler/util"
|
||||
@ -3729,3 +3730,30 @@ func Test_isPodWorthRequeuing(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_queuedPodInfo_gatedSetUponCreationAndUnsetUponUpdate(t *testing.T) {
|
||||
logger, ctx := ktesting.NewTestContext(t)
|
||||
plugin, _ := schedulinggates.New(ctx, nil, nil)
|
||||
m := map[string][]framework.PreEnqueuePlugin{"": {plugin.(framework.PreEnqueuePlugin)}}
|
||||
q := NewTestQueue(ctx, newDefaultQueueSort(), WithPreEnqueuePluginMap(m))
|
||||
|
||||
gatedPod := st.MakePod().SchedulingGates([]string{"hello world"}).Obj()
|
||||
if err := q.Add(logger, gatedPod); err != nil {
|
||||
t.Error("Error calling Add")
|
||||
}
|
||||
|
||||
if !q.unschedulablePods.get(gatedPod).Gated {
|
||||
t.Error("expected pod to be gated")
|
||||
}
|
||||
|
||||
ungatedPod := gatedPod.DeepCopy()
|
||||
ungatedPod.Spec.SchedulingGates = nil
|
||||
if err := q.Update(logger, gatedPod, ungatedPod); err != nil {
|
||||
t.Error("Error calling Update")
|
||||
}
|
||||
|
||||
ungatedPodInfo, _ := q.Pop(logger)
|
||||
if ungatedPodInfo.Gated {
|
||||
t.Error("expected pod to be ungated")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user