@@ -395,6 +395,14 @@ func deviceAllocationResult(request, driver, pool, device string, adminAccess bo
395
395
return r
396
396
}
397
397
398
+ func multipleDeviceAllocationResults (request , driver , pool string , count , startIndex int ) []resourceapi.DeviceRequestAllocationResult {
399
+ var results []resourceapi.DeviceRequestAllocationResult
400
+ for i := startIndex ; i < startIndex + count ; i ++ {
401
+ results = append (results , deviceAllocationResult (request , driver , pool , fmt .Sprintf ("device-%d" , i ), false ))
402
+ }
403
+ return results
404
+ }
405
+
398
406
// nodeLabelSelector creates a node selector with a label match for "key" in "values".
399
407
func nodeLabelSelector (key string , values ... string ) * v1.NodeSelector {
400
408
requirements := []v1.NodeSelectorRequirement {{
@@ -3024,6 +3032,21 @@ func TestAllocator(t *testing.T) {
3024
3032
deviceAllocationResult (req0 , driverA , pool1 , device1 , false ),
3025
3033
)},
3026
3034
},
3035
+ "max-number-devices" : {
3036
+ claimsToAllocate : objects (
3037
+ claimWithRequests (
3038
+ claim0 , nil , request (req0 , classA , resourceapi .AllocationResultsMaxSize ),
3039
+ ),
3040
+ ),
3041
+ classes : objects (class (classA , driverA )),
3042
+ slices : objects (sliceWithMultipleDevices (slice1 , node1 , pool1 , driverA , resourceapi .AllocationResultsMaxSize )),
3043
+ node : node (node1 , region1 ),
3044
+
3045
+ expectResults : []any {allocationResult (
3046
+ localNodeSelector (node1 ),
3047
+ multipleDeviceAllocationResults (req0 , driverA , pool1 , resourceapi .AllocationResultsMaxSize , 0 )... ,
3048
+ )},
3049
+ },
3027
3050
}
3028
3051
3029
3052
for name , tc := range testcases {
0 commit comments