@@ -44,6 +44,7 @@ import (
44
44
"k8s.io/kubernetes/pkg/features"
45
45
"k8s.io/kubernetes/pkg/scheduler/framework"
46
46
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort"
47
+ "k8s.io/kubernetes/pkg/scheduler/framework/plugins/schedulinggates"
47
48
"k8s.io/kubernetes/pkg/scheduler/metrics"
48
49
st "k8s.io/kubernetes/pkg/scheduler/testing"
49
50
"k8s.io/kubernetes/pkg/scheduler/util"
@@ -3729,3 +3730,30 @@ func Test_isPodWorthRequeuing(t *testing.T) {
3729
3730
})
3730
3731
}
3731
3732
}
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