Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9371674b
Commit
9371674b
authored
Jul 29, 2018
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename #track_gap to #track_gaps
Since it can track multiple gaps
parent
fb1299ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
ee/lib/gitlab/geo/event_gap_tracking.rb
ee/lib/gitlab/geo/event_gap_tracking.rb
+2
-2
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb
+12
-12
No files found.
ee/lib/gitlab/geo/event_gap_tracking.rb
View file @
9371674b
...
...
@@ -40,7 +40,7 @@ module Gitlab
return
unless
gap?
(
current_id
)
track_gap
(
current_id
)
track_gap
s
(
current_id
)
ensure
self
.
previous_id
=
current_id
end
...
...
@@ -60,7 +60,7 @@ module Gitlab
end
end
def
track_gap
(
current_id
)
def
track_gap
s
(
current_id
)
log_info
(
"Event log gap detected"
,
previous_event_id:
previous_id
,
current_event_id:
current_id
)
with_redis
do
|
redis
|
...
...
ee/spec/lib/gitlab/geo/event_gap_tracking_spec.rb
View file @
9371674b
...
...
@@ -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_gap
s
(
20
)
end
Timecop
.
travel
(
40
.
minutes
.
ago
)
do
gap_tracking
.
previous_id
=
12
gap_tracking
.
track_gap
(
14
)
gap_tracking
.
track_gap
s
(
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_gap
s
(
20
)
gap_tracking
.
previous_id
=
12
gap_tracking
.
track_gap
(
14
)
gap_tracking
.
track_gap
s
(
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_gap
s
)
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_gap
s
)
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_gap
s
'
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_gap
s
(
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_gap
s
(
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_gap
s
(
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_gap
s
(
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_gap
s
(
19
)
expected_gaps
<<
[
18
.
to_s
,
Time
.
now
.
to_i
]
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment