Skip to content

Commit 31aaf8f

Browse files
committed
Add e2e test
1 parent 1877022 commit 31aaf8f

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

test/e2e/dra/dra.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
"github.com/onsi/ginkgo/v2"
3131
"github.com/onsi/gomega"
32+
"github.com/onsi/gomega/format"
3233
"github.com/onsi/gomega/gstruct"
3334
"github.com/onsi/gomega/types"
3435

@@ -1208,6 +1209,75 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
12081209
b1.create(ctx, claim1, claim1b, claim2, claim2b, pod)
12091210
b1.testPod(ctx, f.ClientSet, pod)
12101211
})
1212+
1213+
ginkgo.It("foobar", func(ctx context.Context) {
1214+
ginkgo.By("Running the multiclaim test")
1215+
name := "external-multiclaim"
1216+
params := `{"a":"b"}`
1217+
rc := &resourceapi.ResourceClaim{
1218+
ObjectMeta: metav1.ObjectMeta{
1219+
Name: name,
1220+
},
1221+
Spec: resourceapi.ResourceClaimSpec{
1222+
Devices: resourceapi.DeviceClaim{
1223+
Requests: []resourceapi.DeviceRequest{{
1224+
Name: "my-request",
1225+
FirstAvailableOf: []resourceapi.DeviceRequest{
1226+
{
1227+
Name: "request-1",
1228+
DeviceClassName: b1.className(),
1229+
AllocationMode: resourceapi.DeviceAllocationModeExactCount,
1230+
Count: 1,
1231+
},
1232+
{
1233+
Name: "request-2",
1234+
DeviceClassName: b2.className(),
1235+
AllocationMode: resourceapi.DeviceAllocationModeExactCount,
1236+
Count: 1,
1237+
},
1238+
},
1239+
}},
1240+
Config: []resourceapi.DeviceClaimConfiguration{
1241+
{
1242+
Requests: []string{"request-1"},
1243+
DeviceConfiguration: resourceapi.DeviceConfiguration{
1244+
Opaque: &resourceapi.OpaqueDeviceConfiguration{
1245+
Driver: b1.driver.Name,
1246+
Parameters: runtime.RawExtension{
1247+
Raw: []byte(params),
1248+
},
1249+
},
1250+
},
1251+
},
1252+
{
1253+
Requests: []string{"request-2"},
1254+
DeviceConfiguration: resourceapi.DeviceConfiguration{
1255+
Opaque: &resourceapi.OpaqueDeviceConfiguration{
1256+
Driver: b2.driver.Name,
1257+
Parameters: runtime.RawExtension{
1258+
Raw: []byte(params),
1259+
},
1260+
},
1261+
},
1262+
},
1263+
},
1264+
},
1265+
},
1266+
}
1267+
framework.Logf("New ResourceClaim:\n%s", format.Object(rc, 1))
1268+
pod := b1.podExternal()
1269+
podClaimName := "resource-claim"
1270+
externalClaimName := "external-multiclaim"
1271+
pod.Spec.ResourceClaims = []v1.PodResourceClaim{
1272+
{
1273+
Name: podClaimName,
1274+
ResourceClaimName: &externalClaimName,
1275+
},
1276+
}
1277+
framework.Logf("New Pod:\n%s", format.Object(pod, 1))
1278+
b1.create(ctx, rc, pod)
1279+
b1.testPod(ctx, f.ClientSet, pod)
1280+
})
12111281
}
12121282
multipleDriversContext := func(prefix string, nodeV1alpha3 bool) {
12131283
ginkgo.Context(prefix, func() {

test/e2e/dra/test-driver/app/kubeletplugin.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,15 @@ func (ex *ExamplePlugin) nodePrepareResource(ctx context.Context, claimReq *drap
307307
var devices []Device
308308
for _, result := range claim.Status.Allocation.Devices.Results {
309309
requestName := result.Request
310+
subRequestName := result.SelectedSubRequest
310311

311312
// The driver joins all env variables in the order in which
312313
// they appear in results (last one wins).
313314
env := make(map[string]string)
314315
for i, config := range claim.Status.Allocation.Devices.Config {
315316
if config.Opaque == nil ||
316317
config.Opaque.Driver != ex.driverName ||
317-
len(config.Requests) > 0 && !slices.Contains(config.Requests, requestName) {
318+
len(config.Requests) > 0 && !slices.Contains(config.Requests, requestName) && !slices.Contains(config.Requests, subRequestName) {
318319
continue
319320
}
320321
if err := extractParameters(config.Opaque.Parameters, &env, config.Source == resourceapi.AllocationConfigSourceClass); err != nil {

0 commit comments

Comments
 (0)