Skip to content

Commit 6d97688

Browse files
authoredAug 26, 2024
xds/xdsclient: Fix flaky test TestLRSClient (#7559)
1 parent cfd14ba commit 6d97688

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎xds/internal/xdsclient/loadreport_test.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,20 @@ func (s) TestLRSClient(t *testing.T) {
132132
// Cancel this load reporting stream, server should see error canceled.
133133
lrsCancel2()
134134

135-
// Server should receive a stream canceled error.
136-
if u, err := fs2.LRSRequestChan.Receive(ctx); err != nil || status.Code(u.(*fakeserver.Request).Err) != codes.Canceled {
137-
t.Errorf("unexpected LRS request: %v, %v, want error canceled", u, err)
135+
// Server should receive a stream canceled error. There may be additional
136+
// load reports from the client in the channel.
137+
for {
138+
u, err := fs2.LRSRequestChan.Receive(ctx)
139+
if err != nil {
140+
t.Fatalf("unexpected error while reading LRS request: %v", err)
141+
}
142+
// Ignore load reports sent before the stream was cancelled.
143+
if u.(*fakeserver.Request).Err == nil {
144+
continue
145+
}
146+
if status.Code(u.(*fakeserver.Request).Err) != codes.Canceled {
147+
t.Errorf("unexpected LRS request: %v, want error canceled", u)
148+
}
149+
break
138150
}
139151
}

0 commit comments

Comments
 (0)