diff options
author | Eric Wong <e@80x24.org> | 2013-10-30 01:50:12 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-30 07:00:55 +0000 |
commit | 68fc0c10468f0fefa6777bdabf4712d33de1aa42 (patch) | |
tree | 46ed4bd684bed91c3440a1d57c9790db7b91896a /test | |
parent | 72e20c9d7aac1837f1565cff5856e50c692304be (diff) | |
download | yahns-68fc0c10468f0fefa6777bdabf4712d33de1aa42.tar.gz |
This is probably not needed and just adds contention, but it makes experimenting easier. While we're at it, validate minimum values of for sndbuf/rcvbuf along with this new threads value, too.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_mt_accept.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/test_mt_accept.rb b/test/test_mt_accept.rb new file mode 100644 index 0000000..e006af8 --- /dev/null +++ b/test/test_mt_accept.rb @@ -0,0 +1,48 @@ +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require_relative 'server_helper' +require 'rack/lobster' + +class TestMtAccept < Testcase + ENV["N"].to_i > 1 and parallelize_me! + include ServerHelper + alias setup server_helper_setup + alias teardown server_helper_teardown + + def test_mt_accept + err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] + opts = { threads: 1 } + cfg.instance_eval do + GTL.synchronize do + app(:rack, Rack::Lobster.new) { listen "#{host}:#{port}", threads: 1 } + end + stderr_path err.path + end + pid = mkserver(cfg) + Net::HTTP.start(host, port) do |http| + assert_equal 200, http.request(Net::HTTP::Get.new("/")).code.to_i + end + orig_count = Dir["/proc/#{pid}/task/*"].size + quit_wait(pid) + + cfg = Yahns::Config.new + opts = { threads: 1 } + cfg.instance_eval do + GTL.synchronize do + app(:rack, Rack::Lobster.new) { listen "#{host}:#{port}", threads: 2 } + end + stderr_path err.path + end + pid = mkserver(cfg) + Net::HTTP.start(host, port) do |http| + assert_equal 200, http.request(Net::HTTP::Get.new("/")).code.to_i + end + Timeout.timeout(30) do + begin + new_count = Dir["/proc/#{pid}/task/*"].size + end until new_count == (orig_count + 1) && sleep(0.01) + end + ensure + quit_wait(pid) + end +end if RUBY_PLATFORM =~ /linux/ && File.directory?("/proc") |