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
d8bd743e
Commit
d8bd743e
authored
May 31, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Geo::PushService to Geo::PushEventStore
parent
e48bba6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
app/services/geo/push_event_store.rb
app/services/geo/push_event_store.rb
+2
-2
app/workers/post_receive.rb
app/workers/post_receive.rb
+4
-4
spec/services/geo/push_event_store_spec.rb
spec/services/geo/push_event_store_spec.rb
+11
-11
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+5
-5
No files found.
app/services/geo/push_
servic
e.rb
→
app/services/geo/push_
event_stor
e.rb
View file @
d8bd743e
module
Geo
class
Push
Servic
e
class
Push
EventStor
e
attr_reader
:project
,
:source
,
:refs
,
:changes
def
initialize
(
project
,
refs:
[],
changes:
[],
source:
Geo
::
PushEvent
::
REPOSITORY
)
...
...
@@ -9,7 +9,7 @@ module Geo
@source
=
source
end
def
execu
te
def
crea
te
return
unless
Gitlab
::
Geo
.
primary?
Geo
::
EventLog
.
transaction
do
...
...
app/workers/post_receive.rb
View file @
d8bd743e
...
...
@@ -18,7 +18,7 @@ class PostReceive
post_received
=
Gitlab
::
GitPostReceive
.
new
(
project
,
identifier
,
changes
)
if
is_wiki
process_wiki_update
(
post_received
)
process_wiki_
repository_
update
(
post_received
)
else
process_project_changes
(
post_received
)
process_repository_update
(
post_received
)
...
...
@@ -42,18 +42,18 @@ class PostReceive
end
# Generate repository update event on Geo event log when Geo is enabled
Geo
::
Push
Service
.
new
(
post_received
.
project
,
refs:
refs
.
to_a
,
changes:
changes
).
execu
te
Geo
::
Push
EventStore
.
new
(
post_received
.
project
,
refs:
refs
.
to_a
,
changes:
changes
).
crea
te
hook_data
=
Gitlab
::
DataBuilder
::
Repository
.
update
(
post_received
.
project
,
@user
,
changes
,
refs
.
to_a
)
SystemHooksService
.
new
.
execute_hooks
(
hook_data
,
:repository_update_hooks
)
end
def
process_wiki_update
(
post_received
)
def
process_wiki_
repository_
update
(
post_received
)
update_wiki_es_indexes
(
post_received
)
if
Gitlab
::
Geo
.
enabled?
# Generate wiki update event on Geo event log
Geo
::
Push
Service
.
new
(
post_received
.
project
,
source:
Geo
::
PushEvent
::
WIKI
).
execu
te
Geo
::
Push
EventStore
.
new
(
post_received
.
project
,
source:
Geo
::
PushEvent
::
WIKI
).
crea
te
# Triggers repository update on secondary nodes
Gitlab
::
Geo
.
notify_wiki_update
(
post_received
.
project
)
...
...
spec/services/geo/push_
servic
e_spec.rb
→
spec/services/geo/push_
event_stor
e_spec.rb
View file @
d8bd743e
require
'spec_helper'
describe
Geo
::
Push
Servic
e
,
services:
true
do
describe
Geo
::
Push
EventStor
e
,
services:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:blankrev
)
{
Gitlab
::
Git
::
BLANK_SHA
}
let
(
:refs
)
{
[
'refs/heads/tést'
,
'refs/tags/tag'
]
}
...
...
@@ -12,13 +12,13 @@ describe Geo::PushService, services: true do
]
end
describe
'#
execu
te'
do
describe
'#
crea
te'
do
it
'does not create a push event when not running on a primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
expect
{
subject
.
execu
te
}.
not_to
change
(
Geo
::
PushEvent
,
:count
)
expect
{
subject
.
crea
te
}.
not_to
change
(
Geo
::
PushEvent
,
:count
)
end
context
'when running on a primary node'
do
...
...
@@ -29,14 +29,14 @@ describe Geo::PushService, services: true do
it
'creates a push event'
do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
expect
{
subject
.
execu
te
}.
to
change
(
Geo
::
PushEvent
,
:count
).
by
(
1
)
expect
{
subject
.
crea
te
}.
to
change
(
Geo
::
PushEvent
,
:count
).
by
(
1
)
end
context
'when repository is beign udpated'
do
it
'does not track ref name when post-receive event affect multiple refs'
do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
subject
.
execu
te
subject
.
crea
te
expect
(
Geo
::
PushEvent
.
last
.
ref
).
to
be_nil
end
...
...
@@ -46,7 +46,7 @@ describe Geo::PushService, services: true do
changes
=
[{
before:
'123456'
,
after:
blankrev
,
ref:
'refs/heads/tést'
}]
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
subject
.
execu
te
subject
.
crea
te
expect
(
Geo
::
PushEvent
.
last
.
ref
).
to
eq
'refs/heads/tést'
end
...
...
@@ -54,7 +54,7 @@ describe Geo::PushService, services: true do
it
'tracks number of branches post-receive event affects'
do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
subject
.
execu
te
subject
.
crea
te
expect
(
Geo
::
PushEvent
.
last
.
branches_affected
).
to
eq
1
end
...
...
@@ -62,7 +62,7 @@ describe Geo::PushService, services: true do
it
'tracks number of tags post-receive event affects'
do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
subject
.
execu
te
subject
.
crea
te
expect
(
Geo
::
PushEvent
.
last
.
tags_affected
).
to
eq
1
end
...
...
@@ -76,7 +76,7 @@ describe Geo::PushService, services: true do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
subject
.
execu
te
subject
.
crea
te
expect
(
Geo
::
PushEvent
.
last
.
new_branch
).
to
eq
true
end
...
...
@@ -89,7 +89,7 @@ describe Geo::PushService, services: true do
]
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
subject
.
execu
te
subject
.
crea
te
expect
(
Geo
::
PushEvent
.
last
.
remove_branch
).
to
eq
true
end
...
...
@@ -99,7 +99,7 @@ describe Geo::PushService, services: true do
it
'does not track any information'
do
subject
=
described_class
.
new
(
project
,
source:
Geo
::
PushEvent
::
WIKI
)
subject
.
execu
te
subject
.
crea
te
push_event
=
Geo
::
PushEvent
.
last
...
...
spec/workers/post_receive_spec.rb
View file @
d8bd743e
...
...
@@ -110,8 +110,8 @@ describe PostReceive do
allow
(
subject
).
to
receive
(
:process_project_changes
).
and_return
(
true
)
end
it
'calls Geo::Push
Servic
e'
do
expect_any_instance_of
(
Geo
::
Push
Service
).
to
receive
(
:execu
te
)
it
'calls Geo::Push
EventStor
e'
do
expect_any_instance_of
(
Geo
::
Push
EventStore
).
to
receive
(
:crea
te
)
subject
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
...
...
@@ -124,11 +124,11 @@ describe PostReceive do
end
describe
'#process_wiki_update'
do
it
'triggers Geo::Push
Servic
e when Geo is enabled'
do
it
'triggers Geo::Push
EventStor
e when Geo is enabled'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
true
}
expect
(
Geo
::
Push
Servic
e
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
Push
Service
).
to
receive
(
:execu
te
)
expect
(
Geo
::
Push
EventStor
e
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
PushEvent
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
Push
EventStore
).
to
receive
(
:crea
te
)
described_class
.
new
.
perform
(
"
#{
pwd
(
project
)
}
.wiki"
,
key_id
,
base64_changes
)
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