@@ -1106,7 +1106,49 @@ func TestUnschedulablePodBecomesSchedulable(t *testing.T) {
1106
1106
return nil
1107
1107
},
1108
1108
},
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
+ },
1110
1152
}
1111
1153
for _ , tt := range tests {
1112
1154
t .Run (tt .name , func (t * testing.T ) {
0 commit comments