test/xds: fail only when state changes to something other than READY and IDLE (#5463)

This commit is contained in:
Easwar Swaminathan 2022-06-24 10:23:13 -07:00 committed by GitHub
parent c6ee1c7144
commit d883f3d5fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -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
}()