diff --git a/app/controllers/unicorn_test_controller.rb b/app/controllers/unicorn_test_controller.rb deleted file mode 100644 index ed04bd1f77d5af9a008f30275d314eaea20dee52..0000000000000000000000000000000000000000 --- a/app/controllers/unicorn_test_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -# :nocov: -if Rails.env.test? - class UnicornTestController < ActionController::Base - def pid - render plain: Process.pid.to_s - end - - def kill - Process.kill(params[:signal], Process.pid) - render plain: 'Bye!' - end - end -end -# :nocov: diff --git a/config/routes.rb b/config/routes.rb index fc13dc4865f098caa4d69334fa3803c74aad13d2..4f27fea0e926cdc56eadc47034fb3bc59d1f2771 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -100,7 +100,5 @@ Rails.application.routes.draw do root to: "root#index" - draw :test if Rails.env.test? - get '*unmatched_route', to: 'application#route_not_found' end diff --git a/config/routes/test.rb b/config/routes/test.rb deleted file mode 100644 index ac477cdbbbc2c69a892df513b05ed6665686569a..0000000000000000000000000000000000000000 --- a/config/routes/test.rb +++ /dev/null @@ -1,2 +0,0 @@ -get '/unicorn_test/pid' => 'unicorn_test#pid' -post '/unicorn_test/kill' => 'unicorn_test#kill' diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb index 9a91f8bf96ae6fbbe11b6f05fd222d701ff3b2a5..7e5dfd3350204416720d7693810b8de336f952e8 100644 --- a/lib/gitlab/path_regex.rb +++ b/lib/gitlab/path_regex.rb @@ -51,7 +51,6 @@ module Gitlab slash-command-logo.png snippets u - unicorn_test unsubscribes uploads users diff --git a/lib/tasks/brakeman.rake b/lib/tasks/brakeman.rake index 99b3168d9eb85c7c43073918f3222c9a410dda1c..2301ec9b2288c16b0a32701e40c679a8f107dfcd 100644 --- a/lib/tasks/brakeman.rake +++ b/lib/tasks/brakeman.rake @@ -2,7 +2,7 @@ desc 'Security check via brakeman' task :brakeman do # We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge # requests are welcome! - if system(*%w(brakeman --no-progress --skip-files lib/backup/repository.rb,app/controllers/unicorn_test_controller.rb -w3 -z)) + if system(*%w(brakeman --no-progress --skip-files lib/backup/repository.rb -w3 -z)) puts 'Security check succeed' else puts 'Security check failed' diff --git a/spec/unicorn/unicorn_spec.rb b/spec/unicorn/unicorn_spec.rb index 79a566975dfc3252483b3bd70f1de97342a8b779..a4cf479a33953eb0b2642d48af8c0ef831a8538e 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