Skip to content

Commit

Permalink
Adds a test to capture #1835
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus committed Jul 23, 2019
1 parent 66769ab commit 54417d1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/test_puma_server_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class TestPumaServerSSL < Minitest::Test

def setup
return if DISABLE_SSL
port = UniquePort.call
host = "127.0.0.1"
@port = port = UniquePort.call
@host = host = "127.0.0.1"

app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }

Expand Down Expand Up @@ -80,6 +80,23 @@ def test_url_scheme_for_https
assert_equal "https", body
end

def test_request_wont_block_thread
# Open a connection and give enough data to trigger a read, then wait
socket = TCPSocket.new @host, @port
socket.write "x"
sleep 1

# Capture the amount of threads being used after connecting and being idle
thread_pool = @server.instance_variable_get(:@thread_pool)
busy_threads = thread_pool.spawned - thread_pool.waiting

socket.close

# The thread pool should be empty since the request would block on read
# and our request should have been moved to the reactor.
assert busy_threads.zero?, "Our connection is monopolizing a thread"
end

def test_very_large_return
giant = "x" * 2056610

Expand Down

0 comments on commit 54417d1

Please sign in to comment.