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
25a7f449
Commit
25a7f449
authored
Jun 27, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle exceptions when syncing project repositories
parent
e191eb67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
22 deletions
+31
-22
app/services/geo/repository_sync_service.rb
app/services/geo/repository_sync_service.rb
+1
-1
spec/services/geo/repository_sync_service_spec.rb
spec/services/geo/repository_sync_service_spec.rb
+30
-21
No files found.
app/services/geo/repository_sync_service.rb
View file @
25a7f449
...
...
@@ -96,7 +96,7 @@ module Geo
project
.
wiki
.
repository
.
fetch_geo_mirror
(
ssh_url_to_wiki
)
finished_at
=
DateTime
.
now
rescue
Gitlab
::
Shell
::
Error
,
ProjectWiki
::
CouldNotCreateWikiError
=>
e
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
,
Gitlab
::
Shell
::
Error
,
ProjectWiki
::
CouldNotCreateWikiError
=>
e
Rails
.
logger
.
error
(
"
#{
self
.
class
.
name
}
: Error syncing wiki repository for project
#{
project
.
path_with_namespace
}
:
#{
e
}
"
)
end
...
...
spec/services/geo/repository_sync_service_spec.rb
View file @
25a7f449
...
...
@@ -214,6 +214,22 @@ describe Geo::RepositorySyncService, services: true do
subject
.
execute
end
context
'exceptions'
do
it
'rescues when Gitlab::Shell::Error is raised'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
).
with
(
/
#{
project
.
path_with_namespace
}
\.git/
)
{
raise
Gitlab
::
Shell
::
Error
}
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'rescues exception and fires after_create hook when Gitlab::Git::Repository::NoRepository is raised'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
).
with
(
/
#{
project
.
path_with_namespace
}
\.git/
)
{
raise
Gitlab
::
Git
::
Repository
::
NoRepository
}
expect_any_instance_of
(
Repository
).
to
receive
(
:after_create
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
end
context
'tracking database'
do
it
'updates last_repository_successful_sync_at'
do
subject
.
execute
...
...
@@ -266,6 +282,20 @@ describe Geo::RepositorySyncService, services: true do
subject
.
execute
end
context
'exceptions'
do
it
'rescues exception when Gitlab::Shell::Error is raised'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
).
with
(
/
#{
project
.
path_with_namespace
}
\.wiki\.git/
)
{
raise
Gitlab
::
Shell
::
Error
}
expect
{
subject
.
execute
}.
not_to
raise_error
end
it
'rescues exception when Gitlab::Git::Repository::NoRepository is raised'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
).
with
(
/
#{
project
.
path_with_namespace
}
\.wiki\.git/
)
{
raise
Gitlab
::
Git
::
Repository
::
NoRepository
}
expect
{
subject
.
execute
}.
not_to
raise_error
end
end
context
'tracking database'
do
it
'updates last_wiki_successful_sync_at'
do
subject
.
execute
...
...
@@ -294,26 +324,5 @@ describe Geo::RepositorySyncService, services: true do
end
end
end
context
'when Gitlab::Shell::Error is raised'
do
let
(
:project
)
{
create
(
:empty_project
)
}
it
'rescues exception'
do
expect
(
subject
).
to
receive
(
:fetch_project_repository
).
and_raise
(
Gitlab
::
Shell
::
Error
)
expect
{
subject
.
execute
}.
not_to
raise_error
end
end
context
'when Gitlab::Git::Repository::NoRepository is raised'
do
let
(
:project
)
{
create
(
:empty_project
)
}
it
'rescues exception and fires after_create hook'
do
expect
(
subject
).
to
receive
(
:fetch_project_repository
).
and_raise
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect_any_instance_of
(
Repository
).
to
receive
(
:after_create
)
expect
{
subject
.
execute
}.
not_to
raise_error
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