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
b3bdcb12
Commit
b3bdcb12
authored
Sep 04, 2020
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix blob_path implementation
parent
3e6db30e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
27 deletions
+31
-27
ee/app/models/concerns/geo/blob_replicator_strategy.rb
ee/app/models/concerns/geo/blob_replicator_strategy.rb
+1
-1
ee/spec/support/shared_examples/models/concerns/blob_replicator_strategy_shared_examples.rb
...dels/concerns/blob_replicator_strategy_shared_examples.rb
+30
-26
No files found.
ee/app/models/concerns/geo/blob_replicator_strategy.rb
View file @
b3bdcb12
...
@@ -49,7 +49,7 @@ module Geo
...
@@ -49,7 +49,7 @@ module Geo
#
#
# @return [String] File path
# @return [String] File path
def
blob_path
def
blob_path
carrierwave_uploader
.
class
.
absolute_path
(
carrierwave_uploader
)
carrierwave_uploader
.
path
end
end
def
calculate_checksum!
def
calculate_checksum!
...
...
ee/spec/support/shared_examples/models/concerns/blob_replicator_strategy_shared_examples.rb
View file @
b3bdcb12
...
@@ -131,37 +131,31 @@ RSpec.shared_examples 'a blob replicator' do
...
@@ -131,37 +131,31 @@ RSpec.shared_examples 'a blob replicator' do
end
end
describe
'#consume_event_deleted'
do
describe
'#consume_event_deleted'
do
before
do
let!
(
:model_record_id
)
{
replicator
.
model_record_id
}
# If a delete event was published from the primary, then the model
let!
(
:blob_path
)
{
replicator
.
blob_path
}
# record generally does not exist anymore.
let!
(
:deleted_params
)
{
{
model_record_id:
model_record_id
,
blob_path:
blob_path
}
}
model_record
.
delete
end
# The replicator is instantiated by Geo::EventService on the secondary side,
# after the model_record no longer exists. This ensures the tests do not
# have access to a model_record instance, only model_record_id. Using this
# replicator helps avoid a regression of
# https://gitlab.com/gitlab-org/gitlab/-/issues/233040
let
(
:secondary_side_replicator
)
{
::
Gitlab
::
Geo
::
Replicator
.
for_replicable_params
(
replicable_name:
replicator
.
replicable_name
,
replicable_id:
replicator
.
model_record_id
)
}
it
'invokes Geo::FileRegistryRemovalService'
do
context
'when model_record was deleted from the DB and the replicator only has its ID'
do
service
=
double
(
:service
)
before
do
model_record
.
delete
end
expect
(
service
).
to
receive
(
:execute
)
# The replicator is instantiated by Geo::EventService on the secondary
expect
(
::
Geo
::
FileRegistryRemovalService
)
# side, after the model_record no longer exists. This line ensures the
.
to
receive
(
:new
).
with
(
secondary_side_replicator
.
replicable_name
,
secondary_side_replicator
.
model_record_id
,
'blob_path'
).
and_return
(
service
)
# replicator does not hold an instance of ActiveRecord::Base, which helps
# avoid a regression of
# https://gitlab.com/gitlab-org/gitlab/-/issues/233040
let
(
:secondary_side_replicator
)
{
replicator
.
class
.
new
(
model_record:
nil
,
model_record_id:
model_record_id
)
}
secondary_side_replicator
.
consume_event_deleted
({
blob_path:
'blob_path'
})
it
'invokes Geo::FileRegistryRemovalService'
do
end
service
=
double
(
:service
)
# `in_replicables_for_geo_node?` returns false if the record does not exist,
expect
(
service
).
to
receive
(
:execute
)
# therefore it is unlikely to be useful during a delete event. This test is
expect
(
::
Geo
::
FileRegistryRemovalService
)
# intended to avoid a regression of
.
to
receive
(
:new
).
with
(
secondary_side_replicator
.
replicable_name
,
model_record_id
,
blob_path
).
and_return
(
service
)
# https://gitlab.com/gitlab-org/gitlab/-/issues/233040
it
'does not invoke in_replicables_for_geo_node?'
do
expect
(
secondary_side_replicator
).
not_to
receive
(
:in_replicables_for_geo_node?
)
secondary_side_replicator
.
consume_event_deleted
({
blob_path:
'blob_path'
})
secondary_side_replicator
.
consume_event_deleted
(
deleted_params
)
end
end
end
end
end
...
@@ -186,4 +180,14 @@ RSpec.shared_examples 'a blob replicator' do
...
@@ -186,4 +180,14 @@ RSpec.shared_examples 'a blob replicator' do
expect
(
invoke_model
).
to
be_a
(
Class
)
expect
(
invoke_model
).
to
be_a
(
Class
)
end
end
end
end
describe
'#blob_path'
do
context
'when the file is locally stored'
do
it
'returns a valid path to a file'
do
file_exist
=
File
.
exist?
(
replicator
.
blob_path
)
expect
(
file_exist
).
to
be_truthy
end
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