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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
ed0a7c25
Commit
ed0a7c25
authored
Aug 06, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactor in Redis class and improved specs
parent
ce41b5c7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
9 deletions
+16
-9
lib/gitlab/redis.rb
lib/gitlab/redis.rb
+5
-1
spec/fixtures/config/redis_new_format_host.yml
spec/fixtures/config/redis_new_format_host.yml
+3
-3
spec/fixtures/config/redis_old_format_socket.yml
spec/fixtures/config/redis_old_format_socket.yml
+3
-3
spec/lib/gitlab/redis_spec.rb
spec/lib/gitlab/redis_spec.rb
+5
-2
No files found.
lib/gitlab/redis.rb
View file @
ed0a7c25
...
...
@@ -19,7 +19,7 @@ module Gitlab
class
<<
self
def
params
PARAMS_MUTEX
.
synchronize
{
new
.
params
}
@params
||
PARAMS_MUTEX
.
synchronize
{
@params
=
new
.
params
}
end
# @deprecated Use .params instead to get sentinel support
...
...
@@ -35,6 +35,10 @@ module Gitlab
end
@pool
.
with
{
|
redis
|
yield
redis
}
end
def
reset_params!
@params
=
nil
end
end
def
initialize
(
rails_env
=
nil
)
...
...
spec/fixtures/config/redis_new_format_host.yml
View file @
ed0a7c25
# redis://[:password@]host[:port][/db-number][?option=value]
# more details: http://www.iana.org/assignments/uri-schemes/prov/redis
development
:
url
:
redis://:mypassword@localhost:6379/99
url
:
redis://:my
new
password@localhost:6379/99
sentinels
:
-
host
:
localhost
...
...
@@ -10,7 +10,7 @@ development:
host
:
slave2
port
:
26381
# point to sentinel, not to redis port
test
:
url
:
redis://:mypassword@localhost:6379/99
url
:
redis://:my
new
password@localhost:6379/99
sentinels
:
-
host
:
localhost
...
...
@@ -19,7 +19,7 @@ test:
host
:
slave2
port
:
26381
# point to sentinel, not to redis port
production
:
url
:
redis://:mypassword@localhost:6379/99
url
:
redis://:my
new
password@localhost:6379/99
sentinels
:
-
host
:
slave1
...
...
spec/fixtures/config/redis_old_format_socket.yml
View file @
ed0a7c25
development
:
unix:/path/to/redis.sock
test
:
unix:/path/to/redis.sock
production
:
unix:/path/to/redis.sock
development
:
unix:/path/to/
old/
redis.sock
test
:
unix:/path/to/
old/
redis.sock
production
:
unix:/path/to/
old/
redis.sock
spec/lib/gitlab/redis_spec.rb
View file @
ed0a7c25
...
...
@@ -3,6 +3,9 @@ require 'spec_helper'
describe
Gitlab
::
Redis
do
let
(
:redis_config
)
{
Rails
.
root
.
join
(
'config'
,
'resque.yml'
).
to_s
}
before
(
:each
)
{
described_class
.
reset_params!
}
after
(
:each
)
{
described_class
.
reset_params!
}
describe
'.params'
do
subject
{
described_class
.
params
}
...
...
@@ -14,7 +17,7 @@ describe Gitlab::Redis do
it
'returns path key instead'
do
expect_any_instance_of
(
described_class
).
to
receive
(
:config_file
)
{
config_old
}
is_expected
.
to
include
(
path:
'/path/to/redis.sock'
)
is_expected
.
to
include
(
path:
'/path/to/
old/
redis.sock'
)
is_expected
.
not_to
have_key
(
:url
)
end
end
...
...
@@ -46,7 +49,7 @@ describe Gitlab::Redis do
it
'returns hash with host, port, db, and password'
do
expect_any_instance_of
(
described_class
).
to
receive
(
:config_file
)
{
config_new
}
is_expected
.
to
include
(
host:
'localhost'
,
password:
'mypassword'
,
port:
6379
,
db:
99
)
is_expected
.
to
include
(
host:
'localhost'
,
password:
'my
new
password'
,
port:
6379
,
db:
99
)
is_expected
.
not_to
have_key
(
:url
)
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