BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
021fb512
Commit
021fb512
authored
Sep 06, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gitaly-shell-redis-2' into 'master'
Internal API changes to decouple redis from Shell Closes gitaly#520 See merge request !13971
parents
b97f9629
758f18b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
4 deletions
+49
-4
GITLAB_SHELL_VERSION
GITLAB_SHELL_VERSION
+1
-1
internal_helpers.rb
lib/api/helpers/internal_helpers.rb
+9
-0
internal.rb
lib/api/internal.rb
+10
-1
internal_spec.rb
spec/requests/api/internal_spec.rb
+29
-2
No files found.
GITLAB_SHELL_VERSION
View file @
021fb512
5.
8
.0
5.
9
.0
lib/api/helpers/internal_helpers.rb
View file @
021fb512
...
...
@@ -46,6 +46,15 @@ module API
::
MergeRequests
::
GetUrlsService
.
new
(
project
).
execute
(
params
[
:changes
])
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
def
set_project
...
...
lib/api/internal.rb
View file @
021fb512
...
...
@@ -88,7 +88,8 @@ module API
{
api_version:
API
.
version
,
gitlab_version:
Gitlab
::
VERSION
,
gitlab_rev:
Gitlab
::
REVISION
gitlab_rev:
Gitlab
::
REVISION
,
redis:
redis_ping
}
end
...
...
@@ -142,6 +143,14 @@ module API
{
success:
true
,
recovery_codes:
codes
}
end
post
'/pre_receive'
do
status
200
reference_counter_increased
=
Gitlab
::
ReferenceCounter
.
new
(
params
[
:gl_repository
]).
increase
{
reference_counter_increased:
reference_counter_increased
}
end
post
"/notify_post_receive"
do
status
200
...
...
spec/requests/api/internal_spec.rb
View file @
021fb512
...
...
@@ -5,13 +5,26 @@ describe API::Internal do
let
(
:key
)
{
create
(
:key
,
user:
user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:secret_token
)
{
Gitlab
::
Shell
.
secret_token
}
let
(
:gl_repository
)
{
"project-
#{
project
.
id
}
"
}
let
(
:reference_counter
)
{
double
(
'ReferenceCounter'
)
}
describe
"GET /internal/check"
do
it
do
expect_any_instance_of
(
Redis
).
to
receive
(
:ping
).
and_return
(
'PONG'
)
get
api
(
"/internal/check"
),
secret_token:
secret_token
expect
(
response
).
to
have_http_status
(
200
)
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
...
...
@@ -661,9 +674,7 @@ describe API::Internal do
# end
describe
'POST /internal/post_receive'
do
let
(
:gl_repository
)
{
"project-
#{
project
.
id
}
"
}
let
(
:identifier
)
{
'key-123'
}
let
(
:reference_counter
)
{
double
(
'ReferenceCounter'
)
}
let
(
:valid_params
)
do
{
...
...
@@ -749,6 +760,22 @@ describe API::Internal do
end
end
describe
'POST /internal/pre_receive'
do
let
(
:valid_params
)
do
{
gl_repository:
gl_repository
,
secret_token:
secret_token
}
end
it
'decreases the reference counter and returns the result'
do
expect
(
Gitlab
::
ReferenceCounter
).
to
receive
(
:new
).
with
(
gl_repository
)
.
and_return
(
reference_counter
)
expect
(
reference_counter
).
to
receive
(
:increase
).
and_return
(
true
)
post
api
(
"/internal/pre_receive"
),
valid_params
expect
(
json_response
[
'reference_counter_increased'
]).
to
be
(
true
)
end
end
def
project_with_repo_path
(
path
)
double
().
tap
do
|
fake_project
|
allow
(
fake_project
).
to
receive_message_chain
(
'repository.path_to_repo'
=>
path
)
...
...
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