xds/xdsclient: Fix flaky test TestLRSClient (#7559)

This commit is contained in:
Arjan Singh Bal 2024-08-26 22:16:55 +05:30 committed by GitHub
parent cfd14baa82
commit 6d976887d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 3 deletions

View File

@ -132,8 +132,20 @@ func (s) TestLRSClient(t *testing.T) {
// Cancel this load reporting stream, server should see error canceled.
lrsCancel2()
// Server should receive a stream canceled error.
if u, err := fs2.LRSRequestChan.Receive(ctx); err != nil || status.Code(u.(*fakeserver.Request).Err) != codes.Canceled {
t.Errorf("unexpected LRS request: %v, %v, want error canceled", u, err)
// Server should receive a stream canceled error. There may be additional
// load reports from the client in the channel.
for {
u, err := fs2.LRSRequestChan.Receive(ctx)
if err != nil {
t.Fatalf("unexpected error while reading LRS request: %v", err)
}
// Ignore load reports sent before the stream was cancelled.
if u.(*fakeserver.Request).Err == nil {
continue
}
if status.Code(u.(*fakeserver.Request).Err) != codes.Canceled {
t.Errorf("unexpected LRS request: %v, want error canceled", u)
}
break
}
}