-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
grpc: server should send RST_STREAM when deadline is exceeded #7892
base: master
Are you sure you want to change the base?
grpc: server should send RST_STREAM when deadline is exceeded #7892
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7892 +/- ##
==========================================
- Coverage 82.04% 81.95% -0.09%
==========================================
Files 377 377
Lines 38117 38183 +66
==========================================
+ Hits 31272 31294 +22
- Misses 5548 5585 +37
- Partials 1297 1304 +7
|
s.WriteStatus(status.New(codes.DeadlineExceeded, "too slow")) | ||
select { |
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.
you have to wait on channel as well otherwise you are not verifying the if your function was triggered
select {
case <-ch: // Signal received, continue with the test
case <-s.ctx.Done():
case <-time.After(5 * time.Second):
t.Errorf("timeout waiting for ctx.Done")
return
}
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.
done
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.
@misvivek i just saw you are doing this inside goroutine which won't affect the execution of test whether pass or fail.
You need to move both no op function setting and channel waiting code outside of go routine and check at the end when go runStream(s) is done, perhaps at the end after checking the trailers. So I would structure it like this
// rst flag setting to verify the noop function: signalDeadlineExceeded
ch := make(chan struct{}, 1)
origSignalDeadlineExceeded := signalDeadlineExceeded
signalDeadlineExceeded = func() {
ch <- struct{}{}
}
defer func() {
signalDeadlineExceeded = origSignalDeadlineExceeded
}()
runStream := func(s *ServerStream) {....}
...
...
checkHeaderAndTrailer(t, rw, wantHeader, wantTrailer)
select {
case <-ch: // Signal received, continue with the test
case <-time.After(5 * time.Second):
t.Errorf("timeout waiting for ctx.Done")
return
}
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.
And i think the test will fail then because you haven't yet fixed the bug.
@misvivek you need to write the test as I mentioned above and then verify if the test is failing. If it is, then we have to fix the bug first. |
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.
Need to fix the bug as well along with test
Fixes: #2886