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
7ee178db
Commit
7ee178db
authored
Jul 06, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Geo log cursor when handling a repository updated event
parent
c44339d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+1
-1
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+34
-4
No files found.
lib/gitlab/geo/log_cursor/daemon.rb
View file @
7ee178db
...
...
@@ -82,7 +82,7 @@ module Gitlab
end
def
handle_repository_update
(
updated_event
)
registry
=
::
Geo
::
ProjectRegistry
.
find_or_initialize_by
(
project_id:
project_id
)
registry
=
::
Geo
::
ProjectRegistry
.
find_or_initialize_by
(
project_id:
updated_event
.
project_id
)
case
updated_event
.
source
when
'repository'
...
...
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
7ee178db
...
...
@@ -2,10 +2,6 @@ require 'spec_helper'
describe
Gitlab
::
Geo
::
LogCursor
::
Daemon
,
lib:
true
do
describe
'#run!'
do
before
do
allow
(
subject
).
to
receive
(
:exit?
)
{
true
}
end
it
'traps signals'
do
allow
(
subject
).
to
receive
(
:exit?
)
{
true
}
expect
(
subject
).
to
receive
(
:trap_signals
)
...
...
@@ -17,10 +13,44 @@ describe Gitlab::Geo::LogCursor::Daemon, lib: true do
subject
{
described_class
.
new
(
full_scan:
true
)
}
it
'executes a full-scan'
do
allow
(
subject
).
to
receive
(
:exit?
)
{
true
}
expect
(
subject
).
to
receive
(
:full_scan!
)
subject
.
run!
end
end
context
'when processing a repository updated event'
do
let
(
:event_log
)
{
create
(
:geo_event_log
)
}
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
)
end
it
'creates a new project registry if does not exists'
do
expect
{
subject
.
run!
}.
to
change
(
Geo
::
ProjectRegistry
,
:count
).
by
(
1
)
end
it
'sets resync_repository to true if event source is repository'
do
repository_updated_event
.
update_attribute
(
:source
,
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
)
registry
=
create
(
:geo_project_registry
,
:synced
,
project:
repository_updated_event
.
project
)
subject
.
run!
expect
(
registry
.
reload
.
resync_repository
).
to
be
true
end
it
'sets resync_wiki to true if event source is wiki'
do
repository_updated_event
.
update_attribute
(
:source
,
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
registry
=
create
(
:geo_project_registry
,
:synced
,
project:
repository_updated_event
.
project
)
subject
.
run!
expect
(
registry
.
reload
.
resync_wiki
).
to
be
true
end
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