mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Make EndpointSlice API e2e test faster
EndpointSlices and Endpoints usually become ready pretty fast, but the test always waited 5s before performing every check and it performed the check 4 times in total, so unnecessarily extends the test 20s. The commit changes the poll function to perform a check before waiting, and reduces the interval to 2 seconds to align with other EndpointSlice tests. It reduces the test duration from 30s to 4s. Signed-off-by: Quan Tian <qtian@vmware.com>
This commit is contained in:
parent
09a5049ca7
commit
afefc6f4eb
@ -307,7 +307,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
err := wait.Poll(5*time.Second, 3*time.Minute, func() (bool, error) {
|
err := wait.PollUntilContextTimeout(ctx, 2*time.Second, 3*time.Minute, true, func(ctx context.Context) (bool, error) {
|
||||||
var err error
|
var err error
|
||||||
pod1, err = podClient.Get(ctx, pod1.Name, metav1.GetOptions{})
|
pod1, err = podClient.Get(ctx, pod1.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -740,7 +740,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
// the only caller of this function.
|
// the only caller of this function.
|
||||||
func expectEndpointsAndSlices(ctx context.Context, cs clientset.Interface, ns string, svc *v1.Service, pods []*v1.Pod, numSubsets, numSlices int, namedPort bool) {
|
func expectEndpointsAndSlices(ctx context.Context, cs clientset.Interface, ns string, svc *v1.Service, pods []*v1.Pod, numSubsets, numSlices int, namedPort bool) {
|
||||||
endpointSlices := []discoveryv1.EndpointSlice{}
|
endpointSlices := []discoveryv1.EndpointSlice{}
|
||||||
if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, 2*time.Minute, true, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(ctx, 2*time.Second, 2*time.Minute, true, func(ctx context.Context) (bool, error) {
|
||||||
endpointSlicesFound, hasMatchingSlices := hasMatchingEndpointSlices(ctx, cs, ns, svc.Name, len(pods), numSlices)
|
endpointSlicesFound, hasMatchingSlices := hasMatchingEndpointSlices(ctx, cs, ns, svc.Name, len(pods), numSlices)
|
||||||
if !hasMatchingSlices {
|
if !hasMatchingSlices {
|
||||||
return false, nil
|
return false, nil
|
||||||
@ -752,7 +752,7 @@ func expectEndpointsAndSlices(ctx context.Context, cs clientset.Interface, ns st
|
|||||||
}
|
}
|
||||||
|
|
||||||
endpoints := &v1.Endpoints{}
|
endpoints := &v1.Endpoints{}
|
||||||
if err := wait.PollWithContext(ctx, 5*time.Second, 2*time.Minute, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(ctx, 2*time.Second, 2*time.Minute, true, func(ctx context.Context) (bool, error) {
|
||||||
endpointsFound, hasMatchingEndpoints := hasMatchingEndpoints(ctx, cs, ns, svc.Name, len(pods), numSubsets)
|
endpointsFound, hasMatchingEndpoints := hasMatchingEndpoints(ctx, cs, ns, svc.Name, len(pods), numSubsets)
|
||||||
if !hasMatchingEndpoints {
|
if !hasMatchingEndpoints {
|
||||||
framework.Logf("Matching Endpoints not found")
|
framework.Logf("Matching Endpoints not found")
|
||||||
|
Loading…
Reference in New Issue
Block a user