scheduler_perf: more realistic structured parameters tests

Real devices are likely to have a handful of attributes and (for GPUs) the
memory as capacity. Most keys will be driver specific, a few may eventually
have a domain (none standardized right now).
This commit is contained in:
Patrick Ohly 2024-09-10 11:02:46 +02:00
parent b071443187
commit 7bbb3465e5

View File

@ -23,11 +23,13 @@ import (
"sync"
resourceapi "k8s.io/api/resource/v1alpha3"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
draapp "k8s.io/kubernetes/test/e2e/dra/test-driver/app"
"k8s.io/kubernetes/test/utils/ktesting"
"k8s.io/utils/ptr"
)
// createResourceClaimsOp defines an op where resource claims are created.
@ -248,7 +250,17 @@ func resourceSlice(driverName, nodeName string, capacity int) *resourceapi.Resou
slice.Spec.Devices = append(slice.Spec.Devices,
resourceapi.Device{
Name: fmt.Sprintf("instance-%d", i),
Basic: &resourceapi.BasicDevice{},
Basic: &resourceapi.BasicDevice{
Attributes: map[resourceapi.QualifiedName]resourceapi.DeviceAttribute{
"model": {StringValue: ptr.To("A100")},
"family": {StringValue: ptr.To("GPU")},
"driverVersion": {VersionValue: ptr.To("1.2.3")},
"dra.example.com/numa": {IntValue: ptr.To(int64(i))},
},
Capacity: map[resourceapi.QualifiedName]resource.Quantity{
"memory": resource.MustParse("1Gi"),
},
},
},
)
}