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
Jérome Perrin
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
Hide 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
...
@@ -19,7 +19,7 @@ module Gitlab
class
<<
self
class
<<
self
def
params
def
params
PARAMS_MUTEX
.
synchronize
{
new
.
params
}
@params
||
PARAMS_MUTEX
.
synchronize
{
@params
=
new
.
params
}
end
end
# @deprecated Use .params instead to get sentinel support
# @deprecated Use .params instead to get sentinel support
...
@@ -35,6 +35,10 @@ module Gitlab
...
@@ -35,6 +35,10 @@ module Gitlab
end
end
@pool
.
with
{
|
redis
|
yield
redis
}
@pool
.
with
{
|
redis
|
yield
redis
}
end
end
def
reset_params!
@params
=
nil
end
end
end
def
initialize
(
rails_env
=
nil
)
def
initialize
(
rails_env
=
nil
)
...
...
spec/fixtures/config/redis_new_format_host.yml
View file @
ed0a7c25
# redis://[:password@]host[:port][/db-number][?option=value]
# redis://[:password@]host[:port][/db-number][?option=value]
# more details: http://www.iana.org/assignments/uri-schemes/prov/redis
# more details: http://www.iana.org/assignments/uri-schemes/prov/redis
development
:
development
:
url
:
redis://:mypassword@localhost:6379/99
url
:
redis://:my
new
password@localhost:6379/99
sentinels
:
sentinels
:
-
-
host
:
localhost
host
:
localhost
...
@@ -10,7 +10,7 @@ development:
...
@@ -10,7 +10,7 @@ development:
host
:
slave2
host
:
slave2
port
:
26381
# point to sentinel, not to redis port
port
:
26381
# point to sentinel, not to redis port
test
:
test
:
url
:
redis://:mypassword@localhost:6379/99
url
:
redis://:my
new
password@localhost:6379/99
sentinels
:
sentinels
:
-
-
host
:
localhost
host
:
localhost
...
@@ -19,7 +19,7 @@ test:
...
@@ -19,7 +19,7 @@ test:
host
:
slave2
host
:
slave2
port
:
26381
# point to sentinel, not to redis port
port
:
26381
# point to sentinel, not to redis port
production
:
production
:
url
:
redis://:mypassword@localhost:6379/99
url
:
redis://:my
new
password@localhost:6379/99
sentinels
:
sentinels
:
-
-
host
:
slave1
host
:
slave1
...
...
spec/fixtures/config/redis_old_format_socket.yml
View file @
ed0a7c25
development
:
unix:/path/to/redis.sock
development
:
unix:/path/to/
old/
redis.sock
test
:
unix:/path/to/redis.sock
test
:
unix:/path/to/
old/
redis.sock
production
:
unix:/path/to/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'
...
@@ -3,6 +3,9 @@ require 'spec_helper'
describe
Gitlab
::
Redis
do
describe
Gitlab
::
Redis
do
let
(
:redis_config
)
{
Rails
.
root
.
join
(
'config'
,
'resque.yml'
).
to_s
}
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
describe
'.params'
do
subject
{
described_class
.
params
}
subject
{
described_class
.
params
}
...
@@ -14,7 +17,7 @@ describe Gitlab::Redis do
...
@@ -14,7 +17,7 @@ describe Gitlab::Redis do
it
'returns path key instead'
do
it
'returns path key instead'
do
expect_any_instance_of
(
described_class
).
to
receive
(
:config_file
)
{
config_old
}
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
)
is_expected
.
not_to
have_key
(
:url
)
end
end
end
end
...
@@ -46,7 +49,7 @@ describe Gitlab::Redis do
...
@@ -46,7 +49,7 @@ describe Gitlab::Redis do
it
'returns hash with host, port, db, and password'
do
it
'returns hash with host, port, db, and password'
do
expect_any_instance_of
(
described_class
).
to
receive
(
:config_file
)
{
config_new
}
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
)
is_expected
.
not_to
have_key
(
:url
)
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