Commit 3c49cb02 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Added specs for sentinel support

parent 0a24df33
redis:
bin: /usr/bin/redis-cli
host: 127.0.1.1
port: 6378
pass: secure
database: 1
socket: /var/run/redis/redis.sock
namespace: my:gitlab
sentinels:
-
host: 127.0.0.1
port: 26380
...@@ -6,17 +6,8 @@ describe GitlabConfig do ...@@ -6,17 +6,8 @@ describe GitlabConfig do
describe :redis do describe :redis do
before do before do
config.instance_variable_set(:@config, YAML.load(<<eos config_file = File.read('spec/fixtures/gitlab_config_redis.yml')
redis: config.instance_variable_set(:@config, YAML.load(config_file))
bin: /usr/bin/redis-cli
host: 127.0.1.1
port: 6378
pass: secure
database: 1
socket: /var/run/redis/redis.sock
namespace: my:gitlab
eos
))
end end
it { config.redis['bin'].should eq('/usr/bin/redis-cli') } it { config.redis['bin'].should eq('/usr/bin/redis-cli') }
...@@ -26,6 +17,7 @@ eos ...@@ -26,6 +17,7 @@ eos
it { config.redis['namespace'].should eq('my:gitlab') } it { config.redis['namespace'].should eq('my:gitlab') }
it { config.redis['socket'].should eq('/var/run/redis/redis.sock') } it { config.redis['socket'].should eq('/var/run/redis/redis.sock') }
it { config.redis['pass'].should eq('secure') } it { config.redis['pass'].should eq('secure') }
it { config.redis['sentinels'].should eq([{ 'host' => '127.0.0.1', 'port' => 26380 }]) }
end end
describe :gitlab_url do describe :gitlab_url do
......
...@@ -306,6 +306,20 @@ describe GitlabNet, vcr: true do ...@@ -306,6 +306,20 @@ describe GitlabNet, vcr: true do
end end
end end
context "with sentinels" do
it 'users the specified sentinels' do
allow(gitlab_net).to receive(:config).and_return(config)
allow(config).to receive(:redis).and_return({ 'host' => 'localhost', 'port' => 1123,
'sentinels' => [{'host' => '127.0.0.1', 'port' => 26380}] })
expect_any_instance_of(Redis).to receive(:initialize).with({ host: 'localhost',
port: 1123,
db: 0,
sentinels: [{host: '127.0.0.1', port: 26380}] }).and_call_original
gitlab_net.redis_client
end
end
context "with redis socket" do context "with redis socket" do
let(:socket) { '/tmp/redis.socket' } let(:socket) { '/tmp/redis.socket' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment