Skip to content

Commit

Permalink
Configure some options to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cafedomancer committed Sep 15, 2022
1 parent d7f7c00 commit a427356
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions test/test_integration_ssl.rb
@@ -1,5 +1,6 @@
require_relative 'helper'
require_relative "helpers/integration"
require "puma/log_writer"

# These tests are used to verify that Puma works with SSL sockets. Only
# integration tests isolate the server from the test environment, so there
Expand Down Expand Up @@ -97,8 +98,8 @@ def test_ssl_run_with_curl_client
skip_if :windows; require 'stringio'

app = lambda { |_| [200, { 'Content-Type' => 'text/plain' }, ["HELLO", ' ', "THERE"]] }
server = Puma::Server.new(app)
server.max_threads = 1
opts = {max_threads: 1}
server = Puma::Server.new app, Puma::LogWriter.stdio, Puma::Events.new, opts
if Puma.jruby?
ssl_params = {
'keystore' => File.expand_path('../examples/puma/client-certs/keystore.jks', __dir__),
Expand Down
11 changes: 6 additions & 5 deletions test/test_persistent.rb
@@ -1,4 +1,5 @@
require_relative "helper"
require "puma/log_writer"

class TestPersistent < Minitest::Test

Expand All @@ -23,9 +24,9 @@ def setup
[status, @headers, @body]
end

@server = Puma::Server.new @simple
opts = {min_threads: 1, max_threads: 1}
@server = Puma::Server.new @simple, Puma::LogWriter.stdio, Puma::Events.new, opts
@port = (@server.add_tcp_listener HOST, 0).addr[1]
@server.max_threads = 1
@server.run
sleep 0.15 if Puma.jruby?
@client = TCPSocket.new HOST, @port
Expand Down Expand Up @@ -156,7 +157,7 @@ def test_one_with_keep_alive_header
end

def test_persistent_timeout
@server.persistent_timeout = 1
@server.instance_variable_set(:@persistent_timeout, 1)
@client << @valid_request
sz = @body[0].size.to_s

Expand Down Expand Up @@ -193,7 +194,7 @@ def test_allow_app_to_chunk_itself


def test_two_requests_in_one_chunk
@server.persistent_timeout = 3
@server.instance_variable_set(:@persistent_timeout, 3)

req = @valid_request.to_s
req += "GET /second HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\n\r\n"
Expand All @@ -210,7 +211,7 @@ def test_two_requests_in_one_chunk
end

def test_second_request_not_in_first_req_body
@server.persistent_timeout = 3
@server.instance_variable_set(:@persistent_timeout, 3)

req = @valid_request.to_s
req += "GET /second HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\n\r\n"
Expand Down
2 changes: 1 addition & 1 deletion test/test_puma_server.rb
Expand Up @@ -529,7 +529,7 @@ def test_timeout_data_no_queue

# https://github.com/puma/puma/issues/2574
def test_no_timeout_after_data_received
@server.first_data_timeout = 1
@server.instance_variable_set(:@first_data_timeout, 1)
server_run

sock = send_http "POST / HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\nContent-Length: 11\r\n\r\n"
Expand Down
2 changes: 1 addition & 1 deletion test/test_response_header.rb
Expand Up @@ -28,7 +28,7 @@ def teardown
def server_run(app: @app, early_hints: false)
@server.app = app
@port = (@server.add_tcp_listener @host, 0).addr[1]
@server.early_hints = true if early_hints
@server.instance_variable_set(:@early_hints, true) if early_hints
@server.run
end

Expand Down

0 comments on commit a427356

Please sign in to comment.