Skip to content

Commit e6f7b35

Browse files
authored
Merge pull request kubernetes#127139 from tozastation/add-test-nodeaffinity-for-queueinghint
add: integration test for NodeAffinity plugin in requeueing scenarios
2 parents 3d17b41 + 0c9828e commit e6f7b35

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/integration/scheduler/queue_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,27 @@ func TestCoreResourceEnqueue(t *testing.T) {
254254
wantRequeuedPods: sets.New("pod2"),
255255
enableSchedulingQueueHint: []bool{false, true},
256256
},
257+
{
258+
name: "Pod rejected by the NodeAffinity plugin is requeued when a Node is updated",
259+
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node1").Label("group", "a").Obj()},
260+
pods: []*v1.Pod{
261+
// - Pod1 will be rejected by the NodeAffinity plugin.
262+
st.MakePod().Name("pod1").NodeAffinityIn("group", []string{"b"}).Container("image").Obj(),
263+
// - Pod2 will be rejected by the NodeAffinity plugin.
264+
st.MakePod().Name("pod2").NodeAffinityIn("group", []string{"c"}).Container("image").Obj(),
265+
},
266+
triggerFn: func(testCtx *testutils.TestContext) error {
267+
// Trigger a NodeUpdate event to change label.
268+
// It causes pod1 to be requeued.
269+
// It causes pod2 not to be requeued.
270+
if _, err := testCtx.ClientSet.CoreV1().Nodes().Update(testCtx.Ctx, st.MakeNode().Name("fake-node1").Label("group", "b").Obj(), metav1.UpdateOptions{}); err != nil {
271+
return fmt.Errorf("failed to remove taints off the node: %w", err)
272+
}
273+
return nil
274+
},
275+
wantRequeuedPods: sets.New("pod1"),
276+
enableSchedulingQueueHint: []bool{false, true},
277+
},
257278
{
258279
name: "Pod updated with toleration requeued to activeQ",
259280
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Capacity(map[v1.ResourceName]string{v1.ResourceCPU: "2"}).Taints([]v1.Taint{{Key: "taint-key", Effect: v1.TaintEffectNoSchedule}}).Obj()},

0 commit comments

Comments
 (0)