-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #698 from bastelfreak/zookeeper
Fix zookeeper tests
- Loading branch information
Showing
1 changed file
with
29 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::zookeeper', type: :class do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '5.5.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
on_supported_os(test_on).each do |os, facts| | ||
context "on #{os} " do | ||
let :facts do | ||
facts | ||
end | ||
|
||
context ':ensure => present and :zookeeper_host => \'myhost\'' do | ||
let :params do | ||
{ zookeeper_host: 'myhost', zookeeper_port: '2181' } | ||
end | ||
options = os_specific_options(facts) | ||
|
||
it 'Will create /etc/collectd.d/10-zookeeper.conf' do | ||
is_expected.to contain_file('write_riemann.load').with(ensure: 'present') | ||
is_expected.to contain_file('write_riemann.load').with(path: '/etc/collectd.d/10-zookeeper.conf') | ||
is_expected.to contain_file('write_riemann.load').with(content: %r{Host "myhost"}) | ||
is_expected.to contain_file('write_riemann.load').with(content: %r{Port "2181"}) | ||
end | ||
end | ||
context ":ensure => present and :zookeeper_host => 'myhost'" do | ||
let :params do | ||
{ zookeeper_host: 'myhost', zookeeper_port: '2181' } | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :params do | ||
{ zookeeper_host: ['myhost'], ensure: 'absent' } | ||
end | ||
it "Will create #{options[:plugin_conf_dir]}/10-zookeeper.load" do | ||
is_expected.to contain_file('zookeeper.load').with(ensure: 'present') | ||
is_expected.to contain_file('zookeeper.load').with(path: "#{options[:plugin_conf_dir]}/10-zookeeper.conf") | ||
is_expected.to contain_file('zookeeper.load').with(content: %r{Host "myhost"}) | ||
is_expected.to contain_file('zookeeper.load').with(content: %r{Port "2181"}) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :params do | ||
{ zookeeper_host: 'myhost', ensure: 'absent' } | ||
end | ||
|
||
it 'Will not create ' do | ||
is_expected.to contain_file('zookeeper.load').with(ensure: 'absent', | ||
path: '/etc/collectd.d/10-zookeeper.conf') | ||
it 'Will not create ' do | ||
is_expected.to contain_file('zookeeper.load').with( | ||
ensure: 'absent', | ||
path: "#{options[:plugin_conf_dir]}/10-zookeeper.conf" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |