Skip to content

Commit b5f25c4

Browse files
committed
add an integration test when nodeAffinity specifies a non-existent node.
1 parent d6d1e6a commit b5f25c4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/integration/scheduler/scheduler_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,33 @@ func TestSchedulerInformers(t *testing.T) {
480480
}),
481481
preemptedPodIndexes: map[int]struct{}{2: {}},
482482
},
483+
{
484+
name: "The pod cannot be scheduled when nodeAffinity specifies a non-existent node.",
485+
nodes: []*nodeConfig{{name: "node-1", res: defaultNodeRes}},
486+
existingPods: []*v1.Pod{},
487+
pod: testutils.InitPausePod(&testutils.PausePodConfig{
488+
Name: "unschedulable-pod",
489+
Namespace: testCtx.NS.Name,
490+
Affinity: &v1.Affinity{
491+
NodeAffinity: &v1.NodeAffinity{
492+
RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{
493+
NodeSelectorTerms: []v1.NodeSelectorTerm{
494+
{
495+
MatchFields: []v1.NodeSelectorRequirement{
496+
{
497+
Key: "metadata.name",
498+
Operator: v1.NodeSelectorOpIn,
499+
Values: []string{"invalid-node"},
500+
},
501+
},
502+
},
503+
},
504+
},
505+
},
506+
},
507+
Resources: defaultPodRes,
508+
}),
509+
},
483510
}
484511

485512
for _, test := range tests {

0 commit comments

Comments
 (0)