From fe7f31bdcb1e41471c7321b33da1755471f1a374 Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Tue, 6 Jan 2026 20:54:12 +0000 Subject: [PATCH] test(e2e/dra): add test for pod requesting allocated and new claims --- test/e2e/dra/dra.go | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/e2e/dra/dra.go b/test/e2e/dra/dra.go index c4adf2b91ef..74569855087 100644 --- a/test/e2e/dra/dra.go +++ b/test/e2e/dra/dra.go @@ -1088,6 +1088,54 @@ var _ = framework.SIGDescribe("node")(framework.WithLabel("DRA"), func() { } } + singleNodeMultipleClaimsTests := func() { + nodes := drautils.NewNodes(f, 1, 1) + // Allow allocating more than one device so that multiple claims can be prepared on the same node. + maxAllocations := 2 + driver := drautils.NewDriver(f, nodes, drautils.DriverResources(maxAllocations)) // All tests get their own driver instance. + driver.WithKubelet = true + b := drautils.NewBuilder(f, driver) + + // https://github.com/kubernetes/kubernetes/issues/135901 was fixed and backported to Kubernetes 1.35. + // An independent backport was introduced for 1.34: https://github.com/kubernetes/kubernetes/pull/136480; + // in the meantime this KubeletMinVersion:1.35 is necessary because + // the latest 1.34 release still has the problem. + f.It("requests an already allocated and a new claim for a pod", f.WithLabel("KubeletMinVersion:1.35"), func(ctx context.Context) { + // This test covers a situation when a pod references a mix of already-prepared and new claims. + firstClaim := b.ExternalClaim() + secondClaim := b.ExternalClaim() + + b.Create(ctx, firstClaim, secondClaim) + + // First pod uses only firstClaim + firstPod := b.PodExternal() + b.Create(ctx, firstPod) + b.TestPod(ctx, f, firstPod) + + // Second pod uses firstClaim (already prepared) + secondClaim (new) + secondPod := b.PodExternal() + + secondPod.Spec.ResourceClaims = []v1.PodResourceClaim{ + { + Name: "first", + ResourceClaimName: &firstClaim.Name, + }, + { + Name: "second", + ResourceClaimName: &secondClaim.Name, + }, + } + + secondPod.Spec.Containers[0].Resources.Claims = []v1.ResourceClaim{ + {Name: "first"}, + {Name: "second"}, + } + + b.Create(ctx, secondPod) + b.TestPod(ctx, f, secondPod) + }) + } + // The following tests only make sense when there is more than one node. // They get skipped when there's only one node. multiNodeTests := func(withKubelet bool) { @@ -1952,6 +2000,7 @@ var _ = framework.SIGDescribe("node")(framework.WithLabel("DRA"), func() { framework.Context("control plane", func() { singleNodeTests(false) }) framework.Context("kubelet", feature.DynamicResourceAllocation, "on single node", func() { singleNodeTests(true) }) + framework.Context("kubelet", feature.DynamicResourceAllocation, "on single node with multiple claims allocation", singleNodeMultipleClaimsTests) framework.Context("control plane", func() { multiNodeTests(false) }) framework.Context("kubelet", feature.DynamicResourceAllocation, "on multiple nodes", func() { multiNodeTests(true) })