Commit a5c0a3e8 authored by Stan Hu's avatar Stan Hu

Merge branch '3453-remove-geo-repository-sync-backoff' into 'master'

Remove the backoff delay from Geo repository sync

Closes #3453

See merge request gitlab-org/gitlab-ee!3009
parents 131e1db5 9110e558
module Geo
class RepositorySyncWorker < Geo::BaseSchedulerWorker
BACKOFF_DELAY = 5.minutes
MAX_CAPACITY = 25
private
......@@ -10,7 +9,7 @@ module Geo
end
def schedule_job(project_id)
job_id = Geo::ProjectSyncWorker.perform_in(BACKOFF_DELAY, project_id, Time.now)
job_id = Geo::ProjectSyncWorker.perform_async(project_id, Time.now)
{ id: project_id, job_id: job_id } if job_id
end
......
---
title: Remove the backoff delay from Geo repository sync
merge_request: 3009
author:
type: changed
......@@ -16,7 +16,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
end
it 'performs Geo::ProjectSyncWorker for each project' do
expect(Geo::ProjectSyncWorker).to receive(:perform_in).twice.and_return(spy)
expect(Geo::ProjectSyncWorker).to receive(:perform_async).twice.and_return(spy)
subject.perform
end
......@@ -25,7 +25,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
create(:geo_project_registry, :sync_failed, project: project_in_synced_group)
create(:geo_project_registry, :synced, project: unsynced_project)
expect(Geo::ProjectSyncWorker).to receive(:perform_in).once.and_return(spy)
expect(Geo::ProjectSyncWorker).to receive(:perform_async).once.and_return(spy)
subject.perform
end
......@@ -35,7 +35,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
create(:geo_project_registry, :synced, project: unsynced_project)
create(:geo_project_registry, :synced, :wiki_dirty)
expect(Geo::ProjectSyncWorker).to receive(:perform_in).twice.and_return(spy)
expect(Geo::ProjectSyncWorker).to receive(:perform_async).twice.and_return(spy)
subject.perform
end
......@@ -43,7 +43,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'does not perform Geo::ProjectSyncWorker when no geo database is configured' do
allow(Gitlab::Geo).to receive(:geo_database_configured?) { false }
expect(Geo::ProjectSyncWorker).not_to receive(:perform_in)
expect(Geo::ProjectSyncWorker).not_to receive(:perform_async)
subject.perform
end
......@@ -51,7 +51,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'does not perform Geo::ProjectSyncWorker when not running on a secondary' do
allow(Gitlab::Geo).to receive(:secondary?) { false }
expect(Geo::ProjectSyncWorker).not_to receive(:perform_in)
expect(Geo::ProjectSyncWorker).not_to receive(:perform_async)
subject.perform
end
......@@ -59,7 +59,7 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'does not perform Geo::ProjectSyncWorker when node is disabled' do
allow_any_instance_of(GeoNode).to receive(:enabled?) { false }
expect(Geo::ProjectSyncWorker).not_to receive(:perform_in)
expect(Geo::ProjectSyncWorker).not_to receive(:perform_async)
subject.perform
end
......@@ -70,8 +70,8 @@ describe Geo::RepositorySyncWorker, :postgresql do
end
it 'does not perform Geo::ProjectSyncWorker for projects that do not belong to selected namespaces to replicate' do
expect(Geo::ProjectSyncWorker).to receive(:perform_in)
.with(300, project_in_synced_group.id, within(1.minute).of(Time.now))
expect(Geo::ProjectSyncWorker).to receive(:perform_async)
.with(project_in_synced_group.id, within(1.minute).of(Time.now))
.once
.and_return(spy)
......@@ -82,8 +82,8 @@ describe Geo::RepositorySyncWorker, :postgresql do
create(:geo_project_registry, :synced, :repository_dirty, project: project_in_synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: unsynced_project)
expect(Geo::ProjectSyncWorker).to receive(:perform_in)
.with(300, project_in_synced_group.id, within(1.minute).of(Time.now))
expect(Geo::ProjectSyncWorker).to receive(:perform_async)
.with(project_in_synced_group.id, within(1.minute).of(Time.now))
.once
.and_return(spy)
......@@ -105,8 +105,8 @@ describe Geo::RepositorySyncWorker, :postgresql do
it 'tries to sync every project' do
project_list.each do |project|
expect(Geo::ProjectSyncWorker)
.to receive(:perform_in)
.with(anything, project.id, anything)
.to receive(:perform_async)
.with(project.id, anything)
.at_least(:once)
.and_call_original
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