Commit 80c9a2bd authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'id-make-repository-update-remote-mirror-idempotent' into 'master'

Make RepositoryUpdateRemoteMirrorWorker idempotent

See merge request gitlab-org/gitlab!48799
parents 6d33b2c8 a264e003
......@@ -2021,7 +2021,7 @@
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:idempotent: true
:tags: []
- :name: self_monitoring_project_create
:feature_category: :metrics
......
# frozen_string_literal: true
class RepositoryUpdateRemoteMirrorWorker # rubocop:disable Scalability/IdempotentWorker
class RepositoryUpdateRemoteMirrorWorker
UpdateError = Class.new(StandardError)
include ApplicationWorker
......@@ -11,6 +11,7 @@ class RepositoryUpdateRemoteMirrorWorker # rubocop:disable Scalability/Idempoten
sidekiq_options retry: 3, dead: false
feature_category :source_code_management
loggable_arguments 1
idempotent!
LOCK_WAIT_TIME = 30.seconds
MAX_TRIES = 3
......
......@@ -3,9 +3,8 @@
require 'spec_helper'
RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
subject { described_class.new }
let_it_be(:remote_mirror) { create(:remote_mirror) }
let(:remote_mirror) { create(:remote_mirror) }
let(:scheduled_time) { Time.current - 5.minutes }
around do |example|
......@@ -19,6 +18,8 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st
end
describe '#perform' do
subject { described_class.new }
it 'calls out to the service to perform the update' do
expect_mirror_service_to_return(remote_mirror, status: :success)
......@@ -68,4 +69,8 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st
subject.perform(remote_mirror.id, scheduled_time)
end
end
include_examples 'an idempotent worker' do
let(:job_args) { [remote_mirror.id, scheduled_time] }
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