From d883f3d5faf91e030539ce310875850357c6c4a8 Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Fri, 24 Jun 2022 10:23:13 -0700 Subject: [PATCH] test/xds: fail only when state changes to something other than READY and IDLE (#5463) --- test/xds/xds_server_serving_mode_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/xds/xds_server_serving_mode_test.go b/test/xds/xds_server_serving_mode_test.go index 03a62ed6c784..118a63394f8b 100644 --- a/test/xds/xds_server_serving_mode_test.go +++ b/test/xds/xds_server_serving_mode_test.go @@ -112,9 +112,18 @@ func (s) TestServerSideXDS_RedundantUpdateSuppression(t *testing.T) { // suppressed, server will recycle client connections. errCh := make(chan error, 1) go func() { - if cc.WaitForStateChange(ctx, connectivity.Ready) { - errCh <- fmt.Errorf("unexpected connectivity state change {%s --> %s} on the client connection", connectivity.Ready, cc.GetState()) - return + prev := connectivity.Ready // We know we are READY since we just did an RPC. + for { + curr := cc.GetState() + if !(curr == connectivity.Ready || curr == connectivity.Idle) { + errCh <- fmt.Errorf("unexpected connectivity state change {%s --> %s} on the client connection", prev, curr) + return + } + if !cc.WaitForStateChange(ctx, curr) { + // Break out of the for loop when the context has been cancelled. + break + } + prev = curr } errCh <- nil }()