Commit f2979986 authored by Mike Kozono's avatar Mike Kozono

Perform Replicator#verify even if not "started"

* `Geo::VerificationWorker` is already deduplicated for identical args
  since it is marked `idempotent!`
* When `verification_state` is not `verification_started`, it is not
  necessary for `VerificationWorker#perform` or `Replicator#verify` to
  exit without doing work. Furthermore, it is unexpected.
parent 465e5f66
......@@ -126,8 +126,7 @@ module Geo
# Calculates checksum and asks the model/registry to update verification
# state.
def verify
# Deduplicate verification job
return unless model_record.verification_started?
model_record.verification_started! unless model_record.verification_started?
calculation_started_at = Time.current
checksum = model_record.calculate_checksum
......
......@@ -299,37 +299,23 @@ RSpec.shared_examples 'a verifiable replicator' do
stub_primary_node
end
context 'when verification was started' do
before do
model_record.verification_started!
end
context 'when the checksum succeeds' do
it 'delegates checksum calculation and the state change to model_record' do
expect(model_record).to receive(:calculate_checksum).and_return('abc123')
expect(model_record).to receive(:verification_succeeded_with_checksum!).with('abc123', kind_of(Time))
context 'when the checksum succeeds' do
it 'delegates checksum calculation and the state change to model_record' do
expect(model_record).to receive(:calculate_checksum).and_return('abc123')
expect(model_record).to receive(:verification_succeeded_with_checksum!).with('abc123', kind_of(Time))
replicator.verify
end
replicator.verify
end
end
context 'when an error is raised during calculate_checksum' do
it 'passes the error message' do
error = StandardError.new('Some exception')
allow(model_record).to receive(:calculate_checksum) do
raise error
end
expect(model_record).to receive(:verification_failed_with_message!).with('Error calculating the checksum', error)
replicator.verify
context 'when an error is raised during calculate_checksum' do
it 'passes the error message' do
error = StandardError.new('Some exception')
allow(model_record).to receive(:calculate_checksum) do
raise error
end
end
end
context 'when verification was not started' do
it 'does not call calculate_checksum!' do
expect(model_record).not_to receive(:calculate_checksum)
expect(model_record).to receive(:verification_failed_with_message!).with('Error calculating the checksum', error)
replicator.verify
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