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
ea13a8ce
Commit
ea13a8ce
authored
Jan 21, 2022
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve repository_base_sync_service specs
parent
59947b4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
9 deletions
+60
-9
ee/app/services/geo/framework_repository_sync_service.rb
ee/app/services/geo/framework_repository_sync_service.rb
+1
-1
ee/app/services/geo/repository_base_sync_service.rb
ee/app/services/geo/repository_base_sync_service.rb
+16
-8
ee/spec/services/geo/repository_base_sync_service_spec.rb
ee/spec/services/geo/repository_base_sync_service_spec.rb
+43
-0
No files found.
ee/app/services/geo/framework_repository_sync_service.rb
View file @
ea13a8ce
...
...
@@ -117,7 +117,7 @@ module Geo
def
fetch_geo_mirror
(
repository
)
# Fetch the repository, using a JWT header for authentication
repository
.
fetch_as_mirror
(
replicator
.
remote_url
,
forced:
true
,
http_authorization_header:
replicator
.
jwt_authentication_header
)
repository
.
fetch_as_mirror
(
replicator
.
remote_url
,
forced:
true
,
http_authorization_header:
replicator
.
jwt_authentication_header
(
repository
)
)
end
# Use snapshotting for redownloads *only* when enabled.
...
...
ee/app/services/geo/repository_base_sync_service.rb
View file @
ea13a8ce
...
...
@@ -41,6 +41,10 @@ module Geo
LEASE_TIMEOUT
end
def
repository
raise
NotImplementedError
,
'Define a reference to the repository'
end
private
def
fetch_repository
...
...
@@ -57,9 +61,9 @@ module Geo
redownload_repository
@new_repository
=
true
elsif
repository
.
exists?
fetch_geo_mirror
(
repository
)
fetch_geo_mirror
else
clone_geo_mirror
(
repository
)
clone_geo_mirror
repository
.
expire_status_cache
# after_create
# Because we ensure a repository exists by this point, we need to
...
...
@@ -101,16 +105,20 @@ module Geo
end
# Update an existing repository using special credentials
#
@param [Repository] repository
def
fetch_geo_mirror
(
repository
)
#
def
fetch_geo_mirror
# Fetch the repository, using a JWT header for authentication
repository
.
fetch_as_mirror
(
remote_url
,
forced:
true
,
http_authorization_header:
jwt_authentication_header
)
repository
.
fetch_as_mirror
(
remote_url
,
forced:
true
,
http_authorization_header:
jwt_authentication_header
)
end
# Clone a new repository using Geo special credentials
# @param [Repository] repository
def
clone_geo_mirror
(
repository
)
repository
.
clone_as_mirror
(
remote_url
,
http_authorization_header:
jwt_authentication_header
)
#
def
clone_geo_mirror
# Clone the repository, using a JWT header for authentication
repository
.
clone_as_mirror
(
remote_url
,
http_authorization_header:
jwt_authentication_header
)
end
# Build a JWT header for authentication
...
...
ee/spec/services/geo/repository_base_sync_service_spec.rb
View file @
ea13a8ce
...
...
@@ -3,7 +3,16 @@
require
'spec_helper'
RSpec
.
describe
Geo
::
RepositoryBaseSyncService
do
include
::
EE
::
GeoHelpers
let
(
:project
)
{
build
(
'project'
)
}
let
(
:repository
)
{
project
.
repository
}
let_it_be
(
:geo_primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:geo_secondary
)
{
create
(
:geo_node
,
:secondary
)
}
before
do
stub_current_geo_node
(
geo_secondary
)
end
subject
{
described_class
.
new
(
project
)
}
...
...
@@ -15,4 +24,38 @@ RSpec.describe Geo::RepositoryBaseSyncService do
expect
(
subject
.
lease_key
).
to
eq
(
'geo_sync_service:wiki:999'
)
end
end
describe
'#lease_timeout'
do
it
'returns a lease timeout value'
do
expect
(
subject
.
lease_timeout
).
to
eq
(
8
.
hours
)
end
end
describe
'#repository'
do
it
'raises a NotImplementedError'
do
expect
{
subject
.
repository
}.
to
raise_error
(
NotImplementedError
)
end
end
context
'with a repository defined'
do
before
do
allow
(
subject
).
to
receive
(
:repository
)
{
repository
}
end
describe
'#fetch_geo_mirror'
do
it
'delegates to repository#fetch_as_mirror'
do
expect
(
repository
).
to
receive
(
:fetch_as_mirror
)
subject
.
send
(
:fetch_geo_mirror
)
end
end
describe
'#clone_geo_mirror'
do
it
'delegates to repository#clone_as_mirror'
do
expect
(
repository
).
to
receive
(
:clone_as_mirror
)
subject
.
send
(
:clone_geo_mirror
)
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