-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: fixup test/test_web_concurrency_auto.rb, add 'concurrent-ruby' to…
… main Gemfile (puma#3545)
- Loading branch information
Showing
5 changed files
with
45 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,59 @@ | ||
require_relative "helper" | ||
require_relative "helpers/integration" | ||
require_relative "helpers/test_puma/puma_socket" | ||
|
||
require "puma/configuration" | ||
require 'puma/log_writer' | ||
|
||
class TestWebConcurrencyAuto < TestIntegration | ||
|
||
include TestPuma::PumaSocket | ||
|
||
ENV_WC_TEST = { | ||
# -W0 removes logging of bundled gem warnings | ||
"RUBYOPT" => "#{ENV["RUBYOPT"]} -W0", | ||
"WEB_CONCURRENCY" => "auto" | ||
} | ||
|
||
def teardown | ||
return if skipped? | ||
super | ||
end | ||
|
||
def test_web_concurrency_with_concurrent_ruby_available | ||
skip_unless :fork | ||
env = { | ||
"BUNDLE_GEMFILE" => "#{__dir__}/web_concurrency_test/Gemfile", | ||
"WEB_CONCURRENCY" => "auto" | ||
} | ||
Dir.chdir("#{__dir__}/web_concurrency_test") do | ||
with_unbundled_env do | ||
silent_and_checked_system_command("bundle config --local path vendor/bundle") | ||
silent_and_checked_system_command("bundle install") | ||
end | ||
cli_server set_pumactl_args, env: env | ||
|
||
app = "app { |_| [200, {}, [Concurrent.available_processor_count.to_i.to_s]] }\n" | ||
|
||
cli_server set_pumactl_args, env: ENV_WC_TEST, config: app | ||
|
||
expected = send_http_read_resp_body GET_11 | ||
assert_equal(expected, get_stats.fetch("workers").to_s) | ||
end | ||
|
||
# Rename the processor_counter file, then restore | ||
def test_web_concurrency_with_concurrent_ruby_unavailable | ||
file_path = nil | ||
skip_unless :fork | ||
|
||
ccr_gem = 'concurrent-ruby' | ||
file_require = 'concurrent/utility/processor_counter' | ||
file_path = Dir["#{ENV['GEM_HOME']}/gems/#{ccr_gem}-*/lib/#{ccr_gem}/#{file_require}.rb"].first | ||
|
||
if file_path && File.exist?(file_path) | ||
File.rename file_path, "#{file_path}_orig" | ||
else | ||
# cannot find concurrent-ruby file? | ||
end | ||
|
||
connection = connect("/worker_count") | ||
body = read_body(connection, 1) | ||
assert_equal(get_stats.fetch("workers").to_s, body) | ||
out, err = capture_io do | ||
assert_raises(LoadError) { Puma::Configuration.new({}, {}, ENV_WC_TEST) } | ||
end | ||
assert_includes err, 'Please add "concurrent-ruby" to your Gemfile' | ||
|
||
ensure | ||
if file_path && File.exist?("#{file_path}_orig") | ||
File.rename "#{file_path}_orig", file_path | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.