summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-11-22 21:28:13 +0000
committerRémy Coutable <remy@rymai.me>2017-11-22 21:28:13 +0000
commit50a5d638e56443ffc7d4d08b3706b9c63e372dfa (patch)
tree6ad05b3d5984832187425d70ba45ba4ba4a25bc0 /spec
parentf5534059011b6752c28d7d6d7538897d6da369ae (diff)
parent11d0787961b33efdbfdad9bf0bbc48afecc3cc53 (diff)
downloadgitlab-ce-50a5d638e56443ffc7d4d08b3706b9c63e372dfa.tar.gz
Merge branch '32620-speed-up-unicorn-specs' into 'master'
Speed up Unicorn specs by using a dummy Rack application instead of GitLab Closes #32620 See merge request gitlab-org/gitlab-ce!15548
Diffstat (limited to 'spec')
-rw-r--r--spec/unicorn/unicorn_spec.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/unicorn/unicorn_spec.rb b/spec/unicorn/unicorn_spec.rb
index 79a566975df..a4cf479a339 100644
--- a/spec/unicorn/unicorn_spec.rb
+++ b/spec/unicorn/unicorn_spec.rb
@@ -37,7 +37,22 @@ describe 'Unicorn' do
config_path = 'tmp/tests/unicorn.rb'
File.write(config_path, config_lines.join("\n") + "\n")
- cmd = %W[unicorn -E test -c #{config_path} #{Rails.root.join('config.ru')}]
+ rackup_path = 'tmp/tests/config.ru'
+ File.write(rackup_path, <<~EOS)
+ app =
+ proc do |env|
+ if env['REQUEST_METHOD'] == 'GET'
+ [200, {}, [Process.pid]]
+ else
+ Process.kill(env['QUERY_STRING'], Process.pid)
+ [200, {}, ['Bye!']]
+ end
+ end
+
+ run app
+ EOS
+
+ cmd = %W[unicorn -E test -c #{config_path} #{rackup_path}]
@unicorn_master_pid = spawn(*cmd)
wait_unicorn_boot!(@unicorn_master_pid, ready_file)
WebMock.allow_net_connect!
@@ -45,14 +60,14 @@ describe 'Unicorn' do
%w[SIGQUIT SIGTERM SIGKILL].each do |signal|
it "has a worker that self-terminates on signal #{signal}" do
- response = Excon.get('unix:///unicorn_test/pid', socket: @socket_path)
+ response = Excon.get('unix://', socket: @socket_path)
expect(response.status).to eq(200)
worker_pid = response.body.to_i
expect(worker_pid).to be > 0
begin
- Excon.post('unix:///unicorn_test/kill', socket: @socket_path, body: "signal=#{signal}")
+ Excon.post("unix://?#{signal}", socket: @socket_path)
rescue Excon::Error::Socket
# The connection may be closed abruptly
end