Commit e3533bae authored by Mike Kozono's avatar Mike Kozono

Fix secondary-specific tests

Many test environments are setup with primary and secondary in one.
This is not usually a problem, but in this case, these hooks were
running even though current node was stubbed as a secondary, and since
these particular tests were tagged `:sidekiq_inline`, they were running
`after_verifiable_update` which is not normally possible to trigger on a
secondary. And so the VerificationWorker ran, in the context of a
secondary. Since registry records didn't exist, they were created. The
test setup went on to create duplicate registry records (apparently we
have not enforced unique foreign keys), and anyway, the test setup was
incorrect, and so some tests failed.
parent 3cb7498d
......@@ -13,7 +13,7 @@ module Geo
end
def handle_after_create_commit
return false unless Gitlab::Geo.enabled?
return false unless Gitlab::Geo.primary?
return unless self.class.enabled?
publish(:created, **created_params)
......
......@@ -267,14 +267,14 @@ module Gitlab
end
def handle_after_destroy
return false unless Gitlab::Geo.enabled?
return false unless Gitlab::Geo.primary?
return unless self.class.enabled?
publish(:deleted, **deleted_params)
end
def handle_after_update
return false unless Gitlab::Geo.enabled?
return false unless Gitlab::Geo.primary?
return unless self.class.enabled?
publish(:updated, **updated_params)
......
......@@ -22,7 +22,7 @@ RSpec.describe Packages::PackageFile, type: :model do
context 'new file' do
it 'calls checksum worker' do
allow(Gitlab::Geo).to receive(:enabled?).and_return(true)
stub_primary_node
allow(Geo::VerificationWorker).to receive(:perform_async)
package_file = create(:conan_package_file, :conan_recipe_file)
......
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