Merge pull request #124669 from gabesaba/test_gated
Add unit test which checks QueuedPodInfo.Gated matches its source
This commit is contained in:
		| @@ -44,6 +44,7 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/features" | 	"k8s.io/kubernetes/pkg/features" | ||||||
| 	"k8s.io/kubernetes/pkg/scheduler/framework" | 	"k8s.io/kubernetes/pkg/scheduler/framework" | ||||||
| 	"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort" | 	"k8s.io/kubernetes/pkg/scheduler/framework/plugins/queuesort" | ||||||
|  | 	"k8s.io/kubernetes/pkg/scheduler/framework/plugins/schedulinggates" | ||||||
| 	"k8s.io/kubernetes/pkg/scheduler/metrics" | 	"k8s.io/kubernetes/pkg/scheduler/metrics" | ||||||
| 	st "k8s.io/kubernetes/pkg/scheduler/testing" | 	st "k8s.io/kubernetes/pkg/scheduler/testing" | ||||||
| 	"k8s.io/kubernetes/pkg/scheduler/util" | 	"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") | ||||||
|  | 	} | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot