diff --git a/test/e2e/dra/dra.go b/test/e2e/dra/dra.go index 59dc3376da3..3d77fd93bd0 100644 --- a/test/e2e/dra/dra.go +++ b/test/e2e/dra/dra.go @@ -61,11 +61,11 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu nodes := NewNodes(f, 1, 1) driver := NewDriver(f, nodes, networkResources) // All tests get their own driver instance. b := newBuilder(f, driver) + ginkgo.It("registers plugin", func() { ginkgo.By("the driver is running") }) - // This test does not pass at the moment because kubelet doesn't retry. ginkgo.It("must retry NodePrepareResource", func(ctx context.Context) { // We have exactly one host. m := MethodInstance{driver.Nodenames()[0], NodePrepareResourceMethod} @@ -95,6 +95,7 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu framework.Fail("NodePrepareResource should have been called again") } }) + ginkgo.It("must not run a pod if a claim is not reserved for it", func(ctx context.Context) { parameters := b.parameters() claim := b.externalClaim(resourcev1alpha2.AllocationModeImmediate) @@ -118,6 +119,7 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu return nil }, 20*time.Second, 200*time.Millisecond).Should(gomega.BeNil()) }) + ginkgo.It("must unprepare resources for force-deleted pod", func(ctx context.Context) { parameters := b.parameters() claim := b.externalClaim(resourcev1alpha2.AllocationModeImmediate) @@ -140,6 +142,19 @@ var _ = ginkgo.Describe("[sig-node] DRA [Feature:DynamicResourceAllocation]", fu gomega.Eventually(plugin.GetPreparedResources).WithTimeout(time.Minute).Should(gomega.BeEmpty(), "prepared claims on host %s", host) } }) + + ginkgo.It("must skip NodePrepareResource if not used by any container", func(ctx context.Context) { + parameters := b.parameters() + pod, template := b.podInline(resourcev1alpha2.AllocationModeWaitForFirstConsumer) + for i := range pod.Spec.Containers { + pod.Spec.Containers[i].Resources.Claims = nil + } + b.create(ctx, parameters, pod, template) + framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(ctx, f.ClientSet, pod), "start pod") + for host, plugin := range b.driver.Nodes { + gomega.Expect(plugin.GetPreparedResources()).Should(gomega.BeEmpty(), "not claims should be prepared on host %s while pod is running", host) + } + }) }) ginkgo.Context("driver", func() {