Commit 789c7c6e authored by Mike Kozono's avatar Mike Kozono

Fix verification_retry_count not incrementing

...properly when `calculate_checksum` returns without error, but
`verification_state` fails to transition to `verification_succeeded`.
parent aa1aa227
......@@ -220,6 +220,10 @@ module Gitlab
track_checksum_result!(checksum, calculation_started_at)
rescue => e
# Reset any potential changes from track_checksum_result, i.e.
# verification_retry_count may have been cleared.
reset
verification_failed_with_message!('Error during verification', e)
end
......
......@@ -195,7 +195,7 @@ RSpec.describe Gitlab::Geo::VerificationState do
end
end
describe '#track_checksum_attempt!' do
describe '#track_checksum_attempt!', :aggregate_failures do
context 'when verification was not yet started' do
it 'starts verification' do
expect do
......@@ -234,12 +234,39 @@ RSpec.describe Gitlab::Geo::VerificationState do
end
context 'when an error occurs while yielding' do
it 'sets verification_failed' do
subject.track_checksum_attempt! do
raise 'an error'
context 'when the record was failed' do
it 'sets verification_failed and increments verification_retry_count' do
subject.verification_failed_with_message!('foo')
subject.track_checksum_attempt! do
raise 'an error'
end
expect(subject.reload.verification_failed?).to be_truthy
expect(subject.verification_retry_count).to eq(2)
end
end
end
expect(subject.reload.verification_failed?).to be_truthy
context 'when the yielded block returns nil' do
context 'when the record was pending' do
it 'sets verification_failed and sets verification_retry_count to 1' do
subject.track_checksum_attempt! { nil }
expect(subject.reload.verification_failed?).to be_truthy
expect(subject.verification_retry_count).to eq(1)
end
end
context 'when the record was failed' do
it 'sets verification_failed and increments verification_retry_count' do
subject.verification_failed_with_message!('foo')
subject.track_checksum_attempt! { nil }
expect(subject.reload.verification_failed?).to be_truthy
expect(subject.verification_retry_count).to eq(2)
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment