@@ -215,6 +215,10 @@ func TestTopologyMatchPlugin(t *testing.T) {
215
215
}
216
216
217
217
nodeList , err := cs .CoreV1 ().Nodes ().List (testCtx .Ctx , metav1.ListOptions {})
218
+ if err != nil {
219
+ t .Errorf ("can't list nodes: %s" , err .Error ())
220
+ }
221
+
218
222
t .Logf ("NodeList: %v" , nodeList )
219
223
pause := imageutils .GetPauseImageName ()
220
224
tests := []nrtTestEntry {
@@ -706,6 +710,69 @@ func TestTopologyMatchPlugin(t *testing.T) {
706
710
},
707
711
expectedNodes : []string {"fake-node-1" , "fake-node-2" },
708
712
},
713
+ {
714
+ name : "Scheduling Guaranteed pod with LeastNUMANodes strategy scheduler, one node only non NUMA resources" ,
715
+ pods : []* v1.Pod {
716
+ util .WithLimits (st .MakePod ().Namespace (ns ).Name (testPodName ).SchedulerName (leastNUMAScheduler ),
717
+ map [string ]string {memory : "4Gi" }, false ).Obj (),
718
+ },
719
+ nodeResourceTopologies : []* topologyv1alpha2.NodeResourceTopology {
720
+ MakeNRT ().Name ("fake-node-1" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
721
+ Zone (
722
+ topologyv1alpha2.ResourceInfoList {
723
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
724
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
725
+ }).
726
+ Zone (
727
+ topologyv1alpha2.ResourceInfoList {
728
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
729
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
730
+ }).Obj (),
731
+ MakeNRT ().Name ("fake-node-2" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
732
+ Zone (
733
+ topologyv1alpha2.ResourceInfoList {
734
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
735
+ }).
736
+ Zone (
737
+ topologyv1alpha2.ResourceInfoList {
738
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
739
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "3Gi" ),
740
+ }).Obj (),
741
+ },
742
+ expectedNodes : []string {"fake-node-1" , "fake-node-2" },
743
+ },
744
+ {
745
+ name : "Scheduling Guaranteed pod with LeastNUMANodes strategy scheduler, different allocation pod scope" ,
746
+ pods : []* v1.Pod {
747
+ util .WithLimits (st .MakePod ().Namespace (ns ).Name (testPodName ).SchedulerName (leastNUMAScheduler ),
748
+ map [string ]string {cpu : "4" , memory : "4Gi" }, false ).Obj (),
749
+ },
750
+ nodeResourceTopologies : []* topologyv1alpha2.NodeResourceTopology {
751
+ MakeNRT ().Name ("fake-node-1" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
752
+ Zone (
753
+ topologyv1alpha2.ResourceInfoList {
754
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
755
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
756
+ }).
757
+ Zone (
758
+ topologyv1alpha2.ResourceInfoList {
759
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
760
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
761
+ }).Obj (),
762
+ MakeNRT ().Name ("fake-node-2" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
763
+ Zone (
764
+ topologyv1alpha2.ResourceInfoList {
765
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
766
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
767
+ }).
768
+ Zone (
769
+ topologyv1alpha2.ResourceInfoList {
770
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
771
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "3Gi" ),
772
+ }).Obj (),
773
+ },
774
+ expectedNodes : []string {"fake-node-2" },
775
+ },
709
776
{
710
777
name : "Scheduling Guaranteed pod with LeastNUMANodes strategy scheduler, different allocation pod scope" ,
711
778
pods : []* v1.Pod {
@@ -747,7 +814,6 @@ func TestTopologyMatchPlugin(t *testing.T) {
747
814
map [string ]string {cpu : "2" , memory : "4Gi" }, false ),
748
815
map [string ]string {cpu : "2" , memory : "6Gi" }, true ).Obj (),
749
816
},
750
-
751
817
nodeResourceTopologies : []* topologyv1alpha2.NodeResourceTopology {
752
818
MakeNRT ().Name ("fake-node-1" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
753
819
Zone (
@@ -987,6 +1053,235 @@ func TestTopologyMatchPlugin(t *testing.T) {
987
1053
},
988
1054
expectedNodes : []string {"fake-node-2" },
989
1055
},
1056
+ {
1057
+ name : "Scheduling Guaranteed single containers pod with LeastNUMANodes strategy scheduler, pod scope,one node non optimal, one no resources left" ,
1058
+ pods : []* v1.Pod {
1059
+ util .WithLimits (st .MakePod ().Namespace (ns ).Name (testPodName ).SchedulerName (leastNUMAScheduler ),
1060
+ map [string ]string {
1061
+ cpu : "4" , memory : "4Gi" , gpuResourceName : "2" ,
1062
+ }, false ).Obj (),
1063
+ },
1064
+ nodeResourceTopologies : []* topologyv1alpha2.NodeResourceTopology {
1065
+ MakeNRT ().Name ("fake-node-1" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
1066
+ ZoneWithCosts (
1067
+ topologyv1alpha2.ResourceInfoList {
1068
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
1069
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1070
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "1" , "1" ),
1071
+ },
1072
+ topologyv1alpha2.CostList {
1073
+ {
1074
+ Name : "node-0" ,
1075
+ Value : 10 ,
1076
+ },
1077
+ {
1078
+ Name : "node-1" ,
1079
+ Value : 12 ,
1080
+ },
1081
+ {
1082
+ Name : "node-2" ,
1083
+ Value : 20 ,
1084
+ },
1085
+ },
1086
+ ).
1087
+ ZoneWithCosts (
1088
+ topologyv1alpha2.ResourceInfoList {
1089
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
1090
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1091
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "0" , "0" ),
1092
+ },
1093
+ topologyv1alpha2.CostList {
1094
+ {
1095
+ Name : "node-0" ,
1096
+ Value : 12 ,
1097
+ },
1098
+ {
1099
+ Name : "node-1" ,
1100
+ Value : 10 ,
1101
+ },
1102
+ {
1103
+ Name : "node-2" ,
1104
+ Value : 20 ,
1105
+ },
1106
+ },
1107
+ ).
1108
+ ZoneWithCosts (
1109
+ topologyv1alpha2.ResourceInfoList {
1110
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
1111
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1112
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "1" , "1" ),
1113
+ },
1114
+ topologyv1alpha2.CostList {
1115
+ {
1116
+ Name : "node-0" ,
1117
+ Value : 20 ,
1118
+ },
1119
+ {
1120
+ Name : "node-1" ,
1121
+ Value : 20 ,
1122
+ },
1123
+ {
1124
+ Name : "node-2" ,
1125
+ Value : 10 ,
1126
+ },
1127
+ },
1128
+ ).Obj (),
1129
+ MakeNRT ().Name ("fake-node-2" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
1130
+ Zone (
1131
+ topologyv1alpha2.ResourceInfoList {
1132
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
1133
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1134
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "0" , "0" ),
1135
+ }).
1136
+ Zone (
1137
+ topologyv1alpha2.ResourceInfoList {
1138
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
1139
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "3Gi" ),
1140
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "0" , "0" ),
1141
+ }).Obj (),
1142
+ },
1143
+ expectedNodes : []string {"fake-node-1" },
1144
+ },
1145
+ {
1146
+ name : "Scheduling Guaranteed single containers pod with LeastNUMANodes strategy scheduler, pod scope,one node non optimal, one node optimal" ,
1147
+ pods : []* v1.Pod {
1148
+ util .WithLimits (st .MakePod ().Namespace (ns ).Name (testPodName ).SchedulerName (leastNUMAScheduler ),
1149
+ map [string ]string {
1150
+ cpu : "4" , memory : "4Gi" , gpuResourceName : "2" ,
1151
+ }, false ).Obj (),
1152
+ },
1153
+ nodeResourceTopologies : []* topologyv1alpha2.NodeResourceTopology {
1154
+ MakeNRT ().Name ("fake-node-1" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
1155
+ ZoneWithCosts (
1156
+ topologyv1alpha2.ResourceInfoList {
1157
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
1158
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1159
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "1" , "1" ),
1160
+ },
1161
+ topologyv1alpha2.CostList {
1162
+ {
1163
+ Name : "node-0" ,
1164
+ Value : 10 ,
1165
+ },
1166
+ {
1167
+ Name : "node-1" ,
1168
+ Value : 12 ,
1169
+ },
1170
+ {
1171
+ Name : "node-2" ,
1172
+ Value : 20 ,
1173
+ },
1174
+ },
1175
+ ).
1176
+ ZoneWithCosts (
1177
+ topologyv1alpha2.ResourceInfoList {
1178
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
1179
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1180
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "0" , "0" ),
1181
+ },
1182
+ topologyv1alpha2.CostList {
1183
+ {
1184
+ Name : "node-0" ,
1185
+ Value : 12 ,
1186
+ },
1187
+ {
1188
+ Name : "node-1" ,
1189
+ Value : 10 ,
1190
+ },
1191
+ {
1192
+ Name : "node-2" ,
1193
+ Value : 20 ,
1194
+ },
1195
+ },
1196
+ ).
1197
+ ZoneWithCosts (
1198
+ topologyv1alpha2.ResourceInfoList {
1199
+ noderesourcetopology .MakeTopologyResInfo (cpu , "2" , "2" ),
1200
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1201
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "1" , "1" ),
1202
+ },
1203
+ topologyv1alpha2.CostList {
1204
+ {
1205
+ Name : "node-0" ,
1206
+ Value : 20 ,
1207
+ },
1208
+ {
1209
+ Name : "node-1" ,
1210
+ Value : 20 ,
1211
+ },
1212
+ {
1213
+ Name : "node-2" ,
1214
+ Value : 10 ,
1215
+ },
1216
+ },
1217
+ ).Obj (),
1218
+ MakeNRT ().Name ("fake-node-2" ).Policy (topologyv1alpha2 .BestEffortPodLevel ).
1219
+ ZoneWithCosts (
1220
+ topologyv1alpha2.ResourceInfoList {
1221
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
1222
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1223
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "1" , "1" ),
1224
+ },
1225
+ topologyv1alpha2.CostList {
1226
+ {
1227
+ Name : "node-0" ,
1228
+ Value : 10 ,
1229
+ },
1230
+ {
1231
+ Name : "node-1" ,
1232
+ Value : 12 ,
1233
+ },
1234
+ {
1235
+ Name : "node-2" ,
1236
+ Value : 20 ,
1237
+ },
1238
+ },
1239
+ ).
1240
+ ZoneWithCosts (
1241
+ topologyv1alpha2.ResourceInfoList {
1242
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
1243
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "8Gi" ),
1244
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "1" , "1" ),
1245
+ },
1246
+ topologyv1alpha2.CostList {
1247
+ {
1248
+ Name : "node-0" ,
1249
+ Value : 12 ,
1250
+ },
1251
+ {
1252
+ Name : "node-1" ,
1253
+ Value : 10 ,
1254
+ },
1255
+ {
1256
+ Name : "node-2" ,
1257
+ Value : 20 ,
1258
+ },
1259
+ },
1260
+ ).
1261
+ ZoneWithCosts (
1262
+ topologyv1alpha2.ResourceInfoList {
1263
+ noderesourcetopology .MakeTopologyResInfo (cpu , "4" , "4" ),
1264
+ noderesourcetopology .MakeTopologyResInfo (memory , "8Gi" , "3Gi" ),
1265
+ noderesourcetopology .MakeTopologyResInfo (gpuResourceName , "0" , "0" ),
1266
+ },
1267
+ topologyv1alpha2.CostList {
1268
+ {
1269
+ Name : "node-0" ,
1270
+ Value : 20 ,
1271
+ },
1272
+ {
1273
+ Name : "node-1" ,
1274
+ Value : 20 ,
1275
+ },
1276
+ {
1277
+ Name : "node-2" ,
1278
+ Value : 10 ,
1279
+ },
1280
+ },
1281
+ ).Obj (),
1282
+ },
1283
+ expectedNodes : []string {"fake-node-2" },
1284
+ },
990
1285
}
991
1286
992
1287
// a dedicated set of tests for the scope=container flow
0 commit comments