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
eb4a4dcc
Commit
eb4a4dcc
authored
Sep 05, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedules repository sync when handling events in the Geo Log Cursor
parent
66062c09
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+4
-0
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+22
-6
No files found.
lib/gitlab/geo/log_cursor/daemon.rb
View file @
eb4a4dcc
...
...
@@ -5,6 +5,7 @@ module Gitlab
VERSION
=
'0.1.0'
.
freeze
POOL_WAIT
=
5
.
seconds
.
freeze
BATCH_SIZE
=
250
SYNC_BACKOFF_DELAY
=
5
.
minutes
attr_reader
:options
...
...
@@ -121,6 +122,7 @@ module Gitlab
registry
.
save!
::
Geo
::
ProjectSyncWorker
.
perform_in
(
SYNC_BACKOFF_DELAY
,
event
.
project_id
,
Time
.
now
)
end
def
handle_repository_updated
(
event_log
)
...
...
@@ -136,6 +138,8 @@ module Gitlab
resync_wiki:
registry
.
resync_wiki
)
registry
.
save!
::
Geo
::
ProjectSyncWorker
.
perform_in
(
SYNC_BACKOFF_DELAY
,
event
.
project_id
,
Time
.
now
)
end
def
handle_repository_deleted
(
event_log
)
...
...
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
eb4a4dcc
require
'spec_helper'
describe
Gitlab
::
Geo
::
LogCursor
::
Daemon
,
:postgresql
do
include
::
EE
::
GeoHelpers
...
...
@@ -31,7 +30,8 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql do
end
context
'when replaying a repository created event'
do
let
(
:repository_created_event
)
{
create
(
:geo_repository_created_event
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository_created_event
)
{
create
(
:geo_repository_created_event
,
project:
project
)
}
let
(
:event_log
)
{
create
(
:geo_event_log
,
repository_created_event:
repository_created_event
)
}
let!
(
:event_log_state
)
{
create
(
:geo_event_log_state
,
event_id:
event_log
.
id
-
1
)
}
...
...
@@ -48,7 +48,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql do
registry
=
Geo
::
ProjectRegistry
.
last
expect
(
registry
).
to
have_attributes
(
resync_repository:
true
,
resync_wiki:
true
)
expect
(
registry
).
to
have_attributes
(
project_id:
project
.
id
,
resync_repository:
true
,
resync_wiki:
true
)
end
it
'sets resync_wiki to false if wiki_path is nil'
do
...
...
@@ -58,14 +58,22 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql do
registry
=
Geo
::
ProjectRegistry
.
last
expect
(
registry
).
to
have_attributes
(
resync_repository:
true
,
resync_wiki:
false
)
expect
(
registry
).
to
have_attributes
(
project_id:
project
.
id
,
resync_repository:
true
,
resync_wiki:
false
)
end
it
'performs Geo::ProjectSyncWorker'
do
expect
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_in
)
.
with
(
anything
,
project
.
id
,
anything
).
once
.
and_return
(
spy
)
subject
.
run!
end
end
context
'when replaying a repository updated event'
do
let
(
:event_log
)
{
create
(
:geo_event_log
,
:updated_event
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository_updated_event
)
{
create
(
:geo_repository_updated_event
,
project:
project
)
}
let
(
:event_log
)
{
create
(
:geo_event_log
,
repository_updated_event:
repository_updated_event
)
}
let!
(
:event_log_state
)
{
create
(
:geo_event_log_state
,
event_id:
event_log
.
id
-
1
)
}
let
(
:repository_updated_event
)
{
event_log
.
repository_updated_event
}
before
do
allow
(
subject
).
to
receive
(
:exit?
).
and_return
(
false
,
true
)
...
...
@@ -92,6 +100,13 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql do
expect
(
registry
.
reload
.
resync_wiki
).
to
be
true
end
it
'performs Geo::ProjectSyncWorker'
do
expect
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_in
)
.
with
(
anything
,
project
.
id
,
anything
).
once
.
and_return
(
spy
)
subject
.
run!
end
end
context
'when replaying a repository deleted event'
do
...
...
@@ -156,6 +171,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql do
before
do
allow
(
subject
).
to
receive
(
:exit?
).
and_return
(
false
,
true
)
allow
(
Geo
::
ProjectSyncWorker
).
to
receive
(
:perform_in
).
and_return
(
spy
)
end
it
'replays events for projects that belong to selected namespaces to replicate'
do
...
...
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