Commit 2d558d25 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '18500-zero-work-idempotency' into 'master'

Mark the `PostReceive` worker as idempotent

See merge request gitlab-org/gitlab!69305
parents 27d0ea79 cb87e136
......@@ -2445,7 +2445,7 @@
:urgency: :high
:resource_boundary: :cpu
:weight: 5
:idempotent:
:idempotent: true
:tags: []
- :name: process_commit
:worker_name: ProcessCommitWorker
......
# frozen_string_literal: true
class PostReceive # rubocop:disable Scalability/IdempotentWorker
class PostReceive
include ApplicationWorker
idempotent!
deduplicate :none
data_consistency :always
sidekiq_options retry: 3
......
......@@ -22,6 +22,8 @@ RSpec.describe PostReceive do
create(:project, :repository, auto_cancel_pending_pipelines: 'disabled')
end
let(:job_args) { [gl_repository, key_id, base64_changes] }
def perform(changes: base64_changes)
described_class.new.perform(gl_repository, key_id, changes)
end
......@@ -282,6 +284,8 @@ RSpec.describe PostReceive do
end
end
end
it_behaves_like 'an idempotent worker'
end
describe '#process_wiki_changes' do
......@@ -352,6 +356,8 @@ RSpec.describe PostReceive do
perform
end
end
it_behaves_like 'an idempotent worker'
end
context 'webhook' do
......@@ -458,6 +464,8 @@ RSpec.describe PostReceive do
end
end
end
it_behaves_like 'an idempotent worker'
end
context 'with PersonalSnippet' do
......@@ -484,5 +492,7 @@ RSpec.describe PostReceive do
described_class.new.perform(gl_repository, key_id, base64_changes)
end
it_behaves_like 'an idempotent worker'
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