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
Boxiang Sun
gitlab-ce
Commits
6d60e265
Commit
6d60e265
authored
Jul 05, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spaces between test phases
+ fix wrong test setup
parent
2f875c40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
spec/controllers/health_check_controller_spec.rb
spec/controllers/health_check_controller_spec.rb
+14
-1
spec/controllers/health_controller_spec.rb
spec/controllers/health_controller_spec.rb
+5
-1
No files found.
config/initializers/1_settings.rb
View file @
6d60e265
...
@@ -498,7 +498,7 @@ Settings.webpack.dev_server['port'] ||= 3808
...
@@ -498,7 +498,7 @@ Settings.webpack.dev_server['port'] ||= 3808
# Monitoring settings
# Monitoring settings
#
#
Settings
[
'monitoring'
]
||=
Settingslogic
.
new
({})
Settings
[
'monitoring'
]
||=
Settingslogic
.
new
({})
Settings
.
monitoring
[
'ip_whitelist'
]
||=
%w{127.0.0.1/8}
Settings
.
monitoring
[
'ip_whitelist'
]
||=
[
'127.0.0.1/8'
]
#
#
# Prometheus metrics settings
# Prometheus metrics settings
...
...
spec/controllers/health_check_controller_spec.rb
View file @
6d60e265
...
@@ -10,7 +10,7 @@ describe HealthCheckController do
...
@@ -10,7 +10,7 @@ describe HealthCheckController do
let
(
:not_whitelisted_ip
)
{
'127.0.0.2'
}
let
(
:not_whitelisted_ip
)
{
'127.0.0.2'
}
before
do
before
do
allow
(
Settings
.
monitoring
).
to
receive
(
:ip_whitelist
).
and_return
([
IPAddr
.
new
(
whitelisted_ip
)
])
allow
(
Settings
.
monitoring
).
to
receive
(
:ip_whitelist
).
and_return
([
whitelisted_ip
])
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
end
end
...
@@ -22,19 +22,23 @@ describe HealthCheckController do
...
@@ -22,19 +22,23 @@ describe HealthCheckController do
it
'returns a not found page'
do
it
'returns a not found page'
do
get
:index
get
:index
expect
(
response
).
to
be_not_found
expect
(
response
).
to
be_not_found
end
end
context
'when services are accessed with token'
do
context
'when services are accessed with token'
do
it
'supports passing the token in the header'
do
it
'supports passing the token in the header'
do
request
.
headers
[
'TOKEN'
]
=
token
request
.
headers
[
'TOKEN'
]
=
token
get
:index
get
:index
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
content_type
).
to
eq
'text/plain'
expect
(
response
.
content_type
).
to
eq
'text/plain'
end
end
it
'supports successful plaintest response'
do
it
'supports successful plaintest response'
do
get
:index
,
token:
token
get
:index
,
token:
token
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
content_type
).
to
eq
'text/plain'
expect
(
response
.
content_type
).
to
eq
'text/plain'
end
end
...
@@ -50,12 +54,14 @@ describe HealthCheckController do
...
@@ -50,12 +54,14 @@ describe HealthCheckController do
it
'supports successful plaintest response'
do
it
'supports successful plaintest response'
do
get
:index
get
:index
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
content_type
).
to
eq
'text/plain'
expect
(
response
.
content_type
).
to
eq
'text/plain'
end
end
it
'supports successful json response'
do
it
'supports successful json response'
do
get
:index
,
format: :json
get
:index
,
format: :json
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
json_response
[
'healthy'
]).
to
be
true
expect
(
json_response
[
'healthy'
]).
to
be
true
...
@@ -63,6 +69,7 @@ describe HealthCheckController do
...
@@ -63,6 +69,7 @@ describe HealthCheckController do
it
'supports successful xml response'
do
it
'supports successful xml response'
do
get
:index
,
format: :xml
get
:index
,
format: :xml
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
content_type
).
to
eq
'application/xml'
expect
(
response
.
content_type
).
to
eq
'application/xml'
expect
(
xml_response
[
'healthy'
]).
to
be
true
expect
(
xml_response
[
'healthy'
]).
to
be
true
...
@@ -70,6 +77,7 @@ describe HealthCheckController do
...
@@ -70,6 +77,7 @@ describe HealthCheckController do
it
'supports successful responses for specific checks'
do
it
'supports successful responses for specific checks'
do
get
:index
,
checks:
'email'
,
format: :json
get
:index
,
checks:
'email'
,
format: :json
expect
(
response
).
to
be_success
expect
(
response
).
to
be_success
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
json_response
[
'healthy'
]).
to
be
true
expect
(
json_response
[
'healthy'
]).
to
be
true
...
@@ -79,6 +87,7 @@ describe HealthCheckController do
...
@@ -79,6 +87,7 @@ describe HealthCheckController do
context
'when a service is down but NO access token'
do
context
'when a service is down but NO access token'
do
it
'returns a not found page'
do
it
'returns a not found page'
do
get
:index
get
:index
expect
(
response
).
to
be_not_found
expect
(
response
).
to
be_not_found
end
end
end
end
...
@@ -92,6 +101,7 @@ describe HealthCheckController do
...
@@ -92,6 +101,7 @@ describe HealthCheckController do
it
'supports failure plaintest response'
do
it
'supports failure plaintest response'
do
get
:index
get
:index
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
.
content_type
).
to
eq
'text/plain'
expect
(
response
.
content_type
).
to
eq
'text/plain'
expect
(
response
.
body
).
to
include
(
'The server is on fire'
)
expect
(
response
.
body
).
to
include
(
'The server is on fire'
)
...
@@ -99,6 +109,7 @@ describe HealthCheckController do
...
@@ -99,6 +109,7 @@ describe HealthCheckController do
it
'supports failure json response'
do
it
'supports failure json response'
do
get
:index
,
format: :json
get
:index
,
format: :json
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
json_response
[
'healthy'
]).
to
be
false
expect
(
json_response
[
'healthy'
]).
to
be
false
...
@@ -107,6 +118,7 @@ describe HealthCheckController do
...
@@ -107,6 +118,7 @@ describe HealthCheckController do
it
'supports failure xml response'
do
it
'supports failure xml response'
do
get
:index
,
format: :xml
get
:index
,
format: :xml
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
.
content_type
).
to
eq
'application/xml'
expect
(
response
.
content_type
).
to
eq
'application/xml'
expect
(
xml_response
[
'healthy'
]).
to
be
false
expect
(
xml_response
[
'healthy'
]).
to
be
false
...
@@ -115,6 +127,7 @@ describe HealthCheckController do
...
@@ -115,6 +127,7 @@ describe HealthCheckController do
it
'supports failure responses for specific checks'
do
it
'supports failure responses for specific checks'
do
get
:index
,
checks:
'email'
,
format: :json
get
:index
,
checks:
'email'
,
format: :json
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
).
to
have_http_status
(
500
)
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
json_response
[
'healthy'
]).
to
be
false
expect
(
json_response
[
'healthy'
]).
to
be
false
...
...
spec/controllers/health_controller_spec.rb
View file @
6d60e265
...
@@ -8,7 +8,7 @@ describe HealthController do
...
@@ -8,7 +8,7 @@ describe HealthController do
let
(
:not_whitelisted_ip
)
{
'127.0.0.2'
}
let
(
:not_whitelisted_ip
)
{
'127.0.0.2'
}
before
do
before
do
allow
(
Settings
.
monitoring
).
to
receive
(
:ip_whitelist
).
and_return
([
IPAddr
.
new
(
whitelisted_ip
)
])
allow
(
Settings
.
monitoring
).
to
receive
(
:ip_whitelist
).
and_return
([
whitelisted_ip
])
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
end
end
...
@@ -20,6 +20,7 @@ describe HealthController do
...
@@ -20,6 +20,7 @@ describe HealthController do
it
'returns proper response'
do
it
'returns proper response'
do
get
:readiness
get
:readiness
expect
(
json_response
[
'db_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'db_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'redis_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'redis_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'fs_shards_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'fs_shards_check'
][
'status'
]).
to
eq
(
'ok'
)
...
@@ -34,6 +35,7 @@ describe HealthController do
...
@@ -34,6 +35,7 @@ describe HealthController do
it
'returns proper response'
do
it
'returns proper response'
do
get
:readiness
get
:readiness
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
...
@@ -47,6 +49,7 @@ describe HealthController do
...
@@ -47,6 +49,7 @@ describe HealthController do
it
'returns proper response'
do
it
'returns proper response'
do
get
:liveness
get
:liveness
expect
(
json_response
[
'db_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'db_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'redis_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'redis_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'fs_shards_check'
][
'status'
]).
to
eq
(
'ok'
)
expect
(
json_response
[
'fs_shards_check'
][
'status'
]).
to
eq
(
'ok'
)
...
@@ -60,6 +63,7 @@ describe HealthController do
...
@@ -60,6 +63,7 @@ describe HealthController do
it
'returns proper response'
do
it
'returns proper response'
do
get
:liveness
get
:liveness
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
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