Skip to content

Commit ad0bee4

Browse files
committed
Add test case for a pod becoming schedulable when another pod is added
1 parent 06e3aec commit ad0bee4

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

test/integration/scheduler/predicates_test.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,49 @@ func TestUnschedulablePodBecomesSchedulable(t *testing.T) {
11061106
return nil
11071107
},
11081108
},
1109-
// TODO(#91111): Add more test cases.
1109+
{
1110+
name: "pod with pod-affinity gets added",
1111+
init: func(cs kubernetes.Interface, _ string) error {
1112+
node, err := createNode(cs, "node-1", nil)
1113+
if err != nil {
1114+
return fmt.Errorf("cannot create node: %v", err)
1115+
}
1116+
if err := utils.AddLabelsToNode(cs, node.Name, map[string]string{"region": "test"}); err != nil {
1117+
return fmt.Errorf("cannot add labels to node: %v", err)
1118+
}
1119+
return nil
1120+
},
1121+
pod: &pausePodConfig{
1122+
Name: "pod-1",
1123+
Affinity: &v1.Affinity{
1124+
PodAffinity: &v1.PodAffinity{
1125+
RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
1126+
{
1127+
LabelSelector: &metav1.LabelSelector{
1128+
MatchLabels: map[string]string{
1129+
"pod-with-affinity": "true",
1130+
},
1131+
},
1132+
TopologyKey: "region",
1133+
},
1134+
},
1135+
},
1136+
},
1137+
},
1138+
update: func(cs kubernetes.Interface, ns string) error {
1139+
podConfig := &pausePodConfig{
1140+
Name: "pod-with-affinity",
1141+
Namespace: ns,
1142+
Labels: map[string]string{
1143+
"pod-with-affinity": "true",
1144+
},
1145+
}
1146+
if _, err := createPausePod(cs, initPausePod(podConfig)); err != nil {
1147+
return fmt.Errorf("cannot create pod: %v", err)
1148+
}
1149+
return nil
1150+
},
1151+
},
11101152
}
11111153
for _, tt := range tests {
11121154
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)