diff --git a/test/integration/apps/rack_input_class.ru b/test/integration/apps/rack_input_class.ru new file mode 100644 index 00000000..53350bc2 --- /dev/null +++ b/test/integration/apps/rack_input_class.ru @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +app = lambda do |env| + [ 200, {}, [env["rack.input"].class.name] ] +end +run app diff --git a/test/integration/write-on-close.ru b/test/integration/apps/write-on-close.ru similarity index 100% rename from test/integration/write-on-close.ru rename to test/integration/apps/write-on-close.ru diff --git a/test/integration/t0013-rewindable-input-false.sh b/test/integration/t0013-rewindable-input-false.sh deleted file mode 100755 index 4c705fd8..00000000 --- a/test/integration/t0013-rewindable-input-false.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -. ./test-lib.sh -t_plan 4 "rewindable_input toggled to false" - -t_begin "setup and start" && { - pitchfork_setup - echo rewindable_input false >> $pitchfork_config - pitchfork_spawn -c $pitchfork_config t0013.ru - pitchfork_wait_start -} - -t_begin "ensure worker is started" && { - test xOK = x$(curl -T t0013.ru -H Expect: -vsSf http://$listen/) -} - -t_begin "killing succeeds" && { - kill $pitchfork_pid -} - -t_begin "check stderr" && { - check_stderr -} - -t_done diff --git a/test/integration/t0013.ru b/test/integration/t0013.ru deleted file mode 100644 index 11389c03..00000000 --- a/test/integration/t0013.ru +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true -#\ -E none -use Rack::ContentLength -use Rack::ContentType, 'text/plain' -app = lambda do |env| - case env['rack.input'] - when Pitchfork::StreamInput - [ 200, {}, %w(OK) ] - else - [ 500, {}, %w(NO) ] - end -end -run app diff --git a/test/integration/t0014-rewindable-input-true.sh b/test/integration/t0014-rewindable-input-true.sh deleted file mode 100755 index d9a4f39e..00000000 --- a/test/integration/t0014-rewindable-input-true.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -. ./test-lib.sh -t_plan 4 "rewindable_input toggled to true" - -t_begin "setup and start" && { - pitchfork_setup - echo rewindable_input true >> $pitchfork_config - pitchfork_spawn -c $pitchfork_config t0014.ru - pitchfork_wait_start -} - -t_begin "ensure worker is started" && { - test xOK = x$(curl -T t0014.ru -sSf http://$listen/) -} - -t_begin "killing succeeds" && { - kill $pitchfork_pid -} - -t_begin "check stderr" && { - check_stderr -} - -t_done diff --git a/test/integration/t0014.ru b/test/integration/t0014.ru deleted file mode 100644 index 0dcafde5..00000000 --- a/test/integration/t0014.ru +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true -#\ -E none -use Rack::ContentLength -use Rack::ContentType, 'text/plain' -app = lambda do |env| - case env['rack.input'] - when Pitchfork::TeeInput - [ 200, {}, %w(OK) ] - else - [ 500, {}, %w(NO) ] - end -end -run app diff --git a/test/integration/t0015-configurator-internals.sh b/test/integration/t0015-configurator-internals.sh deleted file mode 100755 index 250ddb68..00000000 --- a/test/integration/t0015-configurator-internals.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -. ./test-lib.sh -t_plan 4 "configurator internals tests (from FAQ)" - -t_begin "setup and start" && { - pitchfork_setup - cat >> $pitchfork_config <"https"' -} - -t_begin "killing succeeds" && { - kill $pitchfork_pid -} - -t_begin "no errors" && check_stderr - -t_done diff --git a/test/integration/t0018-write-on-close.sh b/test/integration/t0018-write-on-close.sh deleted file mode 100755 index 2201203f..00000000 --- a/test/integration/t0018-write-on-close.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -. ./test-lib.sh -t_plan 4 "write-on-close tests for funky response-bodies" - -t_begin "setup and start" && { - pitchfork_setup - pitchfork_spawn -c $pitchfork_config write-on-close.ru - pitchfork_wait_start -} - -t_begin "write-on-close response body succeeds" && { - test xGoodbye = x"$(curl -sSf http://$listen/)" -} - -t_begin "killing succeeds" && { - kill $pitchfork_pid -} - -t_begin "check stderr" && { - check_stderr -} - -t_done diff --git a/test/integration/t0301.ru b/test/integration/t0301.ru deleted file mode 100644 index 8bbcbccf..00000000 --- a/test/integration/t0301.ru +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true -#\-N --debug -run(lambda do |env| - case env['PATH_INFO'] - when '/vars' - b = "debug=#{$DEBUG.inspect}\n" \ - "lint=#{caller.grep(%r{rack/lint\.rb})[0].split(':')[0]}\n" - end - h = { - 'content-length' => b.size.to_s, - 'content-type' => 'text/plain', - } - [ 200, h, [ b ] ] -end) diff --git a/test/integration/test_configuration.rb b/test/integration/test_configuration.rb index cf7f10bc..94c1cdee 100644 --- a/test/integration/test_configuration.rb +++ b/test/integration/test_configuration.rb @@ -140,7 +140,7 @@ def test_listen_queues addr, port = unused_port pid = spawn_server(app: File.join(ROOT, "test/integration/env.ru"), config: <<~CONFIG) - listen "#{addr}:#{port}", queues: 2, workers_per_queue: 1 + listen "#{addr}:#{port}", queues: 2, queues_per_worker: 1 worker_processes 2 CONFIG @@ -153,4 +153,24 @@ def test_listen_queues assert_clean_shutdown(pid) end + + def test_modify_internals + addr, port = unused_port + + pid = spawn_server(app: File.join(ROOT, "test/integration/env.ru"), config: <<~CONFIG) + listen "#{addr}:#{port}", queues: 1 + worker_processes 1 + + HttpParser::DEFAULTS["rack.url_scheme"] = "https" + Configurator::DEFAULTS[:logger].progname = "[FOO]" + CONFIG + + assert_healthy("http://#{addr}:#{port}") + + env = Net::HTTP.get(URI("http://#{addr}:#{port}/")) + assert_match('"rack.url_scheme"=>"https"', env) + assert_stderr(/\[FOO\]/) + + assert_clean_shutdown(pid) + end end diff --git a/test/integration/test_http_basic.rb b/test/integration/test_http_basic.rb index 9c6b065f..d5a65f43 100644 --- a/test/integration/test_http_basic.rb +++ b/test/integration/test_http_basic.rb @@ -120,4 +120,20 @@ def test_streaming_body assert_clean_shutdown(pid) end + + def test_write_on_close + addr, port = unused_port + + pid = spawn_server(app: File.join(ROOT, "test/integration/apps/write-on-close.ru"), config: <<~CONFIG) + listen "#{addr}:#{port}" + worker_processes 1 + CONFIG + + assert_healthy("http://#{addr}:#{port}") + + response = Net::HTTP.get_response(URI("http://#{addr}:#{port}")) + assert_equal "Goodbye", response.body + + assert_clean_shutdown(pid) + end end diff --git a/test/integration/test_rewindable_input_test.rb b/test/integration/test_rewindable_input_test.rb new file mode 100644 index 00000000..83fbce7e --- /dev/null +++ b/test/integration/test_rewindable_input_test.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true +require "integration_test_helper" + +class RewindableInputTest < Pitchfork::IntegrationTest + def test_rewindable_input_false + addr, port = unused_port + + pid = spawn_server(app: File.join(ROOT, "test/integration/apps/rack_input_class.ru"), lint: false, config: <<~CONFIG) + listen "#{addr}:#{port}" + worker_processes 1 + + rewindable_input false + CONFIG + + assert_healthy("http://#{addr}:#{port}") + + http = Net::HTTP.new(addr, port) + assert_equal "Pitchfork::StreamInput", http.send_request("PUT", "/", "foo").body + + assert_clean_shutdown(pid) + end + + def test_rewindable_input_true + addr, port = unused_port + + pid = spawn_server(app: File.join(ROOT, "test/integration/apps/rack_input_class.ru"), lint: false, config: <<~CONFIG) + listen "#{addr}:#{port}" + worker_processes 1 + + rewindable_input true + CONFIG + + assert_healthy("http://#{addr}:#{port}") + + http = Net::HTTP.new(addr, port) + assert_equal "Pitchfork::TeeInput", http.send_request("PUT", "/", "foo").body + + assert_clean_shutdown(pid) + end +end