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
71cc57b1
Commit
71cc57b1
authored
Jun 04, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Geo::PushEvent to Geo::RepositoryUpdatedEvent
parent
5f28791b
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
40 additions
and
38 deletions
+40
-38
app/models/geo/event_log.rb
app/models/geo/event_log.rb
+2
-1
app/models/geo/repository_updated_event.rb
app/models/geo/repository_updated_event.rb
+1
-1
app/services/geo/repository_updated_event_store.rb
app/services/geo/repository_updated_event_store.rb
+5
-5
app/workers/ee/post_receive.rb
app/workers/ee/post_receive.rb
+2
-2
db/migrate/20170522194603_create_geo_repository_updated_events.rb
...te/20170522194603_create_geo_repository_updated_events.rb
+2
-2
db/migrate/20170522201800_create_geo_event_log.rb
db/migrate/20170522201800_create_geo_event_log.rb
+3
-2
db/schema.rb
db/schema.rb
+7
-7
spec/models/geo/event_log_spec.rb
spec/models/geo/event_log_spec.rb
+1
-1
spec/models/geo/repository_updated_event_spec.rb
spec/models/geo/repository_updated_event_spec.rb
+1
-1
spec/services/geo/repository_updated_event_store_spec.rb
spec/services/geo/repository_updated_event_store_spec.rb
+11
-11
spec/workers/ee/post_receive_spec.rb
spec/workers/ee/post_receive_spec.rb
+5
-5
No files found.
app/models/geo/event_log.rb
View file @
71cc57b1
...
...
@@ -2,6 +2,7 @@ module Geo
class
EventLog
<
ActiveRecord
::
Base
include
Geo
::
Model
belongs_to
:push_event
,
class_name:
'Geo::PushEvent'
,
foreign_key:
'push_event_id'
belongs_to
:repository_updated_event
,
class_name:
'Geo::RepositoryUpdatedEvent'
,
foreign_key:
'repository_updated_event_id'
end
end
app/models/geo/
push
_event.rb
→
app/models/geo/
repository_updated
_event.rb
View file @
71cc57b1
module
Geo
class
Push
Event
<
ActiveRecord
::
Base
class
RepositoryUpdated
Event
<
ActiveRecord
::
Base
include
Geo
::
Model
REPOSITORY
=
0
...
...
app/services/geo/
push
_event_store.rb
→
app/services/geo/
repository_updated
_event_store.rb
View file @
71cc57b1
module
Geo
class
Push
EventStore
class
RepositoryUpdated
EventStore
attr_reader
:project
,
:source
,
:refs
,
:changes
def
initialize
(
project
,
refs:
[],
changes:
[],
source:
Geo
::
Push
Event
::
REPOSITORY
)
def
initialize
(
project
,
refs:
[],
changes:
[],
source:
Geo
::
RepositoryUpdated
Event
::
REPOSITORY
)
@project
=
project
@refs
=
refs
@changes
=
changes
...
...
@@ -14,7 +14,7 @@ module Geo
Geo
::
EventLog
.
transaction
do
event_log
=
Geo
::
EventLog
.
new
event_log
.
push_event
=
build_push
_event
event_log
.
repository_updated_event
=
build
_event
event_log
.
save!
end
rescue
ActiveRecord
::
RecordInvalid
...
...
@@ -23,8 +23,8 @@ module Geo
private
def
build_
push_
event
Geo
::
Push
Event
.
new
(
def
build_event
Geo
::
RepositoryUpdated
Event
.
new
(
project:
project
,
source:
source
,
ref:
ref
,
...
...
app/workers/ee/post_receive.rb
View file @
71cc57b1
...
...
@@ -13,7 +13,7 @@ module EE
super
# Generate repository updated event on Geo event log when Geo is enabled
::
Geo
::
Push
EventStore
.
new
(
post_received
.
project
,
refs:
refs
,
changes:
changes
).
create
::
Geo
::
RepositoryUpdated
EventStore
.
new
(
post_received
.
project
,
refs:
refs
,
changes:
changes
).
create
end
def
process_wiki_changes
(
post_received
)
...
...
@@ -23,7 +23,7 @@ module EE
if
::
Gitlab
::
Geo
.
enabled?
# Create wiki repository updated event on Geo event log
::
Geo
::
PushEventStore
.
new
(
post_received
.
project
,
source:
Geo
::
Push
Event
::
WIKI
).
create
::
Geo
::
RepositoryUpdatedEventStore
.
new
(
post_received
.
project
,
source:
Geo
::
RepositoryUpdated
Event
::
WIKI
).
create
# Triggers repository update on secondary nodes
::
Gitlab
::
Geo
.
notify_wiki_update
(
post_received
.
project
)
...
...
db/migrate/20170522194603_create_geo_
push
_events.rb
→
db/migrate/20170522194603_create_geo_
repository_updated
_events.rb
View file @
71cc57b1
class
CreateGeo
Push
Events
<
ActiveRecord
::
Migration
class
CreateGeo
RepositoryUpdated
Events
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
change
create_table
:geo_
push
_events
,
id: :bigserial
do
|
t
|
create_table
:geo_
repository_updated
_events
,
id: :bigserial
do
|
t
|
t
.
datetime
:created_at
,
null:
false
t
.
integer
:branches_affected
,
null:
false
t
.
integer
:tags_affected
,
null:
false
...
...
db/migrate/20170522201800_create_geo_event_log.rb
View file @
71cc57b1
...
...
@@ -4,9 +4,10 @@ class CreateGeoEventLog < ActiveRecord::Migration
def
change
create_table
:geo_event_log
,
id: :bigserial
do
|
t
|
t
.
datetime
:created_at
,
index:
true
,
null:
false
t
.
integer
:
push
_event_id
,
limit:
8
,
index:
true
t
.
integer
:
repository_updated
_event_id
,
limit:
8
,
index:
true
t
.
foreign_key
:geo_push_events
,
column: :push_event_id
,
on_delete: :cascade
t
.
foreign_key
:geo_repository_updated_events
,
column: :repository_updated_event_id
,
on_delete: :cascade
end
end
end
db/schema.rb
View file @
71cc57b1
...
...
@@ -502,11 +502,11 @@ ActiveRecord::Schema.define(version: 20170602003304) do
create_table
"geo_event_log"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
datetime
"created_at"
,
null:
false
t
.
integer
"
push
_event_id"
,
limit:
8
t
.
integer
"
repository_updated
_event_id"
,
limit:
8
end
add_index
"geo_event_log"
,
[
"created_at"
],
name:
"index_geo_event_log_on_created_at"
,
using: :btree
add_index
"geo_event_log"
,
[
"
push_event_id"
],
name:
"index_geo_event_log_on_push
_event_id"
,
using: :btree
add_index
"geo_event_log"
,
[
"
repository_updated_event_id"
],
name:
"index_geo_event_log_on_repository_updated
_event_id"
,
using: :btree
create_table
"geo_nodes"
,
force: :cascade
do
|
t
|
t
.
string
"schema"
...
...
@@ -528,7 +528,7 @@ ActiveRecord::Schema.define(version: 20170602003304) do
add_index
"geo_nodes"
,
[
"host"
],
name:
"index_geo_nodes_on_host"
,
using: :btree
add_index
"geo_nodes"
,
[
"primary"
],
name:
"index_geo_nodes_on_primary"
,
using: :btree
create_table
"geo_
push
_events"
,
id: :bigserial
,
force: :cascade
do
|
t
|
create_table
"geo_
repository_updated
_events"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
datetime
"created_at"
,
null:
false
t
.
integer
"branches_affected"
,
null:
false
t
.
integer
"tags_affected"
,
null:
false
...
...
@@ -539,8 +539,8 @@ ActiveRecord::Schema.define(version: 20170602003304) do
t
.
text
"ref"
end
add_index
"geo_
push_events"
,
[
"project_id"
],
name:
"index_geo_push
_events_on_project_id"
,
using: :btree
add_index
"geo_
push_events"
,
[
"source"
],
name:
"index_geo_push
_events_on_source"
,
using: :btree
add_index
"geo_
repository_updated_events"
,
[
"project_id"
],
name:
"index_geo_repository_updated
_events_on_project_id"
,
using: :btree
add_index
"geo_
repository_updated_events"
,
[
"source"
],
name:
"index_geo_repository_updated
_events_on_source"
,
using: :btree
create_table
"historical_data"
,
force: :cascade
do
|
t
|
t
.
date
"date"
,
null:
false
...
...
@@ -1688,8 +1688,8 @@ ActiveRecord::Schema.define(version: 20170602003304) do
add_foreign_key
"ci_triggers"
,
"users"
,
column:
"owner_id"
,
name:
"fk_e8e10d1964"
,
on_delete: :cascade
add_foreign_key
"ci_variables"
,
"projects"
,
name:
"fk_ada5eb64b3"
,
on_delete: :cascade
add_foreign_key
"container_repositories"
,
"projects"
add_foreign_key
"geo_event_log"
,
"geo_
push_events"
,
column:
"push
_event_id"
,
on_delete: :cascade
add_foreign_key
"geo_
push
_events"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"geo_event_log"
,
"geo_
repository_updated_events"
,
column:
"repository_updated
_event_id"
,
on_delete: :cascade
add_foreign_key
"geo_
repository_updated
_events"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"issues"
,
name:
"fk_b7d881734a"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"users"
,
name:
"fk_5e0c8d9154"
,
on_delete: :cascade
add_foreign_key
"issue_metrics"
,
"issues"
,
on_delete: :cascade
...
...
spec/models/geo/event_log_spec.rb
View file @
71cc57b1
...
...
@@ -2,6 +2,6 @@ require 'rails_helper'
RSpec
.
describe
Geo
::
EventLog
,
type: :model
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:
push_event
).
class_name
(
'Geo::PushEvent'
).
with_foreign_key
(
'push
_event_id'
)
}
it
{
is_expected
.
to
belong_to
(
:
repository_updated_event
).
class_name
(
'Geo::RepositoryUpdatedEvent'
).
with_foreign_key
(
'repository_updated
_event_id'
)
}
end
end
spec/models/geo/
push
_event_spec.rb
→
spec/models/geo/
repository_updated
_event_spec.rb
View file @
71cc57b1
require
'rails_helper'
RSpec
.
describe
Geo
::
Push
Event
,
type: :model
do
RSpec
.
describe
Geo
::
RepositoryUpdated
Event
,
type: :model
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
end
...
...
spec/services/geo/
push
_event_store_spec.rb
→
spec/services/geo/
repository_updated
_event_store_spec.rb
View file @
71cc57b1
require
'spec_helper'
describe
Geo
::
Push
EventStore
,
services:
true
do
describe
Geo
::
RepositoryUpdated
EventStore
,
services:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:blankrev
)
{
Gitlab
::
Git
::
BLANK_SHA
}
let
(
:refs
)
{
[
'refs/heads/tést'
,
'refs/tags/tag'
]
}
...
...
@@ -18,7 +18,7 @@ describe Geo::PushEventStore, services: true do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
expect
{
subject
.
create
}.
not_to
change
(
Geo
::
Push
Event
,
:count
)
expect
{
subject
.
create
}.
not_to
change
(
Geo
::
RepositoryUpdated
Event
,
:count
)
end
context
'when running on a primary node'
do
...
...
@@ -29,7 +29,7 @@ describe Geo::PushEventStore, services: true do
it
'creates a push event'
do
subject
=
described_class
.
new
(
project
,
refs:
refs
,
changes:
changes
)
expect
{
subject
.
create
}.
to
change
(
Geo
::
Push
Event
,
:count
).
by
(
1
)
expect
{
subject
.
create
}.
to
change
(
Geo
::
RepositoryUpdated
Event
,
:count
).
by
(
1
)
end
context
'when repository is being updated'
do
...
...
@@ -38,7 +38,7 @@ describe Geo::PushEventStore, services: true do
subject
.
create
expect
(
Geo
::
Push
Event
.
last
.
ref
).
to
be_nil
expect
(
Geo
::
RepositoryUpdated
Event
.
last
.
ref
).
to
be_nil
end
it
'tracks ref name when post-receive event affect single ref'
do
...
...
@@ -48,7 +48,7 @@ describe Geo::PushEventStore, services: true do
subject
.
create
expect
(
Geo
::
Push
Event
.
last
.
ref
).
to
eq
'refs/heads/tést'
expect
(
Geo
::
RepositoryUpdated
Event
.
last
.
ref
).
to
eq
'refs/heads/tést'
end
it
'tracks number of branches post-receive event affects'
do
...
...
@@ -56,7 +56,7 @@ describe Geo::PushEventStore, services: true do
subject
.
create
expect
(
Geo
::
Push
Event
.
last
.
branches_affected
).
to
eq
1
expect
(
Geo
::
RepositoryUpdated
Event
.
last
.
branches_affected
).
to
eq
1
end
it
'tracks number of tags post-receive event affects'
do
...
...
@@ -64,7 +64,7 @@ describe Geo::PushEventStore, services: true do
subject
.
create
expect
(
Geo
::
Push
Event
.
last
.
tags_affected
).
to
eq
1
expect
(
Geo
::
RepositoryUpdated
Event
.
last
.
tags_affected
).
to
eq
1
end
it
'tracks when post-receive event create new branches'
do
...
...
@@ -78,7 +78,7 @@ describe Geo::PushEventStore, services: true do
subject
.
create
expect
(
Geo
::
Push
Event
.
last
.
new_branch
).
to
eq
true
expect
(
Geo
::
RepositoryUpdated
Event
.
last
.
new_branch
).
to
eq
true
end
it
'tracks when post-receive event remove branches'
do
...
...
@@ -91,17 +91,17 @@ describe Geo::PushEventStore, services: true do
subject
.
create
expect
(
Geo
::
Push
Event
.
last
.
remove_branch
).
to
eq
true
expect
(
Geo
::
RepositoryUpdated
Event
.
last
.
remove_branch
).
to
eq
true
end
end
context
'when wiki is being updated'
do
it
'does not track any information'
do
subject
=
described_class
.
new
(
project
,
source:
Geo
::
Push
Event
::
WIKI
)
subject
=
described_class
.
new
(
project
,
source:
Geo
::
RepositoryUpdated
Event
::
WIKI
)
subject
.
create
push_event
=
Geo
::
Push
Event
.
last
push_event
=
Geo
::
RepositoryUpdated
Event
.
last
expect
(
push_event
.
ref
).
to
be_nil
expect
(
push_event
.
branches_affected
).
to
be_zero
...
...
spec/workers/ee/post_receive_spec.rb
View file @
71cc57b1
...
...
@@ -25,8 +25,8 @@ describe PostReceive do
allow_any_instance_of
(
GitPushService
).
to
receive
(
:execute
).
and_return
(
true
)
end
it
'calls Geo::
Push
EventStore'
do
expect_any_instance_of
(
Geo
::
Push
EventStore
).
to
receive
(
:create
)
it
'calls Geo::
RepositoryUpdated
EventStore'
do
expect_any_instance_of
(
Geo
::
RepositoryUpdated
EventStore
).
to
receive
(
:create
)
described_class
.
new
.
perform
(
project_identifier
,
key_id
,
base64_changes
)
end
...
...
@@ -36,11 +36,11 @@ describe PostReceive do
describe
'#process_wiki_changes'
do
let
(
:project_identifier
)
{
"
#{
pwd
(
project
)
}
.wiki"
}
it
'triggers Geo::
Push
EventStore when Geo is enabled'
do
it
'triggers Geo::
RepositoryUpdated
EventStore when Geo is enabled'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
true
}
expect
(
Geo
::
PushEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
Push
Event
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
Push
EventStore
).
to
receive
(
:create
)
expect
(
Geo
::
RepositoryUpdatedEventStore
).
to
receive
(
:new
).
with
(
instance_of
(
Project
),
source:
Geo
::
RepositoryUpdated
Event
::
WIKI
).
and_call_original
expect_any_instance_of
(
Geo
::
RepositoryUpdated
EventStore
).
to
receive
(
:create
)
described_class
.
new
.
perform
(
project_identifier
,
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