From 42488b04b47ec3fd87f1d45ec3fa90b588545ca1 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 2 Jul 2013 19:22:35 +0200 Subject: Add basic testing infrastructure --- spec/classes/munin_client_spec.rb | 14 +++++++++ spec/classes/munin_host_spec.rb | 14 +++++++++ spec/classes/munin_plugins_interfaces_spec.rb | 44 +++++++++++++++++++++++++++ spec/spec.opts | 1 + spec/spec_helper.rb | 9 ++++++ 5 files changed, 82 insertions(+) create mode 100644 spec/classes/munin_client_spec.rb create mode 100644 spec/classes/munin_host_spec.rb create mode 100644 spec/classes/munin_plugins_interfaces_spec.rb create mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb (limited to 'spec') diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb new file mode 100644 index 0000000..5438b20 --- /dev/null +++ b/spec/classes/munin_client_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'munin::client' do + let :facts do + { + :operatingsystem => 'CentOS', + :interfaces => 'lo,eth0', + } + end + + it 'should compile' do + should include_class('munin::client') + end +end diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb new file mode 100644 index 0000000..2216cc5 --- /dev/null +++ b/spec/classes/munin_host_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'munin::host' do + let :facts do + { + :operatingsystem => 'CentOS', + :interfaces => 'lo,eth0', + } + end + + it 'should compile' do + should include_class('munin::host') + end +end diff --git a/spec/classes/munin_plugins_interfaces_spec.rb b/spec/classes/munin_plugins_interfaces_spec.rb new file mode 100644 index 0000000..95aa785 --- /dev/null +++ b/spec/classes/munin_plugins_interfaces_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe 'munin::plugins::interfaces' do + context 'on CentOS' do + let :facts do + { + :operatingsystem => 'CentOS', + :interfaces => 'lo,eth0,sit0', + } + end + + it 'should compile' do + should include_class('munin::plugins::interfaces') + end + + it 'should create plugins for each interface' do + # lo + should contain_munin__plugin('if_lo').with_ensure('if_') + should contain_munin__plugin('if_err_lo').with_ensure('if_err_') + + # eth0 + should contain_munin__plugin('if_eth0').with_ensure('if_') + should contain_munin__plugin('if_err_eth0').with_ensure('if_err_') + end + + it 'should not create plugins for sit0' do + should_not contain_munin__plugin('if_sit0') + should_not contain_munin__plugin('if_err_sit0') + end + end + + context 'on OpenBSD' do + let :facts do + { + :operatingsystem => 'OpenBSD', + :interfaces => 'eth0', + } + end + + it 'should use if_errcoll_ instead of if_err_' do + should contain_munin__plugin('if_errcoll_eth0').with_ensure('if_errcoll_') + end + end +end diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..d1bd681 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1 @@ +--format documentation --colour --backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..cffe80c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,9 @@ +require 'puppetlabs_spec_helper/module_spec_helper' + +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) + +RSpec.configure do |c| + c.module_path = File.join(fixture_path, 'modules') + c.manifest_dir = File.join(fixture_path, 'manifests') + c.mock_with :mocha +end -- cgit v1.2.3 From 9c2c7140876bbe20a9871543ba28b7522acdb213 Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Sat, 12 Oct 2013 16:45:19 +0200 Subject: testing infrastructure --- spec/spec_helper_system.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/spec_helper_system.rb (limited to 'spec') diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb new file mode 100644 index 0000000..462d2a1 --- /dev/null +++ b/spec/spec_helper_system.rb @@ -0,0 +1,26 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' +require 'rspec-system-serverspec/helpers' +include Serverspec::Helper::RSpecSystem +include Serverspec::Helper::DetectOS +include RSpecSystemPuppet::Helpers + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Enable colour + c.tty = true + + c.include RSpecSystemPuppet::Helpers + + # This is where we 'setup' the nodes before running our tests + c.before :suite do + # Install puppet + puppet_install + + # Install modules and dependencies + puppet_module_install(:source => proj_root, :module_name => 'munin') + shell('puppet module install puppetlabs-stdlib') + end +end -- cgit v1.2.3 From b729e3903ded13e07501fc9b55766d21de206ae8 Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Sat, 12 Oct 2013 18:29:11 +0200 Subject: basic munin::client specs --- spec/classes/munin_client_spec.rb | 47 ++++++++++++++++++++++++++++++++++----- spec/spec.opts | 1 - spec/spec_helper_system.rb | 1 + 3 files changed, 42 insertions(+), 7 deletions(-) delete mode 100644 spec/spec.opts (limited to 'spec') diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb index 5438b20..a5539b3 100644 --- a/spec/classes/munin_client_spec.rb +++ b/spec/classes/munin_client_spec.rb @@ -1,14 +1,49 @@ require 'spec_helper' describe 'munin::client' do - let :facts do - { - :operatingsystem => 'CentOS', + shared_examples 'debian' do |os, codename| + let(:facts) {{ + :operatingsystem => os, + :osfamily => 'Debian', + :lsbdistcodename => codename, + }} + it { should contain_package('munin-node') } + it { should contain_package('iproute') } + it { should contain_file('/etc/munin/munin-node.conf') } + end + + shared_examples 'redhat' do |os, codename| + let(:facts) {{ + :operatingsystem => os, + :osfamily => 'RedHat', + :lsbdistcodename => codename, :interfaces => 'lo,eth0', - } + }} + it { should contain_package('munin-node') } + it { should contain_file('/etc/munin/munin-node.conf') } + end + + context 'on debian-like system' do + it_behaves_like 'debian', 'Debian', 'squeeze' + it_behaves_like 'debian', 'Debian', 'wheezy' + it_behaves_like 'debian', 'Ubuntu', 'precise' end - it 'should compile' do - should include_class('munin::client') + context 'on redhat-like system' do + it_behaves_like 'redhat', 'CentOS', '6' + # not supported yet + # it_behaves_like 'redhat', 'RedHat', '6' end + + context 'gentoo' do + let(:facts) {{ + :operatingsystem => 'Gentoo', + :osfamily => 'Gentoo', + :lsbdistcodename => '', + :interfaces => 'lo,eth0', + }} + it { should contain_package('munin-node') } + it { should contain_file('/etc/munin/munin-node.conf') } + end + end diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index d1bd681..0000000 --- a/spec/spec.opts +++ /dev/null @@ -1 +0,0 @@ ---format documentation --colour --backtrace diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 462d2a1..9adfea9 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -22,5 +22,6 @@ RSpec.configure do |c| # Install modules and dependencies puppet_module_install(:source => proj_root, :module_name => 'munin') shell('puppet module install puppetlabs-stdlib') + shell('puppet module install puppetlabs-concat') end end -- cgit v1.2.3 From 342ea7aa15a54c33ec4a12cf10b7b1a0c9811dba Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Sun, 13 Oct 2013 18:14:45 +0200 Subject: extended tests, first group should pass --- spec/classes/munin_client_spec.rb | 14 ++++++++------ spec/classes/munin_host_spec.rb | 23 +++++++++++++++-------- spec/spec_helper.rb | 6 +++++- 3 files changed, 28 insertions(+), 15 deletions(-) (limited to 'spec') diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb index a5539b3..ebf8d73 100644 --- a/spec/classes/munin_client_spec.rb +++ b/spec/classes/munin_client_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'munin::client' do - shared_examples 'debian' do |os, codename| + shared_examples 'debian-client' do |os, codename| let(:facts) {{ :operatingsystem => os, :osfamily => 'Debian', @@ -10,9 +10,10 @@ describe 'munin::client' do it { should contain_package('munin-node') } it { should contain_package('iproute') } it { should contain_file('/etc/munin/munin-node.conf') } + it { should include_class('munin::client::debian') } end - shared_examples 'redhat' do |os, codename| + shared_examples 'redhat-client' do |os, codename| let(:facts) {{ :operatingsystem => os, :osfamily => 'RedHat', @@ -24,13 +25,13 @@ describe 'munin::client' do end context 'on debian-like system' do - it_behaves_like 'debian', 'Debian', 'squeeze' - it_behaves_like 'debian', 'Debian', 'wheezy' - it_behaves_like 'debian', 'Ubuntu', 'precise' + it_behaves_like 'debian-client', 'Debian', 'squeeze' + it_behaves_like 'debian-client', 'Debian', 'wheezy' + it_behaves_like 'debian-client', 'Ubuntu', 'precise' end context 'on redhat-like system' do - it_behaves_like 'redhat', 'CentOS', '6' + it_behaves_like 'redhat-client', 'CentOS', '6' # not supported yet # it_behaves_like 'redhat', 'RedHat', '6' end @@ -44,6 +45,7 @@ describe 'munin::client' do }} it { should contain_package('munin-node') } it { should contain_file('/etc/munin/munin-node.conf') } + it { should include_class('munin::client::gentoo') } end end diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb index 2216cc5..ccfcee6 100644 --- a/spec/classes/munin_host_spec.rb +++ b/spec/classes/munin_host_spec.rb @@ -1,14 +1,21 @@ require 'spec_helper' describe 'munin::host' do - let :facts do - { - :operatingsystem => 'CentOS', - :interfaces => 'lo,eth0', - } + shared_examples 'debian-host' do |os, codename| + let(:facts) {{ + :operatingsystem => os, + :osfamily => 'Debian', + :lsbdistcodename => codename, + :concat_basedir => '/var/lib/puppet/concat', + }} + it { should contain_package('munin') } + it { should contain_file('/etc/munin/munin.conf') } end - it 'should compile' do - should include_class('munin::host') - end +# context 'on debian-like system' do +# it_behaves_like 'debian-host', 'Debian', 'squeeze' +# it_behaves_like 'debian', 'Debian', 'wheezy' +# it_behaves_like 'debian', 'Ubuntu', 'precise' +# end + end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cffe80c..7269ae5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,13 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet' + fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) RSpec.configure do |c| c.module_path = File.join(fixture_path, 'modules') c.manifest_dir = File.join(fixture_path, 'manifests') - c.mock_with :mocha end + +Puppet::Util::Log.level = :warning +Puppet::Util::Log.newdestination(:console) -- cgit v1.2.3 From dcea01c89c802c4055e2e99a4ed17576a4c5581b Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Sun, 13 Oct 2013 19:00:48 +0200 Subject: linking current directory to fixtures --- spec/spec_helper.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'spec') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7269ae5..70ab1fb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,5 @@ require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet' - fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) RSpec.configure do |c| -- cgit v1.2.3 From 7be20b4d90918dce2404d5957fc6a2b77e082caf Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Sun, 13 Oct 2013 20:30:33 +0200 Subject: munin host specs --- spec/classes/munin_client_spec.rb | 1 - spec/classes/munin_host_spec.rb | 26 +++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb index ebf8d73..9a92cef 100644 --- a/spec/classes/munin_client_spec.rb +++ b/spec/classes/munin_client_spec.rb @@ -18,7 +18,6 @@ describe 'munin::client' do :operatingsystem => os, :osfamily => 'RedHat', :lsbdistcodename => codename, - :interfaces => 'lo,eth0', }} it { should contain_package('munin-node') } it { should contain_file('/etc/munin/munin-node.conf') } diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb index ccfcee6..461ced5 100644 --- a/spec/classes/munin_host_spec.rb +++ b/spec/classes/munin_host_spec.rb @@ -10,12 +10,28 @@ describe 'munin::host' do }} it { should contain_package('munin') } it { should contain_file('/etc/munin/munin.conf') } + it { should include_class('munin::host') } end -# context 'on debian-like system' do -# it_behaves_like 'debian-host', 'Debian', 'squeeze' -# it_behaves_like 'debian', 'Debian', 'wheezy' -# it_behaves_like 'debian', 'Ubuntu', 'precise' -# end + shared_examples 'redhat-host' do |os, codename| + let(:facts) {{ + :operatingsystem => os, + :osfamily => 'RedHat', + :lsbdistcodename => codename, + :concat_basedir => '/var/lib/puppet/concat', + }} + it { should contain_package('munin') } + it { should contain_file('/etc/munin/munin.conf') } + it { should include_class('munin::host') } + end + context 'on debian-like system' do + it_behaves_like 'debian-host', 'Debian', 'squeeze' + it_behaves_like 'debian-host', 'Debian', 'wheezy' + it_behaves_like 'debian-host', 'Ubuntu', 'precise' + end + + context 'on redhat-like system' do + it_behaves_like 'redhat-host', 'CentOS', '6' + end end -- cgit v1.2.3 From 3064a5d5a6251f84cf4d115be1711266faf7ed13 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 3 Nov 2013 18:21:57 +0100 Subject: fix #26 - do not manage files of a plugin if it should be absent The directories are recursively managed and will purge these files anyway and trigger a proper restart. Like that we can safe a few resources in our catalog. --- spec/defines/munin_plugin_spec.rb | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/defines/munin_plugin_spec.rb (limited to 'spec') diff --git a/spec/defines/munin_plugin_spec.rb b/spec/defines/munin_plugin_spec.rb new file mode 100644 index 0000000..3d7e9e3 --- /dev/null +++ b/spec/defines/munin_plugin_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'munin::plugin' do + let(:title) { 'users' } + let(:facts) do + { :operatingsystem => 'CentOS' } + end + context 'present' do + it { should contain_file('/etc/munin/plugins/users').with( + :ensure => 'link', + :target => '/usr/share/munin/plugins/users' + ) } + it { should_not contain_file('/etc/munin/plugin-conf.d/users.conf') } + end + + context 'present and config' do + let(:params) do + { :config => 'env.user root' } + end + it { should contain_file('/etc/munin/plugins/users').with( + :ensure => 'link', + :target => '/usr/share/munin/plugins/users', + :notify => 'Service[munin-node]' + ) } + it { should contain_file('/etc/munin/plugin-conf.d/users.conf').with( + :content => "[users]\nenv.user root\n", + :owner => 'root', + :group => 0, + :mode => '0640' + ) } + end + + context 'absent' do + let(:params) do + { :ensure => 'absent' } + end + it { should_not contain_file('/etc/munin/plugins/users') } + it { should_not contain_file('/etc/munin/plugin-conf.d/users.conf') } + end +end -- cgit v1.2.3 From 057658ba93e2562c596dfa5607836679631be916 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 2 Jul 2013 22:49:02 +0200 Subject: Unify OS specific munin-conf.conf In essence all munin-node.conf files contained the same template, besides a few values. By moving all to a single template, maintenance burden is reduced. To ensure all values are still present in the templates, tests are added. --- spec/classes/munin_client_base_spec.rb | 86 ++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 spec/classes/munin_client_base_spec.rb (limited to 'spec') diff --git a/spec/classes/munin_client_base_spec.rb b/spec/classes/munin_client_base_spec.rb new file mode 100644 index 0000000..1b3d936 --- /dev/null +++ b/spec/classes/munin_client_base_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +describe 'munin::client::base' do + let :default_facts do + { + :fqdn => 'munin-node.example.org', + } + end + + let :pre_condition do + 'include munin::client' + end + + context 'on Debian' do + let :facts do + { :operatingsystem => 'Debian' }.merge(default_facts) + end + + it 'should compile' do + should include_class('munin::client::base') + end + + it 'should set up munin-node' do + should contain_service('munin-node').with({ + :ensure => 'running', + :enable => true, + :hasstatus => true, + :hasrestart => true, + }) + + should contain_file('/etc/munin').with({ + :ensure => 'directory', + :mode => '0755', + :owner => 'root', + :group => 0, + }) + + should contain_file('/etc/munin/munin-node.conf'). + with_content(/^host_name munin-node.example.org$/). + with_content(/^allow \^127\\\.0\\\.0\\\.1\$$/). + with_content(/^host \*$/). + with_content(/^port 4949$/) + + should contain_munin__register('munin-node.example.org').with({ + :host => 'munin-node.example.org', + :port => '4949', + :use_ssh => false, + :config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'], + :export_tag => 'munin', + }) + + should contain_class('munin::plugins::base') + end + + it 'should contain the Debian specific values' do + should contain_file('/etc/munin/munin-node.conf'). + with_content(/^log_file \/var\/log\/munin\/munin-node.log$/). + with_content(/^group root$/) + end + end + + context 'on CentOS' do + let :facts do + { :operatingsystem => 'CentOS' }.merge(default_facts) + end + + it 'should contain the CentOS specific values' do + should contain_file('/etc/munin/munin-node.conf'). + with_content(/^log_file \/var\/log\/munin-node\/munin-node.log$/). + with_content(/^group root$/) + end + end + + # Disabled because the required openbsd module is not in the requirements + context 'on OpenBSD', :if => false do + let :facts do + { :operatingsystem => 'OpenBSD' }.merge(default_facts) + end + + it 'should contain the config OpenBSD specific values' do + should contain_file('/etc/munin/munin-node.conf'). + with_content(/^log_file \/var\/log\/munin-node\/munin-node.log$/). + with_content(/^group 0$/) + end + end +end -- cgit v1.2.3 From 9bee8a31f2305dda884aeab3caf3bf91cd8603ba Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 2 Jul 2013 23:07:00 +0200 Subject: Unify logrotate files into templates --- spec/classes/munin_host_cgi_spec.rb | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 spec/classes/munin_host_cgi_spec.rb (limited to 'spec') diff --git a/spec/classes/munin_host_cgi_spec.rb b/spec/classes/munin_host_cgi_spec.rb new file mode 100644 index 0000000..301f964 --- /dev/null +++ b/spec/classes/munin_host_cgi_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'munin::host::cgi' do + #let :pre_condition do + # 'include munin::client' + #end + + context 'on Debian' do + let :facts do + { :operatingsystem => 'Debian' } + end + + it 'should compile' do + should include_class('munin::host::cgi') + end + + it 'should exec set_modes_for_cgi' do + should contain_exec('set_modes_for_cgi').with({ + :command => 'chgrp www-data /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/munin/* -maxdepth 1 -type d -exec chgrp -R www-data {} \; && find /var/www/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + :refreshonly => true, + :subscribe => 'Concat::Fragment[munin.conf.header]', + }) + end + + it 'should contain logrotate.conf' do + should contain_file('/etc/logrotate.d/munin').with({ + :content => /^ create 660 munin www-data$/, + :group => 0, + :mode => '0644', + :owner => 'root', + }) + end + end + + context 'on CentOS' do + let :facts do + { :operatingsystem => 'CentOS' } + end + + it 'should exec set_modes_for_cgi' do + should contain_exec('set_modes_for_cgi').with({ + :command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + :refreshonly => true, + :subscribe => 'Concat::Fragment[munin.conf.header]', + }) + end + + it 'should contain logrotate.conf' do + should contain_file('/etc/logrotate.d/munin').with({ + :content => /^ create 660 munin apache$/, + :group => 0, + :mode => '0644', + :owner => 'root', + }) + end + end +end -- cgit v1.2.3 From 9de938880129bc8d8985debdf09336d63787f8ae Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 3 Feb 2014 16:11:07 +0100 Subject: using correct facts in tests --- spec/classes/munin_client_base_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/classes/munin_client_base_spec.rb b/spec/classes/munin_client_base_spec.rb index 1b3d936..2ddfdcc 100644 --- a/spec/classes/munin_client_base_spec.rb +++ b/spec/classes/munin_client_base_spec.rb @@ -13,7 +13,7 @@ describe 'munin::client::base' do context 'on Debian' do let :facts do - { :operatingsystem => 'Debian' }.merge(default_facts) + { :osfamily => 'Debian' }.merge(default_facts) end it 'should compile' do @@ -61,7 +61,7 @@ describe 'munin::client::base' do context 'on CentOS' do let :facts do - { :operatingsystem => 'CentOS' }.merge(default_facts) + { :osfamily => 'CentOS' }.merge(default_facts) end it 'should contain the CentOS specific values' do @@ -74,7 +74,7 @@ describe 'munin::client::base' do # Disabled because the required openbsd module is not in the requirements context 'on OpenBSD', :if => false do let :facts do - { :operatingsystem => 'OpenBSD' }.merge(default_facts) + { :osfamily => 'OpenBSD' }.merge(default_facts) end it 'should contain the config OpenBSD specific values' do -- cgit v1.2.3 From 88d197da8cedd5d711db043995f725ebe66b6ed6 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 13 Jun 2014 12:25:48 +0200 Subject: implement #38 - allow config to be an array --- spec/defines/munin_plugin_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec') diff --git a/spec/defines/munin_plugin_spec.rb b/spec/defines/munin_plugin_spec.rb index 3d7e9e3..0e7306a 100644 --- a/spec/defines/munin_plugin_spec.rb +++ b/spec/defines/munin_plugin_spec.rb @@ -30,6 +30,23 @@ describe 'munin::plugin' do ) } end + context 'present and config as an array' do + let(:params) do + { :config => [ 'env.user root', 'env.group root' ] } + end + it { should contain_file('/etc/munin/plugins/users').with( + :ensure => 'link', + :target => '/usr/share/munin/plugins/users', + :notify => 'Service[munin-node]' + ) } + it { should contain_file('/etc/munin/plugin-conf.d/users.conf').with( + :content => "[users]\nenv.user root\nenv.group root\n", + :owner => 'root', + :group => 0, + :mode => '0640' + ) } + end + context 'absent' do let(:params) do { :ensure => 'absent' } -- cgit v1.2.3 From b4a5d72198df331e8cc62d309d14a989fa4c311c Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 13 Jun 2014 13:15:26 +0200 Subject: migrate tests to new format --- spec/classes/munin_client_base_spec.rb | 2 +- spec/classes/munin_client_spec.rb | 4 ++-- spec/classes/munin_host_cgi_spec.rb | 2 +- spec/classes/munin_host_spec.rb | 4 ++-- spec/classes/munin_plugins_interfaces_spec.rb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'spec') diff --git a/spec/classes/munin_client_base_spec.rb b/spec/classes/munin_client_base_spec.rb index 2ddfdcc..fdf1403 100644 --- a/spec/classes/munin_client_base_spec.rb +++ b/spec/classes/munin_client_base_spec.rb @@ -17,7 +17,7 @@ describe 'munin::client::base' do end it 'should compile' do - should include_class('munin::client::base') + should contain_class('munin::client::base') end it 'should set up munin-node' do diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb index 9a92cef..f7fc5e9 100644 --- a/spec/classes/munin_client_spec.rb +++ b/spec/classes/munin_client_spec.rb @@ -10,7 +10,7 @@ describe 'munin::client' do it { should contain_package('munin-node') } it { should contain_package('iproute') } it { should contain_file('/etc/munin/munin-node.conf') } - it { should include_class('munin::client::debian') } + it { should contain_class('munin::client::debian') } end shared_examples 'redhat-client' do |os, codename| @@ -44,7 +44,7 @@ describe 'munin::client' do }} it { should contain_package('munin-node') } it { should contain_file('/etc/munin/munin-node.conf') } - it { should include_class('munin::client::gentoo') } + it { should contain_class('munin::client::gentoo') } end end diff --git a/spec/classes/munin_host_cgi_spec.rb b/spec/classes/munin_host_cgi_spec.rb index 301f964..52c5c22 100644 --- a/spec/classes/munin_host_cgi_spec.rb +++ b/spec/classes/munin_host_cgi_spec.rb @@ -11,7 +11,7 @@ describe 'munin::host::cgi' do end it 'should compile' do - should include_class('munin::host::cgi') + should contain_class('munin::host::cgi') end it 'should exec set_modes_for_cgi' do diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb index 461ced5..b707b5d 100644 --- a/spec/classes/munin_host_spec.rb +++ b/spec/classes/munin_host_spec.rb @@ -10,7 +10,7 @@ describe 'munin::host' do }} it { should contain_package('munin') } it { should contain_file('/etc/munin/munin.conf') } - it { should include_class('munin::host') } + it { should contain_class('munin::host') } end shared_examples 'redhat-host' do |os, codename| @@ -22,7 +22,7 @@ describe 'munin::host' do }} it { should contain_package('munin') } it { should contain_file('/etc/munin/munin.conf') } - it { should include_class('munin::host') } + it { should contain_class('munin::host') } end context 'on debian-like system' do diff --git a/spec/classes/munin_plugins_interfaces_spec.rb b/spec/classes/munin_plugins_interfaces_spec.rb index 95aa785..7e3c418 100644 --- a/spec/classes/munin_plugins_interfaces_spec.rb +++ b/spec/classes/munin_plugins_interfaces_spec.rb @@ -10,7 +10,7 @@ describe 'munin::plugins::interfaces' do end it 'should compile' do - should include_class('munin::plugins::interfaces') + should contain_class('munin::plugins::interfaces') end it 'should create plugins for each interface' do -- cgit v1.2.3 From 90796d31dd9ab7e4f183f99d0fe7237a7f42ddfc Mon Sep 17 00:00:00 2001 From: Daniel Jakob Date: Sat, 28 Jun 2014 12:02:52 +0200 Subject: Add some simple gentoo specific tests --- spec/classes/munin_host_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec') diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb index b707b5d..df002ce 100644 --- a/spec/classes/munin_host_spec.rb +++ b/spec/classes/munin_host_spec.rb @@ -34,4 +34,14 @@ describe 'munin::host' do context 'on redhat-like system' do it_behaves_like 'redhat-host', 'CentOS', '6' end + + context 'on Gentoo' do + let(:facts) {{ + :osfamily => 'Gentoo', + :concat_basedir => '/var/lib/puppet/concat', + }} + it { should contain_package('munin') } + it { should contain_file('/etc/munin/munin.conf') } + it { should contain_class('munin::host') } + end end -- cgit v1.2.3