| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper_acceptance' |
| 4 |
|
| 5 |
describe 'redis::sentinel' do |
| 6 |
redis_name = fact('os.family') == 'Debian' ? 'redis-server' : 'redis' |
| 7 |
|
| 8 |
include_examples 'an idempotent resource' do |
| 9 |
let(:manifest) do |
| 10 |
<<-PUPPET |
| 11 |
class { 'redis::sentinel': |
| 12 |
master_name => 'mymaster', |
| 13 |
redis_host => '127.0.0.1', |
| 14 |
failover_timeout => 10000, |
| 15 |
} |
| 16 |
PUPPET |
| 17 |
end |
| 18 |
end |
| 19 |
|
| 20 |
specify { expect(package(redis_name)).to be_installed } |
| 21 |
specify { expect(service(redis_name)).to be_running } |
| 22 |
|
| 23 |
specify 'redis should respond to ping command' do |
| 24 |
expect(command('redis-cli ping')). |
| 25 |
to have_attributes(stdout: %r{PONG}) |
| 26 |
end |
| 27 |
|
| 28 |
specify { expect(service('redis-sentinel')).to be_running } |
| 29 |
|
| 30 |
if redis_name == 'redis-server' |
| 31 |
specify { expect(package('redis-sentinel')).to be_installed } |
| 32 |
else |
| 33 |
specify { expect(package('redis-sentinel')).not_to be_installed } |
| 34 |
end |
| 35 |
|
| 36 |
specify 'redis-sentinel should return correct sentinel master' do |
| 37 |
expect(command('redis-cli -p 26379 SENTINEL masters')). |
| 38 |
to have_attributes(stdout: %r{^mymaster}) |
| 39 |
end |
| 40 |
end |