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
5c3ca746
Commit
5c3ca746
authored
Nov 03, 2017
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More the specs more robust
By actually checking if it deletes the correct Geo Event Log events.
parent
f56731fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
app/workers/geo/prune_event_log_worker.rb
app/workers/geo/prune_event_log_worker.rb
+1
-1
spec/workers/geo/prune_event_log_worker_spec.rb
spec/workers/geo/prune_event_log_worker_spec.rb
+13
-11
No files found.
app/workers/geo/prune_event_log_worker.rb
View file @
5c3ca746
...
...
@@ -31,7 +31,7 @@ module Geo
end
log_info
(
'Delete Geo Event Log entries up to id'
,
geo_event_log_id:
cursor_last_event_ids
.
min
)
Geo
::
EventLog
.
delete_all
([
'id < ?'
,
cursor_last_event_ids
.
min
])
Geo
::
EventLog
.
where
(
'id < ?'
,
cursor_last_event_ids
.
min
).
delete_all
end
end
end
...
...
spec/workers/geo/prune_event_log_worker_spec.rb
View file @
5c3ca746
...
...
@@ -43,10 +43,11 @@ describe Geo::PruneEventLogWorker, :geo do
end
it
'deletes everything from the Geo event log'
do
create_list
(
:geo_event_log
,
2
)
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'No secondary nodes, delete all Geo Event Log entries'
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
)
worker
.
perform
expect
{
worker
.
perform
}.
to
change
{
Geo
::
EventLog
.
count
}.
by
(
-
2
)
end
end
...
...
@@ -64,28 +65,29 @@ describe Geo::PruneEventLogWorker, :geo do
it
'contacts all secondary nodes for their status'
do
expect
(
node_status_service
).
to
receive
(
:call
).
twice
{
healthy_status
}
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Delete Geo Event Log entries up to id'
,
anything
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
)
worker
.
perform
end
it
'aborts when there are unhealthy nodes'
do
create_list
(
:geo_event_log
,
2
)
expect
(
node_status_service
).
to
receive
(
:call
).
twice
.
and_return
(
healthy_status
,
unhealthy_status
)
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Could not get status of all nodes, not deleting any entries from Geo Event Log'
,
unhealthy_node_count:
1
)
expect
(
Geo
::
EventLog
).
not_to
receive
(
:delete_all
)
worker
.
perform
expect
{
worker
.
perform
}.
not_to
change
{
Geo
::
EventLog
.
count
}
end
it
'takes the integer-minimum value of all nodes'
do
it
'takes the integer-minimum value of all cursor_last_event_ids'
do
events
=
create_list
(
:geo_event_log
,
12
)
allow
(
node_status_service
).
to
receive
(
:call
).
twice
.
and_return
(
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
3
),
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
10
)
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
events
[
3
]
),
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
events
.
last
)
)
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Delete Geo Event Log entries up to id'
,
geo_event_log_id:
3
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
).
with
([
'id < ?'
,
3
])
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Delete Geo Event Log entries up to id'
,
geo_event_log_id:
events
[
3
])
worker
.
perform
expect
{
worker
.
perform
}.
to
change
{
Geo
::
EventLog
.
count
}.
by
(
-
3
)
end
end
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