Skip to content

Commit 498b1e2

Browse files
authored
Merge pull request kubernetes#93491 from robscott/endpointslice-test-logging
Improving logging in EndpointSlice e2e tests
2 parents 8d74486 + 6051a16 commit 498b1e2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/e2e/network/endpointslice.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package network
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"fmt"
2223
"time"
2324

@@ -311,13 +312,12 @@ func expectEndpointsAndSlices(cs clientset.Interface, ns string, svc *v1.Service
311312
if err := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
312313
endpointSlicesFound, hasMatchingSlices := hasMatchingEndpointSlices(cs, ns, svc.Name, len(pods), numSlices)
313314
if !hasMatchingSlices {
314-
framework.Logf("Matching EndpointSlices not found")
315315
return false, nil
316316
}
317317
endpointSlices = endpointSlicesFound
318318
return true, nil
319319
}); err != nil {
320-
framework.Failf("Timed out waiting for matching EndpointSlices to exist: %v", err)
320+
framework.Failf("Timed out waiting for EndpointSlices to match expectations: %v", err)
321321
}
322322

323323
endpoints := &v1.Endpoints{}
@@ -330,7 +330,7 @@ func expectEndpointsAndSlices(cs clientset.Interface, ns string, svc *v1.Service
330330
endpoints = endpointsFound
331331
return true, nil
332332
}); err != nil {
333-
framework.Failf("Timed out waiting for matching Endpoints to exist: %v", err)
333+
framework.Failf("Timed out waiting for Endpoints to match expectations: %v", err)
334334
}
335335

336336
podsByIP := map[string]*v1.Pod{}
@@ -494,7 +494,15 @@ func hasMatchingEndpointSlices(cs clientset.Interface, ns, svcName string, numEn
494494
}
495495
if len(esList.Items) != numSlices {
496496
framework.Logf("Expected %d EndpointSlices for Service %s/%s, got %d", numSlices, ns, svcName, len(esList.Items))
497-
return []discoveryv1beta1.EndpointSlice{}, false
497+
for i, epSlice := range esList.Items {
498+
epsData, err := json.Marshal(epSlice)
499+
if err != nil {
500+
framework.Logf("Error marshaling JSON for EndpointSlice: %v", err)
501+
} else {
502+
framework.Logf("%d - %v", i, string(epsData))
503+
}
504+
}
505+
return esList.Items, false
498506
}
499507

500508
actualNumEndpoints := 0
@@ -503,7 +511,7 @@ func hasMatchingEndpointSlices(cs clientset.Interface, ns, svcName string, numEn
503511
}
504512
if actualNumEndpoints != numEndpoints {
505513
framework.Logf("EndpointSlices for %s/%s Service have %d/%d endpoints", ns, svcName, actualNumEndpoints, numEndpoints)
506-
return []discoveryv1beta1.EndpointSlice{}, false
514+
return esList.Items, false
507515
}
508516

509517
return esList.Items, true

0 commit comments

Comments
 (0)