xdsclient/test: deflake TestTimerAndWatchStateOnSendCallback (#6169)

This commit is contained in:
Arvind Bright 2023-04-03 11:54:07 -07:00 committed by GitHub
parent e97991991c
commit a51779dfbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 10 deletions

View File

@ -124,17 +124,20 @@ func (s) TestTimerAndWatchStateOnSendCallback(t *testing.T) {
if err := updateResourceInServer(ctx, ms, rn, nodeID); err != nil {
t.Fatalf("Failed to update server with resource: %q; err: %q", rn, err)
}
select {
case <-ctx.Done():
t.Fatal("Test timed out before watcher received an update from server.")
case err := <-w.ErrorCh:
t.Fatalf("Watch got an unexpected error update: %q. Want valid updates.", err)
case <-w.UpdateCh:
// This means the OnUpdate callback was invoked and the watcher was notified.
}
if err := compareWatchState(a, rn, watchStateReceived); err != nil {
t.Fatal(err)
for {
select {
case <-ctx.Done():
t.Fatal("Test timed out before watcher received an update from server.")
case <-w.ErrorCh:
case <-w.UpdateCh:
// This means the OnUpdate callback was invoked and the watcher was notified.
if err := compareWatchState(a, rn, watchStateReceived); err != nil {
t.Fatal(err)
}
return
}
}
}
// This tests the resource's watch state transition when the ADS stream is closed