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
650b4e4f
Commit
650b4e4f
authored
Nov 09, 2020
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename calculate_checksum! to calculate_checksum
Because side effects are no longer expected.
parent
fa4069e8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
ee/app/models/concerns/geo/verifiable_replicator.rb
ee/app/models/concerns/geo/verifiable_replicator.rb
+1
-1
ee/app/services/geo/blob_verification_secondary_service.rb
ee/app/services/geo/blob_verification_secondary_service.rb
+1
-1
ee/lib/gitlab/geo/replicable_model.rb
ee/lib/gitlab/geo/replicable_model.rb
+1
-1
ee/spec/models/packages/package_file_spec.rb
ee/spec/models/packages/package_file_spec.rb
+3
-3
ee/spec/services/geo/blob_verification_secondary_service_spec.rb
.../services/geo/blob_verification_secondary_service_spec.rb
+8
-8
ee/spec/support/shared_examples/models/concerns/verifiable_replicator_shared_examples.rb
.../models/concerns/verifiable_replicator_shared_examples.rb
+2
-2
No files found.
ee/app/models/concerns/geo/verifiable_replicator.rb
View file @
650b4e4f
...
@@ -51,7 +51,7 @@ module Geo
...
@@ -51,7 +51,7 @@ module Geo
end
end
def
verify
def
verify
checksum
=
model_record
.
calculate_checksum
!
checksum
=
model_record
.
calculate_checksum
update_verification_state!
(
checksum:
checksum
)
update_verification_state!
(
checksum:
checksum
)
rescue
=>
e
rescue
=>
e
log_error
(
'Error calculating the checksum'
,
e
)
log_error
(
'Error calculating the checksum'
,
e
)
...
...
ee/app/services/geo/blob_verification_secondary_service.rb
View file @
650b4e4f
...
@@ -36,7 +36,7 @@ module Geo
...
@@ -36,7 +36,7 @@ module Geo
end
end
def
verify_checksum
def
verify_checksum
checksum
=
model_record
.
calculate_checksum
!
checksum
=
model_record
.
calculate_checksum
if
mismatch?
(
checksum
)
if
mismatch?
(
checksum
)
update_registry!
(
mismatch:
checksum
,
failure:
'checksum mismatch'
)
update_registry!
(
mismatch:
checksum
,
failure:
'checksum mismatch'
)
...
...
ee/lib/gitlab/geo/replicable_model.rb
View file @
650b4e4f
...
@@ -49,7 +49,7 @@ module Gitlab
...
@@ -49,7 +49,7 @@ module Gitlab
# Returns a checksum of the file (assumed to be a "blob" type)
# Returns a checksum of the file (assumed to be a "blob" type)
#
#
# @return [String] SHA256 hash of the carrierwave file
# @return [String] SHA256 hash of the carrierwave file
def
calculate_checksum
!
def
calculate_checksum
return
unless
checksummable?
return
unless
checksummable?
self
.
class
.
hexdigest
(
replicator
.
carrierwave_uploader
.
path
)
self
.
class
.
hexdigest
(
replicator
.
carrierwave_uploader
.
path
)
...
...
ee/spec/models/packages/package_file_spec.rb
View file @
650b4e4f
...
@@ -4,19 +4,19 @@ require 'spec_helper'
...
@@ -4,19 +4,19 @@ require 'spec_helper'
RSpec
.
describe
Packages
::
PackageFile
,
type: :model
do
RSpec
.
describe
Packages
::
PackageFile
,
type: :model
do
include
::
EE
::
GeoHelpers
include
::
EE
::
GeoHelpers
describe
'#calculate_checksum
!
'
do
describe
'#calculate_checksum'
do
let
(
:package_file
)
{
create
(
:conan_package_file
,
:conan_recipe_file
)
}
let
(
:package_file
)
{
create
(
:conan_package_file
,
:conan_recipe_file
)
}
it
'returns SHA256 sum of the file'
do
it
'returns SHA256 sum of the file'
do
expected
=
Digest
::
SHA256
.
file
(
package_file
.
file
.
path
).
hexdigest
expected
=
Digest
::
SHA256
.
file
(
package_file
.
file
.
path
).
hexdigest
expect
(
package_file
.
calculate_checksum
!
).
to
eq
(
expected
)
expect
(
package_file
.
calculate_checksum
).
to
eq
(
expected
)
end
end
it
'returns nil for a non-existent file'
do
it
'returns nil for a non-existent file'
do
allow
(
package_file
).
to
receive
(
:file_exist?
).
and_return
(
false
)
allow
(
package_file
).
to
receive
(
:file_exist?
).
and_return
(
false
)
expect
(
package_file
.
calculate_checksum
!
).
to
eq
(
nil
)
expect
(
package_file
.
calculate_checksum
).
to
eq
(
nil
)
end
end
end
end
...
...
ee/spec/services/geo/blob_verification_secondary_service_spec.rb
View file @
650b4e4f
...
@@ -21,7 +21,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -21,7 +21,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
it
'does not calculate the checksum when not running on a secondary'
do
it
'does not calculate the checksum when not running on a secondary'
do
stub_primary_node
stub_primary_node
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
!
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -29,7 +29,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -29,7 +29,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
it
'does not verify the checksum if resync is needed'
do
it
'does not verify the checksum if resync is needed'
do
registry
.
resync
registry
.
resync
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
!
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -37,7 +37,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -37,7 +37,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
it
'does not verify the checksum if sync is started'
do
it
'does not verify the checksum if sync is started'
do
registry
.
start!
registry
.
start!
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
!
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -45,7 +45,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -45,7 +45,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
it
'does not verify the checksum if primary was never verified'
do
it
'does not verify the checksum if primary was never verified'
do
package_file
.
assign_attributes
(
verification_checksum:
nil
)
package_file
.
assign_attributes
(
verification_checksum:
nil
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
!
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
)
service
.
execute
service
.
execute
end
end
...
@@ -54,13 +54,13 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -54,13 +54,13 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
package_file
.
assign_attributes
(
verification_checksum:
'62fc1ec4ce60'
)
package_file
.
assign_attributes
(
verification_checksum:
'62fc1ec4ce60'
)
registry
.
update
(
verification_checksum:
'62fc1ec4ce60'
)
registry
.
update
(
verification_checksum:
'62fc1ec4ce60'
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
!
)
expect
(
package_file
).
not_to
receive
(
:calculate_checksum
)
service
.
execute
service
.
execute
end
end
it
'sets checksum when the checksum matches'
do
it
'sets checksum when the checksum matches'
do
allow
(
package_file
).
to
receive
(
:calculate_checksum
!
).
and_return
(
'62fc1ec4ce60'
)
allow
(
package_file
).
to
receive
(
:calculate_checksum
).
and_return
(
'62fc1ec4ce60'
)
service
.
execute
service
.
execute
...
@@ -77,7 +77,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -77,7 +77,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
context
'when the checksum mismatch'
do
context
'when the checksum mismatch'
do
before
do
before
do
allow
(
package_file
).
to
receive
(
:calculate_checksum
!
).
and_return
(
'99fc1ec4ce60'
)
allow
(
package_file
).
to
receive
(
:calculate_checksum
).
and_return
(
'99fc1ec4ce60'
)
end
end
it
'keeps track of failures'
do
it
'keeps track of failures'
do
...
@@ -109,7 +109,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
...
@@ -109,7 +109,7 @@ RSpec.describe Geo::BlobVerificationSecondaryService, :geo do
context
'when checksum calculation fails'
do
context
'when checksum calculation fails'
do
before
do
before
do
allow
(
package_file
).
to
receive
(
:calculate_checksum
!
).
and_raise
(
'Error calculating checksum'
)
allow
(
package_file
).
to
receive
(
:calculate_checksum
).
and_raise
(
'Error calculating checksum'
)
end
end
it
'keeps track of failures'
do
it
'keeps track of failures'
do
...
...
ee/spec/support/shared_examples/models/concerns/verifiable_replicator_shared_examples.rb
View file @
650b4e4f
...
@@ -54,7 +54,7 @@ RSpec.shared_examples 'a verifiable replicator' do
...
@@ -54,7 +54,7 @@ RSpec.shared_examples 'a verifiable replicator' do
end
end
it
'calculates the checksum'
do
it
'calculates the checksum'
do
expect
(
model_record
).
to
receive
(
:calculate_checksum
!
).
and_return
(
'abc123'
)
expect
(
model_record
).
to
receive
(
:calculate_checksum
).
and_return
(
'abc123'
)
replicator
.
verify
replicator
.
verify
...
@@ -63,7 +63,7 @@ RSpec.shared_examples 'a verifiable replicator' do
...
@@ -63,7 +63,7 @@ RSpec.shared_examples 'a verifiable replicator' do
end
end
it
'saves the error message and increments retry counter'
do
it
'saves the error message and increments retry counter'
do
allow
(
model_record
).
to
receive
(
:calculate_checksum
!
)
do
allow
(
model_record
).
to
receive
(
:calculate_checksum
)
do
raise
StandardError
.
new
(
'Failure to calculate checksum'
)
raise
StandardError
.
new
(
'Failure to calculate checksum'
)
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