summaryrefslogtreecommitdiff
path: root/spec/classes
diff options
context:
space:
mode:
Diffstat (limited to 'spec/classes')
-rw-r--r--spec/classes/munin_client_base_spec.rb86
-rw-r--r--spec/classes/munin_client_spec.rb50
-rw-r--r--spec/classes/munin_host_cgi_spec.rb57
-rw-r--r--spec/classes/munin_host_spec.rb47
-rw-r--r--spec/classes/munin_plugins_interfaces_spec.rb44
5 files changed, 284 insertions, 0 deletions
diff --git a/spec/classes/munin_client_base_spec.rb b/spec/classes/munin_client_base_spec.rb
new file mode 100644
index 0000000..fdf1403
--- /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
+ { :osfamily => 'Debian' }.merge(default_facts)
+ end
+
+ it 'should compile' do
+ should contain_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
+ { :osfamily => '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
+ { :osfamily => '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
diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb
new file mode 100644
index 0000000..f7fc5e9
--- /dev/null
+++ b/spec/classes/munin_client_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+describe 'munin::client' do
+ shared_examples 'debian-client' 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') }
+ it { should contain_class('munin::client::debian') }
+ end
+
+ shared_examples 'redhat-client' do |os, codename|
+ let(:facts) {{
+ :operatingsystem => os,
+ :osfamily => 'RedHat',
+ :lsbdistcodename => codename,
+ }}
+ 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-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-client', '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') }
+ 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
new file mode 100644
index 0000000..52c5c22
--- /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 contain_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
diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb
new file mode 100644
index 0000000..df002ce
--- /dev/null
+++ b/spec/classes/munin_host_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe 'munin::host' do
+ 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') }
+ it { should contain_class('munin::host') }
+ 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 contain_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
+
+ 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
diff --git a/spec/classes/munin_plugins_interfaces_spec.rb b/spec/classes/munin_plugins_interfaces_spec.rb
new file mode 100644
index 0000000..7e3c418
--- /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 contain_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