Merge pull request #127139 from tozastation/add-test-nodeaffinity-for-queueinghint

add: integration test for NodeAffinity plugin in requeueing scenarios
This commit is contained in:
Kubernetes Prow Robot 2024-09-05 16:04:45 +01:00 committed by GitHub
commit e6f7b35cc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -254,6 +254,27 @@ func TestCoreResourceEnqueue(t *testing.T) {
wantRequeuedPods: sets.New("pod2"),
enableSchedulingQueueHint: []bool{false, true},
},
{
name: "Pod rejected by the NodeAffinity plugin is requeued when a Node is updated",
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node1").Label("group", "a").Obj()},
pods: []*v1.Pod{
// - Pod1 will be rejected by the NodeAffinity plugin.
st.MakePod().Name("pod1").NodeAffinityIn("group", []string{"b"}).Container("image").Obj(),
// - Pod2 will be rejected by the NodeAffinity plugin.
st.MakePod().Name("pod2").NodeAffinityIn("group", []string{"c"}).Container("image").Obj(),
},
triggerFn: func(testCtx *testutils.TestContext) error {
// Trigger a NodeUpdate event to change label.
// It causes pod1 to be requeued.
// It causes pod2 not to be requeued.
if _, err := testCtx.ClientSet.CoreV1().Nodes().Update(testCtx.Ctx, st.MakeNode().Name("fake-node1").Label("group", "b").Obj(), metav1.UpdateOptions{}); err != nil {
return fmt.Errorf("failed to remove taints off the node: %w", err)
}
return nil
},
wantRequeuedPods: sets.New("pod1"),
enableSchedulingQueueHint: []bool{false, true},
},
{
name: "Pod updated with toleration requeued to activeQ",
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()},