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
8323e55b
Commit
8323e55b
authored
Aug 31, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return a value to check if redis is available on /internal/check
parent
063e285e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
lib/api/helpers/internal_helpers.rb
lib/api/helpers/internal_helpers.rb
+9
-0
lib/api/internal.rb
lib/api/internal.rb
+2
-1
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+11
-0
No files found.
lib/api/helpers/internal_helpers.rb
View file @
8323e55b
...
@@ -46,6 +46,15 @@ module API
...
@@ -46,6 +46,15 @@ module API
::
MergeRequests
::
GetUrlsService
.
new
(
project
).
execute
(
params
[
:changes
])
::
MergeRequests
::
GetUrlsService
.
new
(
project
).
execute
(
params
[
:changes
])
end
end
def
redis_ping
result
=
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
ping
}
result
==
'PONG'
rescue
=>
e
Rails
.
logger
.
warn
(
"GitLab: An unexpected error occurred in pinging to Redis:
#{
e
}
"
)
false
end
private
private
def
set_project
def
set_project
...
...
lib/api/internal.rb
View file @
8323e55b
...
@@ -88,7 +88,8 @@ module API
...
@@ -88,7 +88,8 @@ module API
{
{
api_version:
API
.
version
,
api_version:
API
.
version
,
gitlab_version:
Gitlab
::
VERSION
,
gitlab_version:
Gitlab
::
VERSION
,
gitlab_rev:
Gitlab
::
REVISION
gitlab_rev:
Gitlab
::
REVISION
,
redis:
redis_ping
}
}
end
end
...
...
spec/requests/api/internal_spec.rb
View file @
8323e55b
...
@@ -8,10 +8,21 @@ describe API::Internal do
...
@@ -8,10 +8,21 @@ describe API::Internal do
describe
"GET /internal/check"
do
describe
"GET /internal/check"
do
it
do
it
do
expect_any_instance_of
(
Redis
).
to
receive
(
:ping
).
and_return
(
'PONG'
)
get
api
(
"/internal/check"
),
secret_token:
secret_token
get
api
(
"/internal/check"
),
secret_token:
secret_token
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'api_version'
]).
to
eq
(
API
::
API
.
version
)
expect
(
json_response
[
'api_version'
]).
to
eq
(
API
::
API
.
version
)
expect
(
json_response
[
'redis'
]).
to
be
(
true
)
end
it
'returns false for field `redis` when redis is unavailable'
do
expect_any_instance_of
(
Redis
).
to
receive
(
:ping
).
and_raise
(
Errno
::
ENOENT
)
get
api
(
"/internal/check"
),
secret_token:
secret_token
expect
(
json_response
[
'redis'
]).
to
be
(
false
)
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