-
Notifications
You must be signed in to change notification settings - Fork 4.5k
xdsclient: fix TestServerFailureMetrics_BeforeResponseRecv test to wait for watch to start before stopping the listener #8217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xdsclient: fix TestServerFailureMetrics_BeforeResponseRecv test to wait for watch to start before stopping the listener #8217
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8217 +/- ##
==========================================
- Coverage 82.17% 82.08% -0.10%
==========================================
Files 410 410
Lines 40236 40236
==========================================
- Hits 33065 33028 -37
- Misses 5822 5852 +30
- Partials 1349 1356 +7 🚀 New features to boost your workflow:
|
…it for watch to start before stopping the listener
c31cf42
to
42a7de2
Compare
// Restart to prevent the attempt to create a new ADS stream after back off. | ||
lis.Restart() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is still racy because the backoff could have completed before the listener is restarted. There is an option that can be used to set a really long backoff duration instead.
grpc-go/xds/internal/xdsclient/pool.go
Lines 60 to 63 in 5edab9e
// StreamBackoffAfterFailure is the backoff function used to determine the | |
// backoff duration after stream failures. | |
// If unspecified, uses the default value used in non-test code. | |
StreamBackoffAfterFailure func(int) time.Duration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in this particular test case it won't happen because we are setting the watch expiry timeout which is way shorter than the back off. So, watch will just expire before backoff anyway but before that we would received the stream error.
select { | ||
case <-ctx.Done(): | ||
t.Fatal("Timeout when waiting for ADS stream to close") | ||
default: | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does ~nothing now - delete it?
And before, it should have been written as: if ctx.Err() != nil {...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah not needed because both lis.Stop() and lis.Restart() are serialized by lock.
Replaced the similar select block in the other test with if ctx.Err() != nil {...}
…it for watch to start before stopping the listener (grpc#8217)
…it for watch to start before stopping the listener (grpc#8217)
Fixes: #8211
TestServerFailureMetrics_BeforeResponseRecv
was flaking because of race between listener watch to start and closing the listener and if watch hasn't started the stream errors won't be received and server failure metric won't be emitted. Adding the hook to wait for stream to open before stopping the listener have fixed the race.RELEASE NOTES: None
Successful forge run