Skip to content

Commit

Permalink
xds/xdsclient: Fix flaky test TestLRSClient (#7559)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Aug 26, 2024
1 parent cfd14ba commit 6d97688
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions xds/internal/xdsclient/loadreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 6d97688

Please sign in to comment.