Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
11d07879
Commit
11d07879
authored
Nov 22, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up Unicorn specs by using a dummy Rack application instead of GitLab
parent
743fd67f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
23 deletions
+19
-23
app/controllers/unicorn_test_controller.rb
app/controllers/unicorn_test_controller.rb
+0
-14
config/routes.rb
config/routes.rb
+0
-2
config/routes/test.rb
config/routes/test.rb
+0
-2
lib/gitlab/path_regex.rb
lib/gitlab/path_regex.rb
+0
-1
lib/tasks/brakeman.rake
lib/tasks/brakeman.rake
+1
-1
spec/unicorn/unicorn_spec.rb
spec/unicorn/unicorn_spec.rb
+18
-3
No files found.
app/controllers/unicorn_test_controller.rb
deleted
100644 → 0
View file @
743fd67f
# :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:
config/routes.rb
View file @
11d07879
...
@@ -100,7 +100,5 @@ Rails.application.routes.draw do
...
@@ -100,7 +100,5 @@ Rails.application.routes.draw do
root
to:
"root#index"
root
to:
"root#index"
draw
:test
if
Rails
.
env
.
test?
get
'*unmatched_route'
,
to:
'application#route_not_found'
get
'*unmatched_route'
,
to:
'application#route_not_found'
end
end
config/routes/test.rb
deleted
100644 → 0
View file @
743fd67f
get
'/unicorn_test/pid'
=>
'unicorn_test#pid'
post
'/unicorn_test/kill'
=>
'unicorn_test#kill'
lib/gitlab/path_regex.rb
View file @
11d07879
...
@@ -51,7 +51,6 @@ module Gitlab
...
@@ -51,7 +51,6 @@ module Gitlab
slash-command-logo.png
slash-command-logo.png
snippets
snippets
u
u
unicorn_test
unsubscribes
unsubscribes
uploads
uploads
users
users
...
...
lib/tasks/brakeman.rake
View file @
11d07879
...
@@ -2,7 +2,7 @@ desc 'Security check via brakeman'
...
@@ -2,7 +2,7 @@ desc 'Security check via brakeman'
task
:brakeman
do
task
:brakeman
do
# We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge
# We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge
# requests are welcome!
# 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'
puts
'Security check succeed'
else
else
puts
'Security check failed'
puts
'Security check failed'
...
...
spec/unicorn/unicorn_spec.rb
View file @
11d07879
...
@@ -37,7 +37,22 @@ describe 'Unicorn' do
...
@@ -37,7 +37,22 @@ describe 'Unicorn' do
config_path
=
'tmp/tests/unicorn.rb'
config_path
=
'tmp/tests/unicorn.rb'
File
.
write
(
config_path
,
config_lines
.
join
(
"
\n
"
)
+
"
\n
"
)
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
)
@unicorn_master_pid
=
spawn
(
*
cmd
)
wait_unicorn_boot!
(
@unicorn_master_pid
,
ready_file
)
wait_unicorn_boot!
(
@unicorn_master_pid
,
ready_file
)
WebMock
.
allow_net_connect!
WebMock
.
allow_net_connect!
...
@@ -45,14 +60,14 @@ describe 'Unicorn' do
...
@@ -45,14 +60,14 @@ describe 'Unicorn' do
%w[SIGQUIT SIGTERM SIGKILL]
.
each
do
|
signal
|
%w[SIGQUIT SIGTERM SIGKILL]
.
each
do
|
signal
|
it
"has a worker that self-terminates on signal
#{
signal
}
"
do
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
)
expect
(
response
.
status
).
to
eq
(
200
)
worker_pid
=
response
.
body
.
to_i
worker_pid
=
response
.
body
.
to_i
expect
(
worker_pid
).
to
be
>
0
expect
(
worker_pid
).
to
be
>
0
begin
begin
Excon
.
post
(
'unix:///unicorn_test/kill'
,
socket:
@socket_path
,
body:
"signal=
#{
signal
}
"
)
Excon
.
post
(
"unix://?
#{
signal
}
"
,
socket:
@socket_path
)
rescue
Excon
::
Error
::
Socket
rescue
Excon
::
Error
::
Socket
# The connection may be closed abruptly
# The connection may be closed abruptly
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment