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
c54e08cf
Commit
c54e08cf
authored
May 02, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactors git push service spec code
parent
be0f6c42
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
100 deletions
+123
-100
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+1
-5
app/workers/repository_update_remote_mirror_worker.rb
app/workers/repository_update_remote_mirror_worker.rb
+1
-1
doc/workflow/repository_mirroring.md
doc/workflow/repository_mirroring.md
+1
-1
spec/models/remote_mirror_spec.rb
spec/models/remote_mirror_spec.rb
+32
-0
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+87
-92
spec/workers/repository_update_remote_mirror_worker_spec.rb
spec/workers/repository_update_remote_mirror_worker_spec.rb
+1
-1
No files found.
app/models/remote_mirror.rb
View file @
c54e08cf
...
...
@@ -76,7 +76,7 @@ class RemoteMirror < ActiveRecord::Base
def
sync
return
unless
project
&&
enabled
schedule_update_job
RepositoryUpdateRemoteMirrorWorker
.
perform_in
(
BACKOFF_DELAY
,
self
.
id
,
Time
.
now
)
if
project
&
.
repository_exists?
end
def
updated_since?
(
timestamp
)
...
...
@@ -133,10 +133,6 @@ class RemoteMirror < ActiveRecord::Base
)
end
def
schedule_update_job
RepositoryUpdateRemoteMirrorWorker
.
perform_in
(
BACKOFF_DELAY
,
self
.
id
,
Time
.
now
)
if
project
&
.
repository_exists?
end
def
refresh_remote
return
unless
project
...
...
app/workers/repository_update_remote_mirror_worker.rb
View file @
c54e08cf
...
...
@@ -5,7 +5,7 @@ class RepositoryUpdateRemoteMirrorWorker
include
Sidekiq
::
Worker
include
Gitlab
::
ShellAdapter
sidekiq_options
queue: :project_mirror
,
retry:
3
sidekiq_options
queue: :project_mirror
,
retry:
3
,
dead:
false
sidekiq_retry_in
{
|
count
|
30
*
count
}
...
...
doc/workflow/repository_mirroring.md
View file @
c54e08cf
...
...
@@ -72,7 +72,7 @@ repository to push to. Hit **Save changes** for the changes to take effect.
Similarly to the pull mirroring, since the upstream repository functions as a
mirror to the repository in GitLab, you are advised not to push commits directly
to the mirrored repository. Instead, all changes will end up in the mirrored repository
whenever commits are
be
pushed to GitLab, or when a
[
forced update
](
#forcing-an-update
)
is initiated.
whenever commits are pushed to GitLab, or when a
[
forced update
](
#forcing-an-update
)
is initiated.
Pushes into GitLab are automatically pushed to the remote mirror 5 minutes after they come in.
...
...
spec/models/remote_mirror_spec.rb
View file @
c54e08cf
...
...
@@ -85,6 +85,38 @@ describe RemoteMirror do
end
end
context
'#sync'
do
let
(
:remote_mirror
)
{
create
(
:project
,
:remote_mirror
).
remote_mirrors
.
first
}
before
do
Timecop
.
freeze
(
Time
.
now
)
end
context
'with remote mirroring enabled'
do
it
'schedules a RepositoryUpdateRemoteMirrorWorker to run within a certain backoff delay'
do
expect
(
RepositoryUpdateRemoteMirrorWorker
).
to
receive
(
:perform_in
).
with
(
RemoteMirror
::
BACKOFF_DELAY
,
remote_mirror
.
id
,
Time
.
now
)
remote_mirror
.
sync
end
end
context
'with remote mirroring disabled'
do
it
'returns nil'
do
remote_mirror
.
update_attributes
(
enabled:
false
)
expect
(
remote_mirror
.
sync
).
to
be_nil
end
end
context
'without project'
do
it
'returns nil'
do
allow_any_instance_of
(
RemoteMirror
).
to
receive
(
:project
).
and_return
(
nil
)
expect
(
remote_mirror
.
sync
).
to
be_nil
end
end
end
context
'#updated_since?'
do
let
(
:remote_mirror
)
{
create
(
:project
,
:remote_mirror
).
remote_mirrors
.
first
}
let
(
:timestamp
)
{
Time
.
now
-
5
.
minutes
}
...
...
spec/services/git_push_service_spec.rb
View file @
c54e08cf
This diff is collapsed.
Click to expand it.
spec/workers/repository_update_remote_mirror_worker_spec.rb
View file @
c54e08cf
...
...
@@ -28,7 +28,7 @@ describe RepositoryUpdateRemoteMirrorWorker do
expect_any_instance_of
(
Projects
::
UpdateRemoteMirrorService
).
to
receive
(
:execute
).
with
(
remote_mirror
).
and_return
(
status: :error
,
message:
error_message
)
expect
do
subject
.
perform
(
remote_mirror
.
id
,
Time
.
now
)
end
.
to
raise_error
(
RepositoryUpdateRemoteMirrorWorker
::
UpdateError
,
'fail!'
)
end
.
to
raise_error
(
RepositoryUpdateRemoteMirrorWorker
::
UpdateError
,
error_message
)
expect
(
remote_mirror
.
reload
.
update_status
).
to
eq
(
'failed'
)
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