Conversation
MSP-Greg
left a comment
There was a problem hiding this comment.
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
endEDIT: "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_shutdownimplementation out of#graceful_shutdownto 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
:stateevent 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.