Use WaitForPodCondition instead of sleep

Signed-off-by: Ayato Tokubi <atokubi@redhat.com>
This commit is contained in:
Ayato Tokubi 2024-04-04 18:46:19 +01:00
parent d9c54f69d4
commit c52160eb3c

View File

@ -45,7 +45,6 @@ import (
e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2enode "k8s.io/kubernetes/test/e2e/framework/node"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod" e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
admissionapi "k8s.io/pod-security-admission/api" admissionapi "k8s.io/pod-security-admission/api"
utilpointer "k8s.io/utils/pointer"
"k8s.io/utils/ptr" "k8s.io/utils/ptr"
) )
@ -481,14 +480,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
objects = append(objects, template, pod) objects = append(objects, template, pod)
b.create(ctx, objects...) b.create(ctx, objects...)
// There's no way to be sure that the scheduler has checked the pod. framework.ExpectNoError(e2epod.WaitForPodNameUnschedulableInNamespace(ctx, f.ClientSet, pod.Name, pod.Namespace))
// 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)
class.UID = "" class.UID = ""
class.ResourceVersion = "" class.ResourceVersion = ""
@ -525,11 +517,7 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation,
objects = append(objects, template, pod) objects = append(objects, template, pod)
b.create(ctx, objects...) b.create(ctx, objects...)
// There's no way to be sure that the scheduler has checked the pod. framework.ExpectNoError(e2epod.WaitForPodNameUnschedulableInNamespace(ctx, f.ClientSet, pod.Name, pod.Namespace))
// 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)
// Unblock the pod. // Unblock the pod.
class.SuitableNodes = nil class.SuitableNodes = nil
@ -1422,7 +1410,7 @@ func (b *builder) podInline(allocationMode resourcev1alpha2.AllocationMode) (*v1
{ {
Name: podClaimName, Name: podClaimName,
Source: v1.ClaimSource{ Source: v1.ClaimSource{
ResourceClaimTemplateName: utilpointer.String(pod.Name), ResourceClaimTemplateName: ptr.To(pod.Name),
}, },
}, },
} }