Merge pull request #124235 from bitoku/dra-e2e

Use WaitForPodCondition instead of sleep
This commit is contained in:
Kubernetes Prow Robot 2024-04-18 03:24:42 -07:00 committed by GitHub
commit 7ebb64d176
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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"
) )
@ -498,14 +497,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 = ""
@ -542,11 +534,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
@ -1439,7 +1427,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),
}, },
}, },
} }