From 1d8778173a4e6f25919224e287b3d297952e03ce Mon Sep 17 00:00:00 2001 From: hc-github-team-consul-core Date: Mon, 31 Oct 2022 13:11:24 -0400 Subject: [PATCH] Backport of test: fix flaky TestSubscribeBackend_IntegrationWithServer_DeliversAllMessages test into release/1.14.x (#15207) This pull request was automerged via backport-assistant --- agent/consul/subscribe_backend_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/agent/consul/subscribe_backend_test.go b/agent/consul/subscribe_backend_test.go index b7ea7e2d3b..a4d1134e18 100644 --- a/agent/consul/subscribe_backend_test.go +++ b/agent/consul/subscribe_backend_test.go @@ -444,13 +444,17 @@ func verifyMonotonicStreamUpdates(ctx context.Context, logger testLogger, client if err != nil { return err } - if expectPort != svc.Port { + switch svc.Port { + case expectPort: + atomic.AddUint64(updateCount, 1) + logger.Logf("subscriber %05d: got event with correct port=%d at index %d", i, expectPort, event.Index) + expectPort++ + case expectPort - 1: + logger.Logf("subscriber %05d: got event with repeated prior port=%d at index %d", i, expectPort-1, event.Index) + default: return fmt.Errorf("subscriber %05d: at index %d: expected port %d, got %d", i, event.Index, expectPort, svc.Port) } - atomic.AddUint64(updateCount, 1) - logger.Logf("subscriber %05d: got event with correct port=%d at index %d", i, expectPort, event.Index) - expectPort++ default: // snapshot events svc, err := svcOrErr(event)