summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2016-08-18 13:10:16 +0200
committerGabriel Mazetto <brodock@gmail.com>2016-08-18 13:10:16 +0200
commit3c49cb0287e4d1ecc52efa43d66183b5a49a318d (patch)
tree07dde327ad422fbf4000fe1d06a821a29ed87ea0
parent0a24df3371c4af2a2b1e6a61a3048c80cd51536c (diff)
downloadgitlab-shell-3c49cb0287e4d1ecc52efa43d66183b5a49a318d.tar.gz
Added specs for sentinel support
-rw-r--r--spec/fixtures/gitlab_config_redis.yml12
-rw-r--r--spec/gitlab_config_spec.rb14
-rw-r--r--spec/gitlab_net_spec.rb14
3 files changed, 29 insertions, 11 deletions
diff --git a/spec/fixtures/gitlab_config_redis.yml b/spec/fixtures/gitlab_config_redis.yml
new file mode 100644
index 0000000..e07e5df
--- /dev/null
+++ b/spec/fixtures/gitlab_config_redis.yml
@@ -0,0 +1,12 @@
+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
diff --git a/spec/gitlab_config_spec.rb b/spec/gitlab_config_spec.rb
index 6c1af85..b92da65 100644
--- a/spec/gitlab_config_spec.rb
+++ b/spec/gitlab_config_spec.rb
@@ -6,17 +6,8 @@ describe GitlabConfig do
describe :redis do
before do
- config.instance_variable_set(:@config, YAML.load(<<eos
-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
-eos
- ))
+ config_file = File.read('spec/fixtures/gitlab_config_redis.yml')
+ config.instance_variable_set(:@config, YAML.load(config_file))
end
it { config.redis['bin'].should eq('/usr/bin/redis-cli') }
@@ -26,6 +17,7 @@ eos
it { config.redis['namespace'].should eq('my:gitlab') }
it { config.redis['socket'].should eq('/var/run/redis/redis.sock') }
it { config.redis['pass'].should eq('secure') }
+ it { config.redis['sentinels'].should eq([{ 'host' => '127.0.0.1', 'port' => 26380 }]) }
end
describe :gitlab_url do
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index 2bbf98b..2cb97cb 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -306,6 +306,20 @@ describe GitlabNet, vcr: true do
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
let(:socket) { '/tmp/redis.socket' }