Commit 594bc10f authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'mk/do-not-create-registry-on-checksum-succeeded' into 'master'

Geo: Fix duplicate Package File Registry rows

See merge request gitlab-org/gitlab!54654
parents 9a319a49 eb528805
......@@ -182,6 +182,7 @@ module Geo
# Called by Gitlab::Geo::Replicator#consume
def consume_event_checksum_succeeded(**params)
return unless Gitlab::Geo.secondary?
return unless registry.persisted?
registry.verification_pending!
end
......
......@@ -457,33 +457,47 @@ RSpec.shared_examples 'a verifiable replicator' do
end
context 'on a Geo secondary' do
let(:registry) { replicator.registry }
before do
stub_secondary_node
end
context 'with a registry which is verified' do
it 'sets state to verification_pending' do
registry.verification_started
registry.verification_succeeded_with_checksum!('foo', Time.current)
context 'with a persisted registry' do
let(:registry) { replicator.registry }
before do
registry.save!
end
context 'with a registry which is verified' do
it 'sets state to verification_pending' do
registry.verification_started
registry.verification_succeeded_with_checksum!('foo', Time.current)
expect do
replicator.consume_event_checksum_succeeded
end.to change { registry.reload.verification_state }
.from(verification_state_value(:verification_succeeded))
.to(verification_state_value(:verification_pending))
end
end
context 'with a registry which is pending verification' do
it 'does not change state from verification_pending' do
registry.save!
expect do
replicator.consume_event_checksum_succeeded
end.to change { registry.reload.verification_state }
.from(verification_state_value(:verification_succeeded))
.to(verification_state_value(:verification_pending))
expect do
replicator.consume_event_checksum_succeeded
end.not_to change { registry.reload.verification_state }
.from(verification_state_value(:verification_pending))
end
end
end
context 'with a registry which is pending verification' do
it 'does not change state from verification_pending' do
registry.save!
context 'with an unpersisted registry' do
it 'does not persist the registry' do
replicator.consume_event_checksum_succeeded
expect do
replicator.consume_event_checksum_succeeded
end.not_to change { registry.reload.verification_state }
.from(verification_state_value(:verification_pending))
expect(replicator.registry.persisted?).to be_falsey
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