-
-
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.
migrate collectd_plugin_swap tests to rspec-puppet-facts
- Loading branch information
1 parent
5bd10fc
commit bfd81f1
Showing
1 changed file
with
68 additions
and
88 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,105 +1,85 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::swap', type: :class do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '4.8.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
on_supported_os.each do |os, facts| | ||
context "on #{os} " do | ||
let :facts do | ||
facts | ||
end | ||
|
||
context ':ensure => present, default params' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '4.8.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
options = os_specific_options(facts) | ||
context ':ensure => present, default params' do | ||
let :facts do | ||
facts.merge(collectd_version: '4.8.0') | ||
end | ||
|
||
it 'Will create /etc/collectd.d/10-swap.conf' do | ||
is_expected.to contain_file('swap.load'). | ||
with(ensure: 'present', | ||
path: '/etc/collectd.d/10-swap.conf', | ||
content: %r{# Generated by Puppet\nLoadPlugin swap\n\n<Plugin swap>\n ReportByDevice false\n</Plugin>\n}) | ||
end | ||
end | ||
it 'Will create /etc/collectd.d/10-swap.conf' do | ||
is_expected.to contain_file('swap.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-swap.conf", | ||
content: %r{# Generated by Puppet\nLoadPlugin swap\n\n<Plugin swap>\n ReportByDevice false\n</Plugin>\n} | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => present, specific params, collectd version 5.0' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '5.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
context ':ensure => present, specific params, collectd version 5.0' do | ||
let :facts do | ||
facts.merge(collectd_version: '5.0') | ||
end | ||
|
||
it 'Will create /etc/collectd.d/10-swap.conf for collectd < 5.2' do | ||
is_expected.to contain_file('swap.load'). | ||
with(ensure: 'present', | ||
path: '/etc/collectd.d/10-swap.conf', | ||
content: "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n</Plugin>\n\n") | ||
end | ||
end | ||
it "Will create #{options[:plugin_conf_dir]}/10-swap.conf for collectd < 5.2" do | ||
is_expected.to contain_file('swap.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-swap.conf", | ||
content: "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n</Plugin>\n\n" | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => present, specific params, collectd version 5.2.0' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '5.2.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
context ':ensure => present, specific params, collectd version 5.2.0' do | ||
let :facts do | ||
facts.merge(collectd_version: '5.2.0') | ||
end | ||
|
||
it 'Will create /etc/collectd.d/10-swap.conf for collectd >= 5.2' do | ||
is_expected.to contain_file('swap.load'). | ||
with(ensure: 'present', | ||
path: '/etc/collectd.d/10-swap.conf', | ||
content: "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n ReportBytes true\n</Plugin>\n\n") | ||
end | ||
end | ||
it 'Will create /etc/collectd.d/10-swap.conf for collectd >= 5.2' do | ||
is_expected.to contain_file('swap.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-swap.conf", | ||
content: "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n ReportBytes true\n</Plugin>\n\n" | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => present, specific params, collectd version 5.5.0' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '5.5.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
context ':ensure => present, specific params, collectd version 5.5.0' do | ||
let :facts do | ||
facts.merge(collectd_version: '5.5.0') | ||
end | ||
|
||
it 'Will create /etc/collectd.d/10-swap.conf for collectd >= 5.5' do | ||
is_expected.to contain_file('swap.load'). | ||
with(ensure: 'present', | ||
path: '/etc/collectd.d/10-swap.conf', | ||
content: "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n ReportBytes true\n ValuesAbsolute true\n ValuesPercentage false\n</Plugin>\n\n") | ||
end | ||
end | ||
it 'Will create /etc/collectd.d/10-swap.conf for collectd >= 5.5' do | ||
is_expected.to contain_file('swap.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-swap.conf", | ||
content: "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n ReportBytes true\n ValuesAbsolute true\n ValuesPercentage false\n</Plugin>\n\n" | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '4.8.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
context ':ensure => absent' do | ||
let :facts do | ||
facts.merge(collectd_version: '4.8.0') | ||
end | ||
|
||
let :params do | ||
{ ensure: 'absent' } | ||
end | ||
let :params do | ||
{ ensure: 'absent' } | ||
end | ||
|
||
it 'Will not create /etc/collectd.d/10-swap.conf' do | ||
is_expected.to contain_file('swap.load'). | ||
with(ensure: 'absent', | ||
path: '/etc/collectd.d/10-swap.conf') | ||
it "Will not create #{options[:plugin_conf_dir]}/10-swap.conf" do | ||
is_expected.to contain_file('swap.load').with( | ||
ensure: 'absent', | ||
path: "#{options[:plugin_conf_dir]}/10-swap.conf" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |