From c52160eb3c4f4d5d6ade74a02af0b1f6bd411694 Mon Sep 17 00:00:00 2001 From: Ayato Tokubi Date: Thu, 4 Apr 2024 18:46:19 +0100 Subject: [PATCH] Use WaitForPodCondition instead of sleep Signed-off-by: Ayato Tokubi --- test/e2e/dra/dra.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/test/e2e/dra/dra.go b/test/e2e/dra/dra.go index 520e6db9b10..64c2b58cc40 100644 --- a/test/e2e/dra/dra.go +++ b/test/e2e/dra/dra.go @@ -45,7 +45,6 @@ import ( e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" admissionapi "k8s.io/pod-security-admission/api" - utilpointer "k8s.io/utils/pointer" "k8s.io/utils/ptr" ) @@ -481,14 +480,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation, objects = append(objects, template, pod) b.create(ctx, objects...) - // There's no way to be sure that the scheduler has checked the pod. - // But if we sleep for a short while, it's likely and if there are any - // bugs that prevent the scheduler from handling creation of the class, - // those bugs should show up as test flakes. - // - // TODO (https://github.com/kubernetes/kubernetes/issues/123805): check the Schedulable condition instead of - // sleeping. - time.Sleep(time.Second) + framework.ExpectNoError(e2epod.WaitForPodNameUnschedulableInNamespace(ctx, f.ClientSet, pod.Name, pod.Namespace)) class.UID = "" class.ResourceVersion = "" @@ -525,11 +517,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation, objects = append(objects, template, pod) b.create(ctx, objects...) - // There's no way to be sure that the scheduler has checked the pod. - // But if we sleep for a short while, it's likely and if there are any - // bugs that prevent the scheduler from handling updates of the class, - // those bugs should show up as test flakes. - time.Sleep(time.Second) + framework.ExpectNoError(e2epod.WaitForPodNameUnschedulableInNamespace(ctx, f.ClientSet, pod.Name, pod.Namespace)) // Unblock the pod. class.SuitableNodes = nil @@ -1422,7 +1410,7 @@ func (b *builder) podInline(allocationMode resourcev1alpha2.AllocationMode) (*v1 { Name: podClaimName, Source: v1.ClaimSource{ - ResourceClaimTemplateName: utilpointer.String(pod.Name), + ResourceClaimTemplateName: ptr.To(pod.Name), }, }, }