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
c808f8c5
Commit
c808f8c5
authored
Jul 06, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `primary?` and `secondary?` instead of the *_role_enabled?
parent
3c562211
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
config/initializers/geo.rb
config/initializers/geo.rb
+1
-2
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+2
-2
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+10
-10
No files found.
config/initializers/geo.rb
View file @
c808f8c5
...
...
@@ -5,8 +5,7 @@ if File.exist?(Rails.root.join('config/database_geo.yml'))
end
begin
# Avoid using the database if this is run in a Rake task
if
Gitlab
::
Geo
.
primary_role_enabled?
if
Gitlab
::
Geo
.
primary?
Gitlab
::
Geo
.
current_node
&
.
update_clone_url!
end
rescue
=>
e
...
...
lib/gitlab/geo.rb
View file @
c808f8c5
...
...
@@ -113,9 +113,9 @@ module Gitlab
end
def
self
.
configure_cron_jobs!
if
self
.
primary
_role_enabled
?
if
self
.
primary?
self
.
configure_primary_jobs!
elsif
self
.
secondary
_role_enabled
?
elsif
self
.
secondary?
self
.
configure_secondary_jobs!
else
self
.
enable_all_cron_jobs!
...
...
spec/lib/gitlab/geo_spec.rb
View file @
c808f8c5
...
...
@@ -142,8 +142,8 @@ describe Gitlab::Geo, lib: true do
end
it
'activates cron jobs for primary'
do
allow
(
described_class
).
to
receive
(
:primary
_role_enabled
?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:secondary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:primary?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:secondary?
).
and_return
(
false
)
described_class
.
configure_cron_jobs!
...
...
@@ -154,8 +154,8 @@ describe Gitlab::Geo, lib: true do
end
it
'activates cron jobs for secondary'
do
allow
(
described_class
).
to
receive
(
:primary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary
_role_enabled
?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:primary?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary?
).
and_return
(
true
)
described_class
.
configure_cron_jobs!
...
...
@@ -166,8 +166,8 @@ describe Gitlab::Geo, lib: true do
end
it
'deactivates all jobs when Geo is not active'
do
allow
(
described_class
).
to
receive
(
:primary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:primary?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary?
).
and_return
(
false
)
described_class
.
configure_cron_jobs!
...
...
@@ -178,14 +178,14 @@ describe Gitlab::Geo, lib: true do
end
it
'reactivates cron jobs when node turns off Geo'
do
allow
(
described_class
).
to
receive
(
:primary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary
_role_enabled
?
).
and_return
(
true
)
allow
(
described_class
).
to
receive
(
:primary?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary?
).
and_return
(
true
)
described_class
.
configure_cron_jobs!
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
'ldap_test'
)).
not_to
be_enabled
allow
(
described_class
).
to
receive
(
:primary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary
_role_enabled
?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:primary?
).
and_return
(
false
)
allow
(
described_class
).
to
receive
(
:secondary?
).
and_return
(
false
)
described_class
.
configure_cron_jobs!
expect
(
Sidekiq
::
Cron
::
Job
.
find
(
'ldap_test'
)).
to
be_enabled
...
...
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