-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 17 additions & 15 deletions
32
spec/acceptance/suites/default/redis_adminstration_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
RSpec::Matchers.define_negated_matcher :execute_without_warning, :execute_with_warning | ||
|
||
# systcl settings are untestable in docker | ||
describe 'redis::administration', unless: default['hypervisor'] =~ %r{docker} do | ||
it 'runs successfully' do | ||
pp = <<-EOS | ||
include redis | ||
include redis::administration | ||
EOS | ||
def execute_with_warning | ||
have_attributes(stderr: %r{WARNING}) | ||
end | ||
|
||
# Apply twice to ensure no errors the second time. | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
include_examples 'an idempotent resource' do | ||
let(:manifest) { 'include redis, redis::administration' } | ||
end | ||
|
||
describe file('/proc/sys/vm/overcommit_memory') do | ||
its(:content) { is_expected.to eq("1\n") } | ||
specify do | ||
expect(file('/proc/sys/vm/overcommit_memory')). | ||
to have_attributes(content: "1\n") | ||
end | ||
|
||
describe file('/proc/sys/net/core/somaxconn') do | ||
its(:content) { is_expected.to eq("65535\n") } | ||
specify do | ||
expect(file('/proc/sys/net/core/somaxconn')). | ||
to have_attributes(content: "65535\n") | ||
end | ||
|
||
describe command('timeout 1s redis-server --port 7777 --loglevel verbose') do | ||
its(:stderr) { is_expected.not_to match(%r{WARNING}) } | ||
its(:exit_status) { is_expected.to eq(124) } | ||
specify do | ||
expect(command('timeout 1s redis-server --port 7777 --loglevel verbose')). | ||
to execute_without_warning. | ||
and have_attributes(exit_status: 124) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 25 additions & 42 deletions
67
spec/acceptance/suites/default/redis_sentinel_one_node_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,37 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'redis::sentinel' do | ||
redis_name = case fact('osfamily') | ||
when 'Debian' | ||
'redis-server' | ||
else | ||
'redis' | ||
end | ||
|
||
it 'runs successfully' do | ||
pp = <<-EOS | ||
class { 'redis::sentinel': | ||
master_name => 'mymaster', | ||
redis_host => '127.0.0.1', | ||
failover_timeout => 10000, | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
|
||
describe package(redis_name) do | ||
it { is_expected.to be_installed } | ||
end | ||
|
||
describe service(redis_name) do | ||
it { is_expected.to be_running } | ||
redis_name = fact('osfamily') == 'Debian' ? 'redis-server' : 'redis' | ||
|
||
include_examples 'an idempotent resource' do | ||
let(:manifest) do | ||
<<-PUPPET | ||
class { 'redis::sentinel': | ||
master_name => 'mymaster', | ||
redis_host => '127.0.0.1', | ||
failover_timeout => 10000, | ||
} | ||
PUPPET | ||
end | ||
end | ||
|
||
describe service('redis-sentinel') do | ||
it { is_expected.to be_running } | ||
end | ||
specify { expect(package(redis_name)).to be_installed } | ||
specify { expect(service(redis_name)).to be_running } | ||
|
||
case fact('osfamily') | ||
when 'Debian' | ||
describe package('redis-sentinel') do | ||
it { is_expected.to be_installed } | ||
end | ||
specify 'redis should respond to ping command' do | ||
expect(command('redis-cli ping')). | ||
to have_attributes(stdout: %r{PONG}) | ||
end | ||
|
||
context 'redis should respond to ping command' do | ||
describe command('redis-cli ping') do | ||
its(:stdout) { is_expected.to match %r{PONG} } | ||
end | ||
specify { expect(service('redis-sentinel')).to be_running } | ||
if redis_name == 'redis-server' | ||
specify { expect(package('redis-sentinel')).to be_installed } | ||
else | ||
specify { expect(package('redis-sentinel')).not_to be_installed } | ||
end | ||
|
||
context 'redis-sentinel should return correct sentinel master' do | ||
describe command('redis-cli -p 26379 SENTINEL masters') do | ||
its(:stdout) { is_expected.to match %r{^mymaster} } | ||
end | ||
specify 'redis-sentinel should return correct sentinel master' do | ||
expect(command('redis-cli -p 26379 SENTINEL masters')). | ||
to have_attributes(stdout: %r{^mymaster}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.