mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Avoid hardcoding ports
When a test that boots a server fails it may not properly close out the port. When this happens there is a cascading failure as all other tests that use that port also fail. It becomes hard to find the actual failure reason. This commit uses a new number of every time port is used.
This commit is contained in:
parent
441a42e185
commit
0d28652c3e
4 changed files with 14 additions and 5 deletions
|
@ -43,6 +43,15 @@ def hit(uris)
|
|||
end
|
||||
end
|
||||
|
||||
module UniquePort
|
||||
@port = 3211
|
||||
|
||||
def self.call
|
||||
@port += 1
|
||||
@port
|
||||
end
|
||||
end
|
||||
|
||||
module TimeoutEveryTestCase
|
||||
# our own subclass so we never confused different timeouts
|
||||
class TestTookTooLong < Timeout::Error
|
||||
|
|
|
@ -21,14 +21,14 @@ class TestPersistent < Minitest::Test
|
|||
end
|
||||
|
||||
@host = "127.0.0.1"
|
||||
@port = 9988
|
||||
@port = UniquePort.call
|
||||
|
||||
@server = Puma::Server.new @simple
|
||||
@server.add_tcp_listener "127.0.0.1", 9988
|
||||
@server.add_tcp_listener "127.0.0.1", @port
|
||||
@server.max_threads = 1
|
||||
@server.run
|
||||
|
||||
@client = TCPSocket.new "127.0.0.1", 9988
|
||||
@client = TCPSocket.new "127.0.0.1", @port
|
||||
end
|
||||
|
||||
def teardown
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestPumaServerSSL < Minitest::Test
|
|||
|
||||
def setup
|
||||
return if DISABLE_SSL
|
||||
port = 3212
|
||||
port = UniquePort.call
|
||||
host = "127.0.0.1"
|
||||
|
||||
app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
|
||||
|
|
|
@ -3,7 +3,7 @@ require_relative "helper"
|
|||
class TestTCPRack < Minitest::Test
|
||||
|
||||
def setup
|
||||
@port = 3212
|
||||
@port = UniquePort.call
|
||||
@host = "127.0.0.1"
|
||||
|
||||
@events = Puma::Events.new STDOUT, STDERR
|
||||
|
|
Loading…
Reference in a new issue