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
Refactor drain on shutdown #2600
Conversation
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.
Any idea about the Ruby 2.2 fails? Otherwise, LGTM.
Maybe change the test to the following? Passed in my fork... def test_drain_on_shutdown
server_run(drain_on_shutdown: true, max_threads: 1) do
sleep 0.005
[200, {}, ["DONE"]]
end
connections = Array.new(20) { send_http "GET / HTTP/1.0\r\n\r\n" }
@server.stop
@thread.join
connections.each do |s|
assert_match 'DONE', s.read
end
end
def test_not_drain_on_shutdown
server_run(max_threads: 1) do
sleep 0.005
[200, {}, ["DONE"]]
end
connections = Array.new(20) { send_http "GET / HTTP/1.0\r\n\r\n" }
@server.stop
@thread.join
bad = 0
connections.each do |s|
begin
assert_match 'DONE', s.read
rescue Errno::ECONNRESET
bad += 1
end
end
assert_operator bad, :>, 5
end EDIT: "Greg, what is Attached patch file (remove |
Oops! I also added a |
Please have a look at the errors in the 2.2 test logs. I added the Something is amiss with my Windows Ruby 2.2 (build system) on the new desktop, I can't build Puma, so I just used CI... |
2fa45e8
to
98df869
Compare
Oops again- I messed up the |
98df869
to
0689c04
Compare
Also add test coverage for drain_on_shutdown option.
0689c04
to
bb566d4
Compare
* Refactor test_puma_server#server_run for option arguments * Refactor drain_on_shutdown into main server accept loop Also add test coverage for drain_on_shutdown option.
Description
This refactoring PR moves the
drain_on_shutdown
implementation out of#graceful_shutdown
to reduce duplication with the main server accept loop, including a test covering the basic behavior of this option to prevent regressions.There might be some slight change in timing around when exactly the
:state
event gets fired (before or after connections are all drained), but this doesn't seem important enough to worry about (there was zero test coverage around it).TestPumaServer#server_run
, in order to allow arbitrary option arguments to be passed. This made writing the added test with a custom option a bit easier and more readable, and allowed me to clean up a bit of boilerplate in the rest of the test suite.Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.