Split out main, and geo DB out of CI transactions

We should not run main, and eo DB operations in the
context of a CI transaction.

Changelog: changed
EE: true
parent 2f545071
......@@ -15,7 +15,7 @@ module EE
# After destroy callbacks are often skipped because of FastDestroyAll.
# All destroy callbacks should be implemented in `Ci::JobArtifacts::DestroyBatchService`
# See https://gitlab.com/gitlab-org/gitlab/-/issues/297472
after_destroy :log_geo_deleted_event
after_commit :log_geo_deleted_event, on: :destroy
LICENSE_SCANNING_REPORT_FILE_TYPES = %w[license_scanning].freeze
DEPENDENCY_LIST_REPORT_FILE_TYPES = %w[dependency_scanning].freeze
......
......@@ -12,14 +12,27 @@ RSpec.describe Ci::JobArtifact do
let_it_be(:primary) { create(:geo_node, :primary) }
let_it_be(:secondary) { create(:geo_node) }
it 'creates a JobArtifactDeletedEvent' do
before do
stub_current_geo_node(primary)
end
it 'creates a JobArtifactDeletedEvent' do
job_artifact = create(:ee_ci_job_artifact, :archive)
expect do
job_artifact.destroy!
end.to change { Geo::JobArtifactDeletedEvent.count }.by(1)
expect { job_artifact.destroy! }.to change { Geo::JobArtifactDeletedEvent.count }.by(1)
end
context 'JobArtifact destroy fails' do
it 'does not create a JobArtifactDeletedEvent' do
job_artifact = create(:ee_ci_job_artifact, :archive)
allow(job_artifact).to receive(:destroy!)
.and_raise(ActiveRecord::RecordNotDestroyed)
expect { job_artifact.destroy! }.to raise_error(ActiveRecord::RecordNotDestroyed)
.and not_change { Ci::JobArtifact.count }
.and not_change { Geo::JobArtifactDeletedEvent.count }
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