Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-11-22 20:46:40 +0300
committerNick Thomas <nick@gitlab.com>2017-11-22 22:51:57 +0300
commit11d0787961b33efdbfdad9bf0bbc48afecc3cc53 (patch)
treee03250eba46094d657083cca9b938b4a6734bf1e /spec/unicorn
parent743fd67f73875dac071287ef8bb91a2392359ba3 (diff)
Speed up Unicorn specs by using a dummy Rack application instead of GitLab
Diffstat (limited to 'spec/unicorn')
-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