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
bc6835c2
Commit
bc6835c2
authored
Mar 17, 2020
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Project#geo_repository_replicated? method
parent
42ea9799
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+6
-0
ee/spec/models/geo/project_registry_spec.rb
ee/spec/models/geo/project_registry_spec.rb
+67
-0
No files found.
ee/app/models/geo/project_registry.rb
View file @
bc6835c2
...
@@ -209,6 +209,12 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
...
@@ -209,6 +209,12 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
where
(
id:
start
..
finish
)
where
(
id:
start
..
finish
)
end
end
def
self
.
repository_replicated_for?
(
project_id
)
return
true
unless
::
Gitlab
::
Geo
.
secondary_with_primary?
where
(
project_id:
project_id
).
where
.
not
(
last_repository_successful_sync_at:
nil
).
exists?
end
# Must be run before fetching the repository to avoid a race condition
# Must be run before fetching the repository to avoid a race condition
#
#
# @param [String] type must be one of the values in TYPES
# @param [String] type must be one of the values in TYPES
...
...
ee/spec/models/geo/project_registry_spec.rb
View file @
bc6835c2
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
require
'spec_helper'
require
'spec_helper'
describe
Geo
::
ProjectRegistry
do
describe
Geo
::
ProjectRegistry
do
include
::
EE
::
GeoHelpers
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
set
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
set
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
...
@@ -210,6 +211,72 @@ describe Geo::ProjectRegistry do
...
@@ -210,6 +211,72 @@ describe Geo::ProjectRegistry do
end
end
end
end
describe
'.repository_replicated_for?'
do
context
'for a non-Geo setup'
do
it
'returns true'
do
expect
(
described_class
.
repository_replicated_for?
(
project
.
id
)).
to
be_truthy
end
end
context
'for a Geo setup'
do
before
do
stub_current_geo_node
(
current_node
)
end
context
'for a Geo Primary'
do
let
(
:current_node
)
{
create
(
:geo_node
,
:primary
)
}
it
'returns true'
do
expect
(
described_class
.
repository_replicated_for?
(
project
.
id
)).
to
be_truthy
end
end
context
'for a Geo secondary'
do
let
(
:current_node
)
{
create
(
:geo_node
)
}
context
'where Primary node is not configured'
do
it
'returns true'
do
expect
(
described_class
.
repository_replicated_for?
(
project
.
id
)).
to
be_truthy
end
end
context
'where Primary node is configured'
do
before
do
create
(
:geo_node
,
:primary
)
end
context
'where project_registry entry does not exist'
do
it
'returns false'
do
project_without_registry
=
create
(
:project
)
expect
(
described_class
.
repository_replicated_for?
(
project_without_registry
.
id
)).
to
be_falsey
end
end
context
'where project_registry entry does exist'
do
context
'where last_repository_successful_sync_at is not set'
do
it
'returns false'
do
project_with_failed_registry
=
create
(
:project
)
create
(
:geo_project_registry
,
:repository_sync_failed
,
project:
project_with_failed_registry
)
expect
(
described_class
.
repository_replicated_for?
(
project_with_failed_registry
.
id
)).
to
be_falsey
end
end
context
'where last_repository_successful_sync_at is set'
do
it
'returns true'
do
project_with_synced_registry
=
create
(
:project
)
create
(
:geo_project_registry
,
:synced
,
project:
project_with_synced_registry
)
expect
(
described_class
.
repository_replicated_for?
(
project_with_synced_registry
.
id
)).
to
be_truthy
end
end
end
end
end
end
end
describe
'#repository_sync_due?'
do
describe
'#repository_sync_due?'
do
where
(
:last_synced_at
,
:resync
,
:retry_at
,
:expected
)
do
where
(
:last_synced_at
,
:resync
,
:retry_at
,
:expected
)
do
now
=
Time
.
now
now
=
Time
.
now
...
...
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