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