Skip to content

Commit de662bb

Browse files
authored
Merge pull request kubernetes#124669 from gabesaba/test_gated
Add unit test which checks QueuedPodInfo.Gated matches its source
2 parents d0e78ef + 9a8197d commit de662bb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pkg/scheduler/internal/queue/scheduling_queue_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"k8s.io/kubernetes/pkg/features"
4545
"k8s.io/kubernetes/pkg/scheduler/framework"
4646
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
47+
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/schedulinggates"
4748
"k8s.io/kubernetes/pkg/scheduler/metrics"
4849
st "k8s.io/kubernetes/pkg/scheduler/testing"
4950
"k8s.io/kubernetes/pkg/scheduler/util"
@@ -3729,3 +3730,30 @@ func Test_isPodWorthRequeuing(t *testing.T) {
37293730
})
37303731
}
37313732
}
3733+
3734+
func Test_queuedPodInfo_gatedSetUponCreationAndUnsetUponUpdate(t *testing.T) {
3735+
logger, ctx := ktesting.NewTestContext(t)
3736+
plugin, _ := schedulinggates.New(ctx, nil, nil)
3737+
m := map[string][]framework.PreEnqueuePlugin{"": {plugin.(framework.PreEnqueuePlugin)}}
3738+
q := NewTestQueue(ctx, newDefaultQueueSort(), WithPreEnqueuePluginMap(m))
3739+
3740+
gatedPod := st.MakePod().SchedulingGates([]string{"hello world"}).Obj()
3741+
if err := q.Add(logger, gatedPod); err != nil {
3742+
t.Error("Error calling Add")
3743+
}
3744+
3745+
if !q.unschedulablePods.get(gatedPod).Gated {
3746+
t.Error("expected pod to be gated")
3747+
}
3748+
3749+
ungatedPod := gatedPod.DeepCopy()
3750+
ungatedPod.Spec.SchedulingGates = nil
3751+
if err := q.Update(logger, gatedPod, ungatedPod); err != nil {
3752+
t.Error("Error calling Update")
3753+
}
3754+
3755+
ungatedPodInfo, _ := q.Pop(logger)
3756+
if ungatedPodInfo.Gated {
3757+
t.Error("expected pod to be ungated")
3758+
}
3759+
}

0 commit comments

Comments
 (0)