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
356bf3af
Commit
356bf3af
authored
Jul 10, 2019
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for `ci_environments_status` Gitaly N+1
parent
476c9f0b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
16 deletions
+34
-16
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+34
-16
No files found.
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
356bf3af
...
...
@@ -870,22 +870,19 @@ describe Projects::MergeRequestsController do
end
end
# we're trying to reduce the overall number of queries for this method.
# set a hard limit for now. https://gitlab.com/gitlab-org/gitlab-ce/issues/52287
it
'keeps queries in check'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
get_ci_environments_status
}.
count
expect
(
control_count
).
to
be
<=
137
end
context
'when multiple environments with deployments are present'
do
let
(
:another_environment
)
{
create
(
:environment
,
project:
forked
)
}
it
'has no N+1
issues for environments'
,
:request_store
,
retry:
0
do
it
'has no N+1 SQL
issues for environments'
,
:request_store
,
retry:
0
do
# First run to insert test data from lets, which does take up some 30 queries
get_ci_environments_status
control_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
{
get_ci_environments_status
}.
count
environment2
=
create
(
:environment
,
project:
forked
)
create
(
:deployment
,
:succeed
,
environment:
environment2
,
sha:
sha
,
ref:
'master'
,
deployable:
build
)
create
(
:deployment
,
:succeed
,
environment:
another_environment
,
sha:
sha
,
ref:
'master'
,
deployable:
build
)
# TODO address the last 11 queries
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/63952 (5 queries)
...
...
@@ -894,6 +891,27 @@ describe Projects::MergeRequestsController do
expect
{
get_ci_environments_status
}.
not_to
exceed_all_query_limit
(
control_count
+
leeway
)
end
it
'has no N+1 Gitaly requests for deployments'
,
:request_store
do
expect
(
merge_request
).
to
be_present
create
(
:deployment
,
:succeed
,
environment:
another_environment
,
sha:
sha
,
ref:
'master'
,
deployable:
build
)
expect
{
get_ci_environments_status
}
.
not_to
change
{
Gitlab
::
GitalyClient
.
get_request_count
}
end
end
# we're trying to reduce the overall number of queries for this method.
# set a hard limit for now. https://gitlab.com/gitlab-org/gitlab-ce/issues/52287
it
'keeps queries in check'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
get_ci_environments_status
}.
count
expect
(
control_count
).
to
be
<=
137
end
def
get_ci_environments_status
(
extra_params
=
{})
params
=
{
namespace_id:
merge_request
.
project
.
namespace
.
to_param
,
...
...
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