Commit 9371674b authored by Toon Claes's avatar Toon Claes

Rename #track_gap to #track_gaps

Since it can track multiple gaps
parent fb1299ee
......@@ -40,7 +40,7 @@ module Gitlab
return unless gap?(current_id)
track_gap(current_id)
track_gaps(current_id)
ensure
self.previous_id = current_id
end
......@@ -60,7 +60,7 @@ module Gitlab
end
end
def track_gap(current_id)
def track_gaps(current_id)
log_info("Event log gap detected", previous_event_id: previous_id, current_event_id: current_id)
with_redis do |redis|
......
......@@ -18,12 +18,12 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
it 'returns the lowest gap id' do
Timecop.travel(50.minutes.ago) do
gap_tracking.previous_id = 18
gap_tracking.track_gap(20)
gap_tracking.track_gaps(20)
end
Timecop.travel(40.minutes.ago) do
gap_tracking.previous_id = 12
gap_tracking.track_gap(14)
gap_tracking.track_gaps(14)
end
expect(described_class.min_gap_id).to eq(13)
......@@ -37,10 +37,10 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
it 'returns the number of gaps' do
gap_tracking.previous_id = 18
gap_tracking.track_gap(20)
gap_tracking.track_gaps(20)
gap_tracking.previous_id = 12
gap_tracking.track_gap(14)
gap_tracking.track_gaps(14)
expect(described_class.gap_count).to eq(2)
end
......@@ -58,7 +58,7 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
end
it 'does nothing when there is no gap' do
expect(gap_tracking).not_to receive(:track_gap)
expect(gap_tracking).not_to receive(:track_gaps)
gap_tracking.check!(previous_event_id + 1)
......@@ -66,7 +66,7 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
end
it 'tracks the gap if there is one' do
expect(gap_tracking).to receive(:track_gap)
expect(gap_tracking).to receive(:track_gaps)
gap_tracking.check!(event_id_with_gap)
......@@ -102,16 +102,16 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
end
end
describe '#track_gap' do
describe '#track_gaps' do
it 'logs a message' do
expect(gap_tracking).to receive(:log_info).with(/gap detected/, hash_including(previous_event_id: previous_event_id, current_event_id: event_id_with_gap))
gap_tracking.track_gap(event_id_with_gap)
gap_tracking.track_gaps(event_id_with_gap)
end
it 'saves the gap id in redis' do
Timecop.freeze do
gap_tracking.track_gap(event_id_with_gap)
gap_tracking.track_gaps(event_id_with_gap)
expect(read_gaps).to contain_exactly([gap_id.to_s, Time.now.to_i])
end
......@@ -119,7 +119,7 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
it 'saves a range of gaps id in redis' do
Timecop.freeze do
gap_tracking.track_gap(event_id_with_gap + 3)
gap_tracking.track_gaps(event_id_with_gap + 3)
expected_gaps = ((previous_event_id + 1)..(event_id_with_gap + 2)).collect { |id| [id.to_s, Time.now.to_i] }
......@@ -131,13 +131,13 @@ describe Gitlab::Geo::EventGapTracking, :clean_gitlab_redis_cache do
expected_gaps = []
Timecop.freeze do
gap_tracking.track_gap(event_id_with_gap)
gap_tracking.track_gaps(event_id_with_gap)
expected_gaps << [gap_id.to_s, Time.now.to_i]
end
Timecop.travel(2.minutes) do
gap_tracking.previous_id = 17
gap_tracking.track_gap(19)
gap_tracking.track_gaps(19)
expected_gaps << [18.to_s, Time.now.to_i]
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