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
8dd9289b
Commit
8dd9289b
authored
Jul 28, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for N+1 in AlertReferenceFilter
parent
9e44919c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
spec/lib/banzai/filter/references/alert_reference_filter_spec.rb
...b/banzai/filter/references/alert_reference_filter_spec.rb
+29
-0
No files found.
spec/lib/banzai/filter/references/alert_reference_filter_spec.rb
View file @
8dd9289b
...
@@ -220,4 +220,33 @@ RSpec.describe Banzai::Filter::References::AlertReferenceFilter do
...
@@ -220,4 +220,33 @@ RSpec.describe Banzai::Filter::References::AlertReferenceFilter do
expect
(
reference_filter
(
act
,
project:
nil
,
group:
group
).
to_html
).
to
eq
exp
expect
(
reference_filter
(
act
,
project:
nil
,
group:
group
).
to_html
).
to
eq
exp
end
end
end
end
context
'checking N+1'
do
let
(
:namespace
)
{
create
(
:namespace
)
}
let
(
:project2
)
{
create
(
:project
,
:public
,
namespace:
namespace
)
}
let
(
:alert2
)
{
create
(
:alert_management_alert
,
project:
project2
)
}
let
(
:alert_reference
)
{
alert
.
to_reference
}
let
(
:alert2_reference
)
{
alert2
.
to_reference
(
full:
true
)
}
it
'does not have N+1 per multiple references per project'
,
:use_sql_query_cache
do
markdown
=
"
#{
alert_reference
}
"
max_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
reference_filter
(
markdown
)
end
.
count
expect
(
max_count
).
to
eq
1
markdown
=
"
#{
alert_reference
}
^alert#2 ^alert#3 ^alert#4
#{
alert2_reference
}
"
# Since we're not batching alert queries across projects,
# we have to account for that.
# 1 for both projects, 1 for alerts in each project == 3
# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/330359
max_count
+=
2
expect
do
reference_filter
(
markdown
)
end
.
not_to
exceed_all_query_limit
(
max_count
)
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