Skip to content

Commit 00346e5

Browse files
committed
Log CCM output when TestServiceTrafficPolicyLocal fails, to capture rare test error
1 parent 6a1c393 commit 00346e5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pkg/internal/integration/service_test.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,12 @@ func (s *IntegrationTestSuite) TestServiceTrafficPolicyLocal() {
404404
// ten responses with the expected address come back.
405405
assertPrefix := func(addr string, prefix *netip.Prefix) {
406406
url := fmt.Sprintf("http://%s", addr)
407-
successful := 0
407+
successes := 0
408+
successesRequired := 15
408409
start := time.Now()
410+
timeout := 120
409411

410-
for i := 0; i < 120; i++ {
412+
for i := 0; i < timeout; i++ {
411413
time.Sleep(1 * time.Second)
412414

413415
peer, err := testkit.HTTPRead(url)
@@ -424,15 +426,23 @@ func (s *IntegrationTestSuite) TestServiceTrafficPolicyLocal() {
424426
continue
425427
}
426428

427-
successful++
429+
successes++
428430

429-
if successful >= 15 {
431+
if successes >= successesRequired {
430432
break
431433
}
432434
}
433435

434-
s.T().Logf("Took %s too %s to get ready", url, time.Since(start))
435-
s.Require().GreaterOrEqual(successful, 15)
436+
took := time.Since(start).Round(time.Second)
437+
438+
if successes >= successesRequired {
439+
s.T().Logf("Took %s %s to get ready", url, took)
440+
} else {
441+
s.T().Logf("Took %s too long to get ready (%s)", url, took)
442+
s.T().Logf("CCM Logs: \n%s", s.CCMLogs(start))
443+
}
444+
445+
s.Require().GreaterOrEqual(successes, successesRequired)
436446
}
437447

438448
// Ensures the traffic is handled without unexpected delay

0 commit comments

Comments
 (0)