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
61d3aae6
Commit
61d3aae6
authored
May 02, 2018
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only write to tracking database when node is a Geo secondary
parent
1ccf720c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
13 deletions
+39
-13
ee/app/workers/ee/repository_check/single_repository_worker.rb
...p/workers/ee/repository_check/single_repository_worker.rb
+6
-7
ee/spec/workers/ee/repository_check/single_repository_worker_spec.rb
...kers/ee/repository_check/single_repository_worker_spec.rb
+33
-6
No files found.
ee/app/workers/ee/repository_check/single_repository_worker.rb
View file @
61d3aae6
...
...
@@ -7,17 +7,16 @@ module EE
private
override
:save_result
def
save_result
(
project
,
failure
)
# TODO: Check for Geo
def
save_result
(
project
,
result
)
return
super
unless
::
Gitlab
::
Geo
.
secondary?
# TODO: What if project registry does not exist
project_registry
=
::
Geo
::
ProjectRegistry
.
find_or_initialize_by
(
project:
project
)
project_registry
=
Geo
::
ProjectRegistry
.
find_by
(
project_id:
project
.
id
)
project_registry
.
update_columns
(
last_repository_check_failed:
failure
,
project_registry
.
assign_attributes
(
last_repository_check_failed:
!
result
,
last_repository_check_at:
Time
.
now
)
project_registry
.
save!
end
end
end
...
...
ee/spec/workers/ee/repository_check/single_repository_worker_spec.rb
View file @
61d3aae6
require
'spec_helper'
describe
EE
::
RepositoryCheck
::
SingleRepositoryWorker
do
include
::
EE
::
GeoHelpers
set
(
:project
)
{
create
(
:project
)
}
set
(
:project_registry
)
{
create
(
:geo_project_registry
,
project:
project
)
}
set
(
:secondary
)
{
create
(
:geo_node
)
}
subject
(
:worker
)
{
RepositoryCheck
::
SingleRepositoryWorker
.
new
}
it
'saves results to Geo registry'
do
expect
do
worker
.
perform
(
project
.
id
)
end
.
to
change
{
project_registry
.
reload
.
last_repository_check_at
}
context
'Geo primary'
do
set
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
before
do
stub_current_geo_node
(
primary
)
end
it
'saves results to main database'
do
expect
do
worker
.
perform
(
project
.
id
)
end
.
to
change
{
project
.
reload
.
last_repository_check_at
}
expect
(
project
.
last_repository_check_failed
).
to
be_falsy
end
end
context
'Geo secondary'
do
set
(
:project_registry
)
{
create
(
:geo_project_registry
,
project:
project
)
}
set
(
:secondary
)
{
create
(
:geo_node
)
}
before
do
stub_current_geo_node
(
secondary
)
end
it
'saves results to Geo registry'
do
expect
do
worker
.
perform
(
project
.
id
)
end
.
to
change
{
project_registry
.
reload
.
last_repository_check_at
}
expect
(
project_registry
.
last_repository_check_failed
).
to
be_falsy
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