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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3d42bab7
Commit
3d42bab7
authored
Jun 12, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply feedback
parent
e1589a5c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
21 deletions
+16
-21
app/uploaders/object_storage.rb
app/uploaders/object_storage.rb
+2
-1
spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
...ers/workers/object_storage/migrate_uploads_worker_spec.rb
+14
-20
No files found.
app/uploaders/object_storage.rb
View file @
3d42bab7
...
...
@@ -16,7 +16,8 @@ module ObjectStorage
end
def
message
"Exclusive lease
#{
@lease_key
}
already taken."
*
lease_key_group
,
_
=
*
@lease_key
.
split
(
":"
)
"Exclusive lease for
#{
lease_key_group
.
join
(
':'
)
}
is already taken."
end
end
...
...
spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
View file @
3d42bab7
require
'spec_helper'
MIGRATION_QUERIES
=
5
describe
ObjectStorage
::
MigrateUploadsWorker
,
:sidekiq
do
shared_context
'sanity_check! fails'
do
before
do
...
...
@@ -127,13 +125,12 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
it_behaves_like
"uploads migration worker"
describe
"limits N+1 queries"
do
let!
(
:projects
)
{
create_list
(
:project
,
10
,
:with_avatar
)
}
it
"to N*
#{
MIGRATION_QUERIES
}
"
do
it
"to N*5"
do
query_count
=
ActiveRecord
::
QueryRecorder
.
new
{
perform
(
uploads
)
}
more_projects
=
create_list
(
:project
,
100
,
:with_avatar
)
expected_queries_per_migration
=
MIGRATION_QUERIES
*
more_projects
.
count
more_projects
=
create_list
(
:project
,
3
,
:with_avatar
)
expected_queries_per_migration
=
5
*
more_projects
.
count
expect
{
perform
(
Upload
.
all
)
}.
not_to
exceed_query_limit
(
query_count
).
with_threshold
(
expected_queries_per_migration
)
end
end
...
...
@@ -144,30 +141,27 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
let
(
:secret
)
{
SecureRandom
.
hex
}
let
(
:mounted_as
)
{
nil
}
before
do
stub_uploads_object_storage
(
FileUploader
)
projects
.
map
do
|
project
|
def
upload_file
(
project
)
uploader
=
FileUploader
.
new
(
project
)
uploader
.
store!
(
fixture_file_upload
(
'spec/fixtures/doc_sample.txt'
))
end
before
do
stub_uploads_object_storage
(
FileUploader
)
projects
.
map
(
&
method
(
:upload_file
))
end
it_behaves_like
"uploads migration worker"
describe
"limits N+1 queries"
do
let!
(
:projects
)
{
create_list
(
:project
,
10
)
}
it
"to N*
#{
MIGRATION_QUERIES
}
"
do
it
"to N*5"
do
query_count
=
ActiveRecord
::
QueryRecorder
.
new
{
perform
(
uploads
)
}
more_projects
=
create_list
(
:project
,
100
)
more_projects
.
map
do
|
project
|
uploader
=
FileUploader
.
new
(
project
)
uploader
.
store!
(
fixture_file_upload
(
'spec/fixtures/doc_sample.txt'
))
end
expected_queries_per_migration
=
MIGRATION_QUERIES
*
more_projects
.
count
more_projects
=
create_list
(
:project
,
3
)
more_projects
.
map
(
&
method
(
:upload_file
))
expected_queries_per_migration
=
5
*
more_projects
.
count
expect
{
perform
(
Upload
.
all
)
}.
not_to
exceed_query_limit
(
query_count
).
with_threshold
(
expected_queries_per_migration
)
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