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
62602469
Commit
62602469
authored
Mar 21, 2022
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a control for comparison in N+1 spec
parent
59b0cda6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
spec/services/ci/job_artifacts/destroy_all_expired_service_spec.rb
...ices/ci/job_artifacts/destroy_all_expired_service_spec.rb
+25
-14
No files found.
spec/services/ci/job_artifacts/destroy_all_expired_service_spec.rb
View file @
62602469
...
...
@@ -19,8 +19,23 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
let!
(
:artifact
)
{
create
(
:ci_job_artifact
,
:expired
,
job:
job
,
locked:
job
.
pipeline
.
locked
)
}
context
'with preloaded relationships'
do
let
(
:second_artifact
)
{
create
(
:ci_job_artifact
,
:expired
,
:junit
,
job:
job
)
}
let
(
:more_artifacts
)
do
[
create
(
:ci_job_artifact
,
:expired
,
:sast
,
job:
job
),
create
(
:ci_job_artifact
,
:expired
,
:metadata
,
job:
job
),
create
(
:ci_job_artifact
,
:expired
,
:codequality
,
job:
job
),
create
(
:ci_job_artifact
,
:expired
,
:accessibility
,
job:
job
)
]
end
before
do
stub_const
(
"
#{
described_class
}
::LARGE_LOOP_LIMIT"
,
1
)
# This artifact-with-file is created before the control execution to ensure
# that the DeletedObject operations are accounted for in the query count.
second_artifact
end
context
'with ci_destroy_unlocked_job_artifacts feature flag disabled'
do
...
...
@@ -28,19 +43,12 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
stub_feature_flags
(
ci_destroy_unlocked_job_artifacts:
false
)
end
it
'performs
the smallest number of queries for job_artifact
s'
do
log
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
it
'performs
a consistent number of querie
s'
do
control
=
ActiveRecord
::
QueryRecorder
.
new
{
service
.
execute
}
# SELECT expired ci_job_artifacts - 3 queries from each_batch
# PRELOAD projects, routes, project_statistics
# BEGIN
# INSERT into ci_deleted_objects
# DELETE loaded ci_job_artifacts
# DELETE security_findings -- for EE
# COMMIT
# SELECT next expired ci_job_artifacts
more_artifacts
expect
(
log
.
count
).
to
be_within
(
1
).
of
(
10
)
expect
{
subject
}.
not_to
exceed_query_limit
(
control
.
count
)
end
end
...
...
@@ -49,9 +57,12 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
stub_feature_flags
(
ci_destroy_unlocked_job_artifacts:
true
)
end
it
'performs the smallest number of queries for job_artifacts'
do
log
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
log
.
count
).
to
be_within
(
1
).
of
(
8
)
it
'performs a consistent number of queries'
do
control
=
ActiveRecord
::
QueryRecorder
.
new
{
service
.
execute
}
more_artifacts
expect
{
subject
}.
not_to
exceed_query_limit
(
control
.
count
)
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