Commit 387c844e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Move specs to the right place and fix failed ones

parent c2691419
...@@ -27,14 +27,14 @@ module Geo ...@@ -27,14 +27,14 @@ module Geo
@registry ||= Geo::ProjectRegistry.find_or_initialize_by(project_id: project.id) @registry ||= Geo::ProjectRegistry.find_or_initialize_by(project_id: project.id)
end end
private
def increment! def increment!
Gitlab::Metrics.measure(:geo_increment_syncs_since_gc) do Gitlab::Metrics.measure(:geo_increment_syncs_since_gc) do
registry.increment_syncs_since_gc registry.increment_syncs_since_gc
end end
end end
private
def do_housekeeping def do_housekeeping
lease_uuid = try_obtain_lease lease_uuid = try_obtain_lease
return false unless lease_uuid.present? return false unless lease_uuid.present?
......
...@@ -33,7 +33,7 @@ describe Geo::ProjectHousekeepingService do ...@@ -33,7 +33,7 @@ describe Geo::ProjectHousekeepingService do
it 'resets counter when syncs_since_gc > gc_period' do it 'resets counter when syncs_since_gc > gc_period' do
allow(service).to receive(:gc_period).and_return(1) allow(service).to receive(:gc_period).and_return(1)
allow(service).to receive(:try_obtain_lease).and_return(:the_uuid) allow(service).to receive(:try_obtain_lease).and_return(:the_uuid)
registry.increment_syncs_since_gc service.increment!
Sidekiq::Testing.inline! do Sidekiq::Testing.inline! do
expect { service.execute }.to change { registry.syncs_since_gc }.to(0) expect { service.execute }.to change { registry.syncs_since_gc }.to(0)
...@@ -109,7 +109,7 @@ describe Geo::ProjectHousekeepingService do ...@@ -109,7 +109,7 @@ describe Geo::ProjectHousekeepingService do
describe '#increment!' do describe '#increment!' do
it 'increments the syncs_since_gc counter' do it 'increments the syncs_since_gc counter' do
expect { service.send(:increment!) }.to change { registry.syncs_since_gc }.by(1) expect { service.increment! }.to change { registry.syncs_since_gc }.by(1)
end end
end end
......
...@@ -7,7 +7,7 @@ describe Geo::RepositorySyncService do ...@@ -7,7 +7,7 @@ describe Geo::RepositorySyncService do
set(:secondary) { create(:geo_node) } set(:secondary) { create(:geo_node) }
let(:lease) { double(try_obtain: true) } let(:lease) { double(try_obtain: true) }
let(:project) { create(:project_empty_repo) } set(:project) { create(:project_empty_repo) }
let(:repository) { project.repository } let(:repository) { project.repository }
subject { described_class.new(project) } subject { described_class.new(project) }
...@@ -354,4 +354,18 @@ describe Geo::RepositorySyncService do ...@@ -354,4 +354,18 @@ describe Geo::RepositorySyncService do
end end
end end
end end
context 'repository housekeeping' do
let(:registry) { Geo::ProjectRegistry.find_or_initialize_by(project_id: project.id) }
it 'increases sync count after execution' do
expect { subject.execute }.to change { registry.syncs_since_gc }.by(1)
end
it 'initiate housekeeping at end of execution' do
expect_any_instance_of(Geo::ProjectHousekeepingService).to receive(:execute)
subject.execute
end
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