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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
083337f1
Commit
083337f1
authored
Dec 28, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
97114d13
49041d67
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
2 deletions
+39
-2
changelogs/unreleased/sh-fix-branches-api-timeout.yml
changelogs/unreleased/sh-fix-branches-api-timeout.yml
+5
-0
lib/api/branches.rb
lib/api/branches.rb
+2
-2
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+12
-0
spec/support/helpers/kubernetes_helpers.rb
spec/support/helpers/kubernetes_helpers.rb
+20
-0
No files found.
changelogs/unreleased/sh-fix-branches-api-timeout.yml
0 → 100644
View file @
083337f1
---
title
:
Fix timeout issues retrieving branches via API
merge_request
:
24034
author
:
type
:
performance
lib/api/branches.rb
View file @
083337f1
...
@@ -34,11 +34,11 @@ module API
...
@@ -34,11 +34,11 @@ module API
repository
=
user_project
.
repository
repository
=
user_project
.
repository
branches
=
BranchesFinder
.
new
(
repository
,
declared_params
(
include_missing:
false
)).
execute
branches
=
BranchesFinder
.
new
(
repository
,
declared_params
(
include_missing:
false
)).
execute
branches
=
::
Kaminari
.
paginate_array
(
branches
)
merged_branch_names
=
repository
.
merged_branch_names
(
branches
.
map
(
&
:name
))
merged_branch_names
=
repository
.
merged_branch_names
(
branches
.
map
(
&
:name
))
present
(
present
(
paginate
(
::
Kaminari
.
paginate_array
(
branches
)
),
paginate
(
branches
),
with:
Entities
::
Branch
,
with:
Entities
::
Branch
,
current_user:
current_user
,
current_user:
current_user
,
project:
user_project
,
project:
user_project
,
...
...
spec/requests/api/branches_spec.rb
View file @
083337f1
...
@@ -20,6 +20,12 @@ describe API::Branches do
...
@@ -20,6 +20,12 @@ describe API::Branches do
let
(
:route
)
{
"/projects/
#{
project_id
}
/repository/branches"
}
let
(
:route
)
{
"/projects/
#{
project_id
}
/repository/branches"
}
shared_examples_for
'repository branches'
do
shared_examples_for
'repository branches'
do
RSpec
::
Matchers
.
define
:has_merged_branch_names_count
do
|
expected
|
match
do
|
actual
|
actual
[
:merged_branch_names
].
count
==
expected
end
end
it
'returns the repository branches'
do
it
'returns the repository branches'
do
get
api
(
route
,
current_user
),
params:
{
per_page:
100
}
get
api
(
route
,
current_user
),
params:
{
per_page:
100
}
...
@@ -30,6 +36,12 @@ describe API::Branches do
...
@@ -30,6 +36,12 @@ describe API::Branches do
expect
(
branch_names
).
to
match_array
(
project
.
repository
.
branch_names
)
expect
(
branch_names
).
to
match_array
(
project
.
repository
.
branch_names
)
end
end
it
'determines only a limited number of merged branch names'
do
expect
(
API
::
Entities
::
Branch
).
to
receive
(
:represent
).
with
(
anything
,
has_merged_branch_names_count
(
2
))
get
api
(
route
,
current_user
),
params:
{
per_page:
2
}
end
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
...
...
spec/support/helpers/kubernetes_helpers.rb
View file @
083337f1
...
@@ -69,6 +69,11 @@ module KubernetesHelpers
...
@@ -69,6 +69,11 @@ module KubernetesHelpers
.
to_return
(
status:
[
status
,
"Internal Server Error"
])
.
to_return
(
status:
[
status
,
"Internal Server Error"
])
end
end
def
stub_kubeclient_get_service_account
(
api_url
,
name
,
namespace:
'default'
)
WebMock
.
stub_request
(
:get
,
api_url
+
"/api/v1/namespaces/
#{
namespace
}
/serviceaccounts/
#{
name
}
"
)
.
to_return
(
kube_response
({}))
end
def
stub_kubeclient_get_service_account_error
(
api_url
,
name
,
namespace:
'default'
,
status:
404
)
def
stub_kubeclient_get_service_account_error
(
api_url
,
name
,
namespace:
'default'
,
status:
404
)
WebMock
.
stub_request
(
:get
,
api_url
+
"/api/v1/namespaces/
#{
namespace
}
/serviceaccounts/
#{
name
}
"
)
WebMock
.
stub_request
(
:get
,
api_url
+
"/api/v1/namespaces/
#{
namespace
}
/serviceaccounts/
#{
name
}
"
)
.
to_return
(
status:
[
status
,
"Internal Server Error"
])
.
to_return
(
status:
[
status
,
"Internal Server Error"
])
...
@@ -84,6 +89,11 @@ module KubernetesHelpers
...
@@ -84,6 +89,11 @@ module KubernetesHelpers
.
to_return
(
status:
[
500
,
"Internal Server Error"
])
.
to_return
(
status:
[
500
,
"Internal Server Error"
])
end
end
def
stub_kubeclient_put_service_account
(
api_url
,
name
,
namespace:
'default'
)
WebMock
.
stub_request
(
:put
,
api_url
+
"/api/v1/namespaces/
#{
namespace
}
/serviceaccounts/
#{
name
}
"
)
.
to_return
(
kube_response
({}))
end
def
stub_kubeclient_create_secret
(
api_url
,
namespace:
'default'
)
def
stub_kubeclient_create_secret
(
api_url
,
namespace:
'default'
)
WebMock
.
stub_request
(
:post
,
api_url
+
"/api/v1/namespaces/
#{
namespace
}
/secrets"
)
WebMock
.
stub_request
(
:post
,
api_url
+
"/api/v1/namespaces/
#{
namespace
}
/secrets"
)
.
to_return
(
kube_response
({}))
.
to_return
(
kube_response
({}))
...
@@ -104,6 +114,11 @@ module KubernetesHelpers
...
@@ -104,6 +114,11 @@ module KubernetesHelpers
.
to_return
(
kube_response
({}))
.
to_return
(
kube_response
({}))
end
end
def
stub_kubeclient_get_role_binding
(
api_url
,
name
,
namespace:
'default'
)
WebMock
.
stub_request
(
:get
,
api_url
+
"/apis/rbac.authorization.k8s.io/v1/namespaces/
#{
namespace
}
/rolebindings/
#{
name
}
"
)
.
to_return
(
kube_response
({}))
end
def
stub_kubeclient_get_role_binding_error
(
api_url
,
name
,
namespace:
'default'
,
status:
404
)
def
stub_kubeclient_get_role_binding_error
(
api_url
,
name
,
namespace:
'default'
,
status:
404
)
WebMock
.
stub_request
(
:get
,
api_url
+
"/apis/rbac.authorization.k8s.io/v1/namespaces/
#{
namespace
}
/rolebindings/
#{
name
}
"
)
WebMock
.
stub_request
(
:get
,
api_url
+
"/apis/rbac.authorization.k8s.io/v1/namespaces/
#{
namespace
}
/rolebindings/
#{
name
}
"
)
.
to_return
(
status:
[
status
,
"Internal Server Error"
])
.
to_return
(
status:
[
status
,
"Internal Server Error"
])
...
@@ -114,6 +129,11 @@ module KubernetesHelpers
...
@@ -114,6 +129,11 @@ module KubernetesHelpers
.
to_return
(
kube_response
({}))
.
to_return
(
kube_response
({}))
end
end
def
stub_kubeclient_put_role_binding
(
api_url
,
name
,
namespace:
'default'
)
WebMock
.
stub_request
(
:put
,
api_url
+
"/apis/rbac.authorization.k8s.io/v1/namespaces/
#{
namespace
}
/rolebindings/
#{
name
}
"
)
.
to_return
(
kube_response
({}))
end
def
stub_kubeclient_create_namespace
(
api_url
)
def
stub_kubeclient_create_namespace
(
api_url
)
WebMock
.
stub_request
(
:post
,
api_url
+
"/api/v1/namespaces"
)
WebMock
.
stub_request
(
:post
,
api_url
+
"/api/v1/namespaces"
)
.
to_return
(
kube_response
({}))
.
to_return
(
kube_response
({}))
...
...
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