mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Add test case for a pod becoming schedulable when another pod is added
This commit is contained in:
parent
06e3aeccc4
commit
ad0bee482e
@ -1106,7 +1106,49 @@ func TestUnschedulablePodBecomesSchedulable(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO(#91111): Add more test cases.
|
{
|
||||||
|
name: "pod with pod-affinity gets added",
|
||||||
|
init: func(cs kubernetes.Interface, _ string) error {
|
||||||
|
node, err := createNode(cs, "node-1", nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot create node: %v", err)
|
||||||
|
}
|
||||||
|
if err := utils.AddLabelsToNode(cs, node.Name, map[string]string{"region": "test"}); err != nil {
|
||||||
|
return fmt.Errorf("cannot add labels to node: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
pod: &pausePodConfig{
|
||||||
|
Name: "pod-1",
|
||||||
|
Affinity: &v1.Affinity{
|
||||||
|
PodAffinity: &v1.PodAffinity{
|
||||||
|
RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
|
||||||
|
{
|
||||||
|
LabelSelector: &metav1.LabelSelector{
|
||||||
|
MatchLabels: map[string]string{
|
||||||
|
"pod-with-affinity": "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TopologyKey: "region",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: func(cs kubernetes.Interface, ns string) error {
|
||||||
|
podConfig := &pausePodConfig{
|
||||||
|
Name: "pod-with-affinity",
|
||||||
|
Namespace: ns,
|
||||||
|
Labels: map[string]string{
|
||||||
|
"pod-with-affinity": "true",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if _, err := createPausePod(cs, initPausePod(podConfig)); err != nil {
|
||||||
|
return fmt.Errorf("cannot create pod: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user