diff --git a/.fixtures.yml b/.fixtures.yml
index 0e733f0e3..02f876fc1 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -6,7 +6,6 @@ fixtures:
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib'
concat:
repo: 'git://github.com/puppetlabs/puppetlabs-concat'
- ref: '2.1.0'
epel:
repo: 'https://github.com/stahnma/puppet-module-epel'
symlinks:
diff --git a/.gitignore b/.gitignore
index 0d629b0c1..e9b3cf4bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ Puppetfile.lock
*.iml
.*.sw?
.yardoc/
+Guardfile
diff --git a/.msync.yml b/.msync.yml
index 540f0cea4..4abde2202 100644
--- a/.msync.yml
+++ b/.msync.yml
@@ -1 +1 @@
-modulesync_config_version: '0.21.0'
+modulesync_config_version: '0.21.3'
diff --git a/.rspec_parallel b/.rspec_parallel
new file mode 100644
index 000000000..e4d136b75
--- /dev/null
+++ b/.rspec_parallel
@@ -0,0 +1 @@
+--format progress
diff --git a/.rubocop.yml b/.rubocop.yml
index 02f6dd5d6..d92e4e456 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -11,6 +11,7 @@ AllCops:
- spec/fixtures/**/*
- Gemfile
- Rakefile
+ - Guardfile
Lint/ConditionPosition:
Enabled: True
@@ -502,6 +503,10 @@ Style/ClosingParenthesisIndentation:
# RSpec
+RSpec/BeforeAfterAll:
+ Exclude:
+ - spec/acceptance/**/*
+
# We don't use rspec in this way
RSpec/DescribeClass:
Enabled: False
@@ -524,6 +529,7 @@ RSpec/NestedGroups:
# this is broken on ruby1.9
Style/IndentHeredoc:
Enabled: False
+
# disable Yaml safe_load. This is needed to support ruby2.0.0 development envs
Security/YAMLLoad:
Enabled: false
diff --git a/Gemfile b/Gemfile
index d35336cb5..0914f7cbb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -35,6 +35,7 @@ group :test do
gem 'github_changelog_generator', '~> 1.13.0', :require => false if RUBY_VERSION < '2.2.2'
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2'
gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2'
+ gem 'parallel_tests', :require => false
end
group :development do
diff --git a/spec/acceptance/nodesets/archlinux-2-x64.yml b/spec/acceptance/nodesets/archlinux-2-x64.yml
new file mode 100644
index 000000000..89b63003f
--- /dev/null
+++ b/spec/acceptance/nodesets/archlinux-2-x64.yml
@@ -0,0 +1,13 @@
+---
+# This file is managed via modulesync
+# https://github.com/voxpupuli/modulesync
+# https://github.com/voxpupuli/modulesync_config
+HOSTS:
+ archlinux-2-x64:
+ roles:
+ - master
+ platform: archlinux-2-x64
+ box: archlinux/archlinux
+ hypervisor: vagrant
+CONFIG:
+ type: foss
diff --git a/spec/classes/collectd_plugin_curl_spec.rb b/spec/classes/collectd_plugin_curl_spec.rb
index edfcb6533..a473315fd 100644
--- a/spec/classes/collectd_plugin_curl_spec.rb
+++ b/spec/classes/collectd_plugin_curl_spec.rb
@@ -1,118 +1,93 @@
require 'spec_helper'
describe 'collectd::plugin::curl', type: :class do
- let :pre_condition do
- 'include ::collectd'
- end
- 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)
- it 'Will create /etc/collectd.d/10-curl.conf' do
- is_expected.to contain_file('curl.load').with(ensure: 'present',
- path: '/etc/collectd.d/10-curl.conf',
- content: %r{\#\ Generated by Puppet\nLoadPlugin curl\n\n})
- end
- end
+ let :pre_condition do
+ 'include ::collectd'
+ end
- context ':ensure => present, creating two pages' do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '4.8.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
- let :params do
- {
- ensure: 'present',
- pages: {
- 'stocks_ILD' => {
- 'url' => 'http://finance.google.com/finance?q=EPA%3AILD',
- 'user' => 'foo',
- 'password' => 'bar',
- 'matches' => [
- {
- 'dstype' => 'GaugeAverage',
- 'instance' => 'ILD',
- 'regex' => ']*> *([0-9]*\\.[0-9]+) *',
- 'type' => 'stock_value'
+ context ':ensure => present, default params' do
+ it "Will create #{options[:plugin_conf_dir]}/10-curl.conf" do
+ is_expected.to contain_file('curl.load').with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/10-curl.conf",
+ content: %r{LoadPlugin curl}
+ )
+ end
+ end
+
+ context ':ensure => present, creating two pages' do
+ let :params do
+ {
+ ensure: 'present',
+ pages: {
+ 'stocks_ILD' => {
+ 'url' => 'http://finance.google.com/finance?q=EPA%3AILD',
+ 'user' => 'foo',
+ 'password' => 'bar',
+ 'matches' => [
+ {
+ 'dstype' => 'GaugeAverage',
+ 'instance' => 'ILD',
+ 'regex' => ']*> *([0-9]*\\.[0-9]+) *',
+ 'type' => 'stock_value'
+ }
+ ]
}
- ]
+ }
}
- }
- }
- end
+ end
- it 'Will create /etc/collectd.d/conf.d/curl-stocks_ILD.conf and /etc/collectd/conf.d/curl-stocks_GM.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/curl-stocks_ILD.conf').with(ensure: 'present',
- path: '/etc/collectd/conf.d/curl-stocks_ILD.conf',
- content: "\n \n URL \"http://finance.google.com/finance?q=EPA%3AILD\"\n User \"foo\"\n Password \"bar\"\n \n Regex \"]*> *([0-9]*\\.[0-9]+) *\"\n DSType \"GaugeAverage\"\n Type \"stock_value\"\n Instance \"ILD\"\n \n\n \n\n")
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/curl-stocks_ILD.conf and #{options[:plugin_conf_dir]}/curl-stocks_GM.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/curl-stocks_ILD.conf").with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/curl-stocks_ILD.conf",
+ content: "\n \n URL \"http://finance.google.com/finance?q=EPA%3AILD\"\n User \"foo\"\n Password \"bar\"\n \n Regex \"]*> *([0-9]*\\.[0-9]+) *\"\n DSType \"GaugeAverage\"\n Type \"stock_value\"\n Instance \"ILD\"\n \n\n \n\n")
+ end
+ end
- context ':ensure => present, verifypeer => false, verifyhost => \'false\', measureresponsetime => true, matches empty' do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '4.8.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
- let :params do
- {
- ensure: 'present',
- pages: {
- 'selfsigned_ssl' => {
- 'url' => 'https://some.selfsigned.ssl.site/',
- 'verifypeer' => false,
- 'verifyhost' => 'false',
- 'measureresponsetime' => true
+ context ':ensure => present, verifypeer => false, verifyhost => \'false\', measureresponsetime => true, matches empty' do
+ let :params do
+ {
+ ensure: 'present',
+ pages: {
+ 'selfsigned_ssl' => {
+ 'url' => 'https://some.selfsigned.ssl.site/',
+ 'verifypeer' => false,
+ 'verifyhost' => 'false',
+ 'measureresponsetime' => true
+ }
+ }
}
- }
- }
- end
+ end
- it 'Will create /etc/collectd.d/conf.d/curl-selfsigned_ssl.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/curl-selfsigned_ssl.conf').with(ensure: 'present',
- path: '/etc/collectd/conf.d/curl-selfsigned_ssl.conf',
- content: "\n \n URL \"https://some.selfsigned.ssl.site/\"\n VerifyPeer false\n VerifyHost false\n MeasureResponseTime true\n \n\n")
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/curl-selfsigned_ssl.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/curl-selfsigned_ssl.conf").with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/curl-selfsigned_ssl.conf",
+ content: "\n \n URL \"https://some.selfsigned.ssl.site/\"\n VerifyPeer false\n VerifyHost false\n MeasureResponseTime true\n \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
- let :params do
- { ensure: 'absent' }
- end
+ context ':ensure => absent' do
+ let :params do
+ { ensure: 'absent' }
+ end
- it 'Will not create /etc/collectd.d/10-curl.conf' do
- is_expected.to contain_file('curl.load').with(ensure: 'absent',
- path: '/etc/collectd.d/10-curl.conf')
+ it "Will not create #{options[:plugin_conf_dir]}/10-curl.conf" do
+ is_expected.to contain_file('curl.load').with(
+ ensure: 'absent',
+ path: "#{options[:plugin_conf_dir]}/10-curl.conf"
+ )
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_exec_spec.rb b/spec/classes/collectd_plugin_exec_spec.rb
index f379fcd3e..44eef1edd 100644
--- a/spec/classes/collectd_plugin_exec_spec.rb
+++ b/spec/classes/collectd_plugin_exec_spec.rb
@@ -1,72 +1,86 @@
require 'spec_helper'
describe 'collectd::plugin::exec', type: :class do
- let :facts do
- {
- osfamily: 'Debian',
- concat_basedir: '/dne',
- id: 'root',
- kernel: 'Linux',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '5.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 'single command' do
- let :params do
- {
- commands: { 'hello' =>
- { 'user' => 'nobody', 'group' => 'users', 'exec' => ['/bin/echo', 'hello world'] } }
- }
- end
+ options = os_specific_options(facts)
+ context 'single command' do
+ let :params do
+ {
+ commands: { 'hello' =>
+ {
+ 'user' => 'nobody',
+ 'group' => 'users',
+ 'exec' => ['/bin/echo', 'hello world']
+ }
+ }
+ }
+ end
- it 'Will create /etc/collectd.d/conf.d/exec-config.conf' do
- is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_header').
- with(content: %r{},
- target: '/etc/collectd/conf.d/exec-config.conf',
- order: '00')
- end
+ it "Will create #{options[:plugin_conf_dir]}/exec-config.conf" do
+ is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_header').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/exec-config.conf",
+ order: '00'
+ )
+ end
- it 'Will create /etc/collectd.d/conf.d/exec-config' do
- is_expected.to contain_concat('/etc/collectd/conf.d/exec-config.conf').
- that_requires('File[collectd.d]')
- is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_footer').
- with(content: %r{},
- target: '/etc/collectd/conf.d/exec-config.conf',
- order: '99')
- end
+ it "Will create #{options[:plugin_conf_dir]}/exec-config" do
+ is_expected.to contain_concat("#{options[:plugin_conf_dir]}/exec-config.conf").
+ that_requires('File[collectd.d]')
+ is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_footer').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/exec-config.conf",
+ order: '99'
+ )
+ end
- it 'includes exec statement' do
- is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_hello').
- with(content: %r{Exec "nobody:users" "/bin/echo" "hello world"},
- target: '/etc/collectd/conf.d/exec-config.conf')
- end
- end
+ it 'includes exec statement' do
+ is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_hello').with(
+ content: %r{Exec "nobody:users" "/bin/echo" "hello world"},
+ target: "#{options[:plugin_conf_dir]}/exec-config.conf"
+ )
+ end
+ end
- context 'multiple commands' do
- let :params do
- {
- commands: {
- 'hello' => { 'user' => 'nobody', 'group' => 'users',
- 'exec' => ['/bin/echo', 'hello world'] },
- 'my_date' => { 'user' => 'nobody', 'group' => 'users',
- 'exec' => ['/bin/date'] }
- }
- }
- end
+ context 'multiple commands' do
+ let :params do
+ {
+ commands: {
+ 'hello' =>
+ {
+ 'user' => 'nobody',
+ 'group' => 'users',
+ 'exec' => ['/bin/echo', 'hello world']
+ },
+ 'my_date' =>
+ {
+ 'user' => 'nobody',
+ 'group' => 'users',
+ 'exec' => ['/bin/date']
+ }
+ }
+ }
+ end
- it 'includes echo statement' do
- is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_hello').
- with(content: %r{Exec "nobody:users" "/bin/echo" "hello world"},
- target: '/etc/collectd/conf.d/exec-config.conf')
- end
+ it 'includes echo statement' do
+ is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_hello').with(
+ content: %r{Exec "nobody:users" "/bin/echo" "hello world"},
+ target: "#{options[:plugin_conf_dir]}/exec-config.conf"
+ )
+ end
- it 'includes date statement' do
- is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_my_date').
- with(content: %r{Exec "nobody:users" "/bin/date"},
- target: '/etc/collectd/conf.d/exec-config.conf')
+ it 'includes date statement' do
+ is_expected.to contain_concat__fragment('collectd_plugin_exec_conf_my_date').with(
+ content: %r{Exec "nobody:users" "/bin/date"},
+ target: "#{options[:plugin_conf_dir]}/exec-config.conf"
+ )
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_filter_spec.rb b/spec/classes/collectd_plugin_filter_spec.rb
index 4213c6389..11cbc594e 100644
--- a/spec/classes/collectd_plugin_filter_spec.rb
+++ b/spec/classes/collectd_plugin_filter_spec.rb
@@ -1,65 +1,67 @@
require 'spec_helper'
describe 'collectd::plugin::filter', type: :class do
- let :facts do
- {
- osfamily: 'Debian',
- concat_basedir: '/dne',
- id: 'root',
- kernel: 'Linux',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '5.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 and default parameters' do
- it 'Will create /etc/collectd/conf.d/01-filter.conf to set the default Chains' do
- is_expected.to contain_file('/etc/collectd/conf.d/01-filter.conf').with(ensure: 'present',
- path: '/etc/collectd/conf.d/01-filter.conf',
- content: %r{PreCacheChain \"PreChain\"\nPostCacheChain \"PostChain\"})
- end
- end
+ options = os_specific_options(facts)
+ context ':ensure => present and default parameters' do
+ it "Will create #{options[:plugin_conf_dir]}/01-filter.conf to set the default Chains" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/01-filter.conf").with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/01-filter.conf",
+ content: %r{PreCacheChain \"PreChain\"\nPostCacheChain \"PostChain\"}
+ )
+ end
+ end
- context ':ensure => present and custom parameters' do
- let(:params) do
- {
- ensure: 'present',
- precachechain: 'MyPreChain',
- postcachechain: 'MyPostChain'
- }
- end
+ context ':ensure => present and custom parameters' do
+ let(:params) do
+ {
+ ensure: 'present',
+ precachechain: 'MyPreChain',
+ postcachechain: 'MyPostChain'
+ }
+ end
- it 'Will create /etc/collectd/conf.d/01-filter.conf to set the default Chains' do
- is_expected.to contain_file('/etc/collectd/conf.d/01-filter.conf').with(ensure: 'present',
- path: '/etc/collectd/conf.d/01-filter.conf',
- content: %r{PreCacheChain \"MyPreChain\"\nPostCacheChain \"MyPostChain\"})
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/01-filter.conf to set the default Chains" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/01-filter.conf").with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/01-filter.conf",
+ content: %r{PreCacheChain \"MyPreChain\"\nPostCacheChain \"MyPostChain\"}
+ )
+ end
+ end
- context ':ensure => absent' do
- let(:params) do
- { ensure: 'absent' }
- end
+ context ':ensure => absent' do
+ let(:params) do
+ { ensure: 'absent' }
+ end
- it 'Will remove /etc/collectd/conf.d/01-filter.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/01-filter.conf').with(ensure: 'absent',
- path: '/etc/collectd/conf.d/01-filter.conf')
- end
+ it "Will remove #{options[:plugin_conf_dir]}/01-filter.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/01-filter.conf").with(
+ ensure: 'absent',
+ path: "#{options[:plugin_conf_dir]}/01-filter.conf"
+ )
+ end
- it 'Will remove loads of match plugins for filter' do
- is_expected.to contain_file('match_regex.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-match_regex.conf')
- is_expected.to contain_file('match_timediff.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-match_timediff.conf')
- is_expected.to contain_file('match_value.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-match_value.conf')
- is_expected.to contain_file('match_empty_counter.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-match_empty_counter.conf')
- is_expected.to contain_file('match_hashed.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-match_hashed.conf')
- end
+ it 'Will remove loads of match plugins for filter' do
+ is_expected.to contain_file('match_regex.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-match_regex.conf")
+ is_expected.to contain_file('match_timediff.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-match_timediff.conf")
+ is_expected.to contain_file('match_value.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-match_value.conf")
+ is_expected.to contain_file('match_empty_counter.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-match_empty_counter.conf")
+ is_expected.to contain_file('match_hashed.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-match_hashed.conf")
+ end
- it 'Will remove loads of target plugins for filter' do
- is_expected.to contain_file('target_notification.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-target_notification.conf')
- is_expected.to contain_file('target_replace.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-target_replace.conf')
- is_expected.to contain_file('target_set.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/02-target_set.conf')
+ it 'Will remove loads of target plugins for filter' do
+ is_expected.to contain_file('target_notification.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-target_notification.conf")
+ is_expected.to contain_file('target_replace.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-target_replace.conf")
+ is_expected.to contain_file('target_set.load').with(ensure: 'absent', path: "#{options[:plugin_conf_dir]}/02-target_set.conf")
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_genericjmx_spec.rb b/spec/classes/collectd_plugin_genericjmx_spec.rb
index 3714935d9..d03949277 100644
--- a/spec/classes/collectd_plugin_genericjmx_spec.rb
+++ b/spec/classes/collectd_plugin_genericjmx_spec.rb
@@ -1,77 +1,74 @@
require 'spec_helper'
describe 'collectd::plugin::genericjmx', type: :class do
- let(:facts) do
- {
- osfamily: 'Debian',
- id: 'root',
- concat_basedir: '/dne',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- 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
- let(:config_filename) { '/etc/collectd/conf.d/15-genericjmx.conf' }
+ options = os_specific_options(facts)
- context 'defaults' do
- it 'will include the java plugin' do
- is_expected.to contain_class('collectd::plugin::java')
- end
+ let(:config_filename) { "#{options[:plugin_conf_dir]}/15-genericjmx.conf" }
- it 'will load the genericjmx plugin' do
- is_expected.to contain_concat(config_filename).
- with(ensure: 'present',
- mode: '0640',
- owner: 'root',
- group: 'root',
- ensure_newline: true)
- end
+ context 'defaults' do
+ it 'will include the java plugin' do
+ is_expected.to contain_class('collectd::plugin::java')
+ end
- it { is_expected.to contain_concat(config_filename).that_notifies('Service[collectd]') }
- it { is_expected.to contain_concat(config_filename).that_requires('File[collectd.d]') }
+ it 'will load the genericjmx plugin' do
+ is_expected.to contain_concat(config_filename).
+ with(ensure: 'present',
+ mode: '0640',
+ owner: 'root',
+ ensure_newline: true)
+ end
- it do
- is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').
- with(order: '00',
- target: config_filename,
- content: %r{.+LoadPlugin "org\.collectd\.java\.GenericJMX".+}m)
- end
+ it { is_expected.to contain_concat(config_filename).that_notifies('Service[collectd]') }
+ it { is_expected.to contain_concat(config_filename).that_requires('File[collectd.d]') }
- it do
- is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_footer').
- with(order: '99',
- target: config_filename,
- content: %r{.+}m)
- end
- end
+ it do
+ is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').
+ with(order: '00',
+ target: config_filename,
+ content: %r{.+LoadPlugin "org\.collectd\.java\.GenericJMX".+}m)
+ end
- context 'jvmarg parameter array' do
- let(:params) { { jvmarg: %w[foo bar baz] } }
+ it do
+ is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_footer').
+ with(order: '99',
+ target: config_filename,
+ content: %r{.+}m)
+ end
+ end
- it 'has multiple jvmarg parameters' do
- is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').
- with_content(%r{JVMArg "foo".*JVMArg "bar".*JVMArg "baz"}m)
- end
- end
+ context 'jvmarg parameter array' do
+ let(:params) { { jvmarg: %w[foo bar baz] } }
- context 'jvmarg parameter string' do
- let(:params) { { jvmarg: 'bat' } }
+ it 'has multiple jvmarg parameters' do
+ is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').
+ with_content(%r{JVMArg "foo".*JVMArg "bar".*JVMArg "baz"}m)
+ end
+ end
- it 'has one jvmarg parameter' do
- is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').with_content(%r{JVMArg "bat"})
- end
- it 'has ONLY one jvmarg parameter other than classpath' do
- is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(%r{(.*JVMArg.*){3,}}m)
- end
- end
+ context 'jvmarg parameter string' do
+ let(:params) { { jvmarg: 'bat' } }
+
+ it 'has one jvmarg parameter' do
+ is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').with_content(%r{JVMArg "bat"})
+ end
+ it 'has ONLY one jvmarg parameter other than classpath' do
+ is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(%r{(.*JVMArg.*){3,}}m)
+ end
+ end
- context 'jvmarg parameter empty' do
- let(:params) { { jvmarg: [] } }
+ context 'jvmarg parameter empty' do
+ let(:params) { { jvmarg: [] } }
- it 'does not have any jvmarg parameters other than classpath' do
- is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(%r{(.*JVMArg.*){2,}}m)
+ it 'does not have any jvmarg parameters other than classpath' do
+ is_expected.to contain_concat__fragment('collectd_plugin_genericjmx_conf_header').without_content(%r{(.*JVMArg.*){2,}}m)
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_load_spec.rb b/spec/classes/collectd_plugin_load_spec.rb
index a8d6048d3..395c56ff1 100644
--- a/spec/classes/collectd_plugin_load_spec.rb
+++ b/spec/classes/collectd_plugin_load_spec.rb
@@ -1,29 +1,29 @@
require 'spec_helper'
describe 'collectd::plugin::load', type: :class do
- let :pre_condition do
- 'include ::collectd'
- end
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
+ end
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '4.10.1',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
+ options = os_specific_options(facts)
+ let :pre_condition do
+ 'include ::collectd'
+ end
- context 'report_relative in load.conf' do
- let :params do
- {
- report_relative: true
- }
- end
+ context 'report_relative in load.conf' do
+ let :params do
+ {
+ report_relative: true
+ }
+ end
- it 'is present' do
- is_expected.to contain_file('load.load').
- without_content(%r{\s{2}ReportRelative true\s{2}})
+ it 'is present' do
+ is_expected.to contain_file('load.load').
+ without_content(%r{\s{2}ReportRelative true\s{2}})
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_python_spec.rb b/spec/classes/collectd_plugin_python_spec.rb
index 0938c64f0..83a0124c4 100644
--- a/spec/classes/collectd_plugin_python_spec.rb
+++ b/spec/classes/collectd_plugin_python_spec.rb
@@ -1,253 +1,264 @@
require 'spec_helper'
describe 'collectd::plugin::python', type: :class do
- let :facts do
- {
- osfamily: 'Debian',
- operatingsystem: 'Debian',
- concat_basedir: '/dne',
- id: 'root',
- kernel: 'Linux',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '5.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
-
- context ':ensure => present' do
- context ':ensure => present and default parameters' do
- it 'ensures that $modulepaths exits' do
- is_expected.to contain_file('/usr/local/lib/python2.7/dist-packages').with(ensure: 'directory')
- end
-
- it 'Will create /etc/collectd/conf.d/10-python.conf to load the plugin' do
- is_expected.to contain_file('python.load').with(ensure: 'present',
- path: '/etc/collectd/conf.d/10-python.conf',
- content: %r{LoadPlugin python})
- end
-
- it 'Will create /etc/collectd.d/conf.d/python-config.conf' do
- is_expected.to contain_concat('/etc/collectd/conf.d/python-config.conf').
- that_requires('File[collectd.d]')
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').
- with(content: %r{},
- target: '/etc/collectd/conf.d/python-config.conf',
- order: '00')
- end
-
- it 'set default Python module path' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').
- with(content: %r{ModulePath "/usr/local/lib/python2.7/dist-packages"},
- target: '/etc/collectd/conf.d/python-config.conf')
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
end
- it 'Will create /etc/collectd.d/conf.d/python-config.conf' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_footer').
- with(content: %r{},
- target: '/etc/collectd/conf.d/python-config.conf',
- order: '99')
- end
- end
-
- context ':ensure => present and multiple $modulepaths' do
- let :params do
- {
- modulepaths: ['/tmp/', '/data/']
- }
- end
-
- it 'will ensure the two directories are here' do
- is_expected.to contain_file('/tmp/')
- is_expected.to contain_file('/data/')
- end
- it 'will set two modulepath in the module conf' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
- content: %r{ModulePath "/tmp/"},
- target: '/etc/collectd/conf.d/python-config.conf'
- )
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
- content: %r{ModulePath "/data/"},
- target: '/etc/collectd/conf.d/python-config.conf'
- )
- end
- end
-
- context ':ensure => present and configure elasticsearch module' do
- let :params do
- {
- modules: {
- 'elasticsearch' => {
- 'script_source' => 'puppet:///modules/myorg/elasticsearch_collectd_python.py',
- 'config' => [{ 'Cluster' => 'ES-clust' }, { 'Cluster' => 'Another-ES-clust' }]
- },
- 'foo' => {
- 'config' => [{ 'Verbose' => true, 'Bar' => '"bar"' }]
+ options = os_specific_options(facts)
+
+ context ':ensure => present' do
+ context ':ensure => present and default parameters' do
+ it 'ensures that $modulepaths exits' do
+ is_expected.to contain_file('/usr/local/lib/python2.7/dist-packages').with(ensure: 'directory')
+ end
+
+ it "Will create #{options[:plugin_conf_dir]}/10-python.conf to load the plugin" do
+ is_expected.to contain_file('python.load').with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/10-python.conf",
+ content: %r{LoadPlugin python}
+ )
+ end
+
+ it "Will create #{options[:plugin_conf_dir]}/python-config.conf" do
+ is_expected.to contain_concat("#{options[:plugin_conf_dir]}/python-config.conf").
+ that_requires('File[collectd.d]')
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf",
+ order: '00'
+ )
+ end
+
+ it 'set default Python module path' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ content: %r{ModulePath "/usr/local/lib/python2.7/dist-packages"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+
+ it 'Will create /etc/collectd.d/conf.d/python-config.conf' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_footer').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf",
+ order: '99'
+ )
+ end
+ end
+
+ context ':ensure => present and multiple $modulepaths' do
+ let :params do
+ {
+ modulepaths: ['/tmp/', '/data/']
}
- }
- }
- end
+ end
+
+ it 'will ensure the two directories are here' do
+ is_expected.to contain_file('/tmp/')
+ is_expected.to contain_file('/data/')
+ end
+ it 'will set two modulepath in the module conf' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ content: %r{ModulePath "/tmp/"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ content: %r{ModulePath "/data/"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+ end
+
+ context ':ensure => present and configure elasticsearch module' do
+ let :params do
+ {
+ modules: {
+ 'elasticsearch' => {
+ 'script_source' => 'puppet:///modules/myorg/elasticsearch_collectd_python.py',
+ 'config' => [{ 'Cluster' => 'ES-clust' }, { 'Cluster' => 'Another-ES-clust' }]
+ },
+ 'foo' => {
+ 'config' => [{ 'Verbose' => true, 'Bar' => '"bar"' }]
+ }
+ }
+ }
+ end
+
+ it 'imports elasticsearch module' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').with(
+ content: %r{Import "elasticsearch"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+
+ it 'includes elasticsearch module configuration' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+
+ it 'includes elasticsearch Cluster name' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').with(
+ content: %r{Cluster "ES-clust"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+
+ it 'includes second elasticsearch Cluster name' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').with(
+ content: %r{Cluster "Another-ES-clust"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+
+ it 'created collectd plugin file' do
+ is_expected.to contain_file('elasticsearch.script').with(
+ ensure: 'present',
+ path: '/usr/local/lib/python2.7/dist-packages/elasticsearch.py'
+ )
+ end
+
+ # test foo module
+ it 'imports foo module' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').with(
+ content: %r{Import "foo"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ end
+
+ it 'includes foo module configuration' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').with(content: %r{Verbose true})
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').with(content: %r{Bar "bar"})
+ end
+ end
+
+ context 'allow changing module path' do
+ let :params do
+ {
+ modulepaths: ['/var/lib/collectd/python', '/usr/collectd'],
+ modules: {
+ 'elasticsearch' => {
+ 'script_source' => 'puppet:///modules/myorg/elasticsearch_collectd_python.py',
+ 'config' => [{ 'Cluster' => 'ES-clust' }],
+ 'modulepath' => '/var/lib/collectd/python'
+ }
+ }
+ }
+ end
- it 'imports elasticsearch module' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').
- with(content: %r{Import "elasticsearch"},
- target: '/etc/collectd/conf.d/python-config.conf')
- end
+ it 'ensures that each directory on $modulepaths exits' do
+ is_expected.to contain_file('/var/lib/collectd/python').with(ensure: 'directory')
- it 'includes elasticsearch module configuration' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').
- with(content: %r{},
- target: '/etc/collectd/conf.d/python-config.conf')
- end
+ is_expected.to contain_file('/usr/collectd').with(ensure: 'directory')
+ end
- it 'includes elasticsearch Cluster name' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').
- with(content: %r{Cluster "ES-clust"},
- target: '/etc/collectd/conf.d/python-config.conf')
- end
+ it 'set default Python module paths' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ content: %r{ModulePath "/var/lib/collectd/python"},
+ target: "#{options[:plugin_conf_dir]}/python-config.conf"
+ )
- it 'includes second elasticsearch Cluster name' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_elasticsearch').
- with(content: %r{Cluster "Another-ES-clust"},
- target: '/etc/collectd/conf.d/python-config.conf')
- end
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{ModulePath "/usr/collectd"})
- it 'created collectd plugin file' do
- is_expected.to contain_file('elasticsearch.script').
- with(ensure: 'present',
- path: '/usr/local/lib/python2.7/dist-packages/elasticsearch.py')
- end
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{ModulePath "/var/lib/collectd/python"})
+ end
- # test foo module
- it 'imports foo module' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').
- with(content: %r{Import "foo"},
- target: '/etc/collectd/conf.d/python-config.conf')
- end
+ it 'created collectd plugin file' do
+ is_expected.to contain_file('elasticsearch.script').
+ with(ensure: 'present',
+ path: '/var/lib/collectd/python/elasticsearch.py')
+ end
+ end
- it 'includes foo module configuration' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').
- with(content: %r{},
- target: '/etc/collectd/conf.d/python-config.conf')
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').with(content: %r{Verbose true})
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_foo').with(content: %r{Bar "bar"})
- end
- end
-
- context 'allow changing module path' do
- let :params do
- {
- modulepaths: ['/var/lib/collectd/python', '/usr/collectd'],
- modules: {
- 'elasticsearch' => {
- 'script_source' => 'puppet:///modules/myorg/elasticsearch_collectd_python.py',
- 'config' => [{ 'Cluster' => 'ES-clust' }],
- 'modulepath' => '/var/lib/collectd/python'
+ context ':ensure => present and custom python config location' do
+ let :params do
+ {
+ conf_name: 'custom-location-config.conf'
}
- }
- }
+ end
+
+ it "Will create #{options[:plugin_conf_dir]}/custom-location-config.conf" do
+ is_expected.to contain_concat("#{options[:plugin_conf_dir]}/custom-location-config.conf").
+ that_requires('File[collectd.d]')
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/custom-location-config.conf",
+ order: '00'
+ )
+ end
+ end
end
- it 'ensures that each directory on $modulepaths exits' do
- is_expected.to contain_file('/var/lib/collectd/python').with(ensure: 'directory')
-
- is_expected.to contain_file('/usr/collectd').with(ensure: 'directory')
- end
-
- it 'set default Python module paths' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').
- with(content: %r{ModulePath "/var/lib/collectd/python"},
- target: '/etc/collectd/conf.d/python-config.conf')
-
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{ModulePath "/usr/collectd"})
-
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{ModulePath "/var/lib/collectd/python"})
- end
-
- it 'created collectd plugin file' do
- is_expected.to contain_file('elasticsearch.script').
- with(ensure: 'present',
- path: '/var/lib/collectd/python/elasticsearch.py')
+ context 'change globals parameter' do
+ let :params do
+ {
+ globals: false
+ }
+ end
+
+ it 'will change $globals settings' do
+ is_expected.to contain_file('python.load').with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/10-python.conf",
+ content: %r{Globals false}
+ )
+ end
end
- end
- context ':ensure => present and custom python config location' do
- let :params do
- {
- conf_name: 'custom-location-config.conf'
- }
- end
+ context 'allow passing shared options for all modules' do
+ let :params do
+ {
+ logtraces: true,
+ interactive: true,
+ encoding: 'utf-8'
+ }
+ end
- it 'Will create /etc/collectd.d/conf.d/custom-location-config.conf' do
- is_expected.to contain_concat('/etc/collectd/conf.d/custom-location-config.conf').
- that_requires('File[collectd.d]')
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').
- with(content: %r{},
- target: '/etc/collectd/conf.d/custom-location-config.conf',
- order: '00')
+ it 'sets options' do
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{LogTraces true})
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{Interactive true})
+ is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{Encoding utf-8})
+ end
end
- end
- end
-
- context 'change globals parameter' do
- let :params do
- {
- globals: false
- }
- end
- it 'will change $globals settings' do
- is_expected.to contain_file('python.load').
- with(ensure: 'present',
- path: '/etc/collectd/conf.d/10-python.conf',
- content: %r{Globals false})
- end
- end
-
- context 'allow passing shared options for all modules' do
- let :params do
- {
- logtraces: true,
- interactive: true,
- encoding: 'utf-8'
- }
- end
-
- it 'sets options' do
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{LogTraces true})
-
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{Interactive true})
-
- is_expected.to contain_concat__fragment('collectd_plugin_python_conf_header').with(content: %r{Encoding utf-8})
- end
- end
-
- context ':ensure => absent' do
- let(:title) { 'elasticsearch' }
- let :params do
- {
- ensure: 'absent',
- modules: {
- 'elasticsearch' => {
- 'script_source' => 'puppet:///modules/myorg/elasticsearch_collectd_python.py',
- 'config' => [{ 'Cluster' => 'ES-clust' }]
+ context ':ensure => absent' do
+ let(:title) { 'elasticsearch' }
+ let :params do
+ {
+ ensure: 'absent',
+ modules: {
+ 'elasticsearch' => {
+ 'script_source' => 'puppet:///modules/myorg/elasticsearch_collectd_python.py',
+ 'config' => [{ 'Cluster' => 'ES-clust' }]
+ }
+ }
}
- }
- }
- end
-
- it 'will remove /etc/collectd/conf.d/10-python.conf' do
- is_expected.to contain_file('python.load').
- with(ensure: 'absent',
- path: '/etc/collectd/conf.d/10-python.conf',
- content: %r{LoadPlugin python})
- end
-
- it 'won\'t create /etc/collectd.d/conf.d/python-config.conf (no modules defined)' do
- is_expected.not_to contain_concat__fragment('collectd_plugin_python_conf_header').
- with(ensure: 'absent',
- target: '/etc/collectd/conf.d/python-config.conf',
- order: '00')
+ end
+
+ it "will remove #{options[:plugin_conf_dir]}/10-python.conf" do
+ is_expected.to contain_file('python.load').with(
+ ensure: 'absent',
+ path: "#{options[:plugin_conf_dir]}/10-python.conf",
+ content: %r{LoadPlugin python}
+ )
+ end
+
+ it "won't create #{options[:plugin_conf_dir]}/python-config.conf (no modules defined)" do
+ is_expected.not_to contain_concat__fragment('collectd_plugin_python_conf_header').with(
+ ensure: 'absent',
+ target: "#{options[:plugin_conf_dir]}/python-config.conf",
+ order: '00'
+ )
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_virt_spec.rb b/spec/classes/collectd_plugin_virt_spec.rb
index 57b1b5f7b..0bda00d45 100644
--- a/spec/classes/collectd_plugin_virt_spec.rb
+++ b/spec/classes/collectd_plugin_virt_spec.rb
@@ -1,63 +1,56 @@
require 'spec_helper'
describe 'collectd::plugin::virt', type: :class do
- let :pre_condition do
- 'include ::collectd'
- end
-
- context 'interface_format in virt.conf' do
- let :params do
- {
- connection: 'qemu:///system',
- interface_format: 'address'
- }
- end
-
- context 'with collectd_version < 5.0' do
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '4.10.1',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
-
- it 'is ignored' do
- is_expected.to contain_file('libvirt.load').
- without_content(%r{.*InterfaceFormat \"address\".*})
- end
- end
+ facts
+ end
- context 'with collectd_version >= 5.0' do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '5.0.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
-
- it 'is included' do
- is_expected.to contain_file('libvirt.load').
- with_content(%r{.*InterfaceFormat \"address\".*})
- end
- end
-
- context 'with collectd_version >= 5.5' do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '5.5.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
+ let :pre_condition do
+ 'include ::collectd'
end
- it 'is included' do
- is_expected.to contain_file('virt.load').
- with_content(%r{.*InterfaceFormat \"address\".*})
+ context 'interface_format in virt.conf' do
+ let :params do
+ {
+ connection: 'qemu:///system',
+ interface_format: 'address'
+ }
+ end
+
+ context 'with collectd_version < 5.0' do
+ let :facts do
+ facts.merge(collectd_version: '4.10.1')
+ end
+
+ it 'is ignored' do
+ is_expected.to contain_file('libvirt.load').
+ without_content(%r{.*InterfaceFormat \"address\".*})
+ end
+ end
+
+ context 'with collectd_version >= 5.0' do
+ let :facts do
+ facts.merge(collectd_version: '5.0.0')
+ end
+
+ it 'is included' do
+ is_expected.to contain_file('libvirt.load').
+ with_content(%r{.*InterfaceFormat \"address\".*})
+ end
+ end
+
+ context 'with collectd_version >= 5.5' do
+ let :facts do
+ facts.merge(collectd_version: '5.5.0')
+ end
+
+ it 'is included' do
+ is_expected.to contain_file('virt.load').
+ with_content(%r{.*InterfaceFormat \"address\".*})
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_write_kafka_spec.rb b/spec/classes/collectd_plugin_write_kafka_spec.rb
index 33647c572..5614a03a5 100644
--- a/spec/classes/collectd_plugin_write_kafka_spec.rb
+++ b/spec/classes/collectd_plugin_write_kafka_spec.rb
@@ -1,46 +1,49 @@
require 'spec_helper'
describe 'collectd::plugin::write_kafka', type: :class do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '5.5.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 and :kafka_host => \'myhost\'' do
- let :params do
- { kafka_host: 'myhost', kafka_port: '9092', topics: { 'my-topic' => { 'format' => 'JSON' } } }
- end
+ options = os_specific_options(facts)
+ context ':ensure => present and :kafka_host => \'myhost\'' do
+ let :params do
+ { kafka_host: 'myhost', kafka_port: '9092', topics: { 'my-topic' => { 'format' => 'JSON' } } }
+ end
- it 'Will create /etc/collectd/conf.d/10-write_kafka.conf' do
- is_expected.to contain_file('write_kafka.load').with(ensure: 'present')
- is_expected.to contain_file('write_kafka.load').with(path: '/etc/collectd/conf.d/10-write_kafka.conf')
- is_expected.to contain_file('write_kafka.load').with(content: %r{Property "metadata.broker.list" "myhost:9092"})
- is_expected.to contain_file('write_kafka.load').with(content: %r{Topic "my-topic"})
- is_expected.to contain_file('write_kafka.load').with(content: %r{Format "JSON"})
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/10-write_kafka.conf" do
+ is_expected.to contain_file('write_kafka.load').with(ensure: 'present')
+ is_expected.to contain_file('write_kafka.load').with(path: "#{options[:plugin_conf_dir]}/10-write_kafka.conf")
+ is_expected.to contain_file('write_kafka.load').with(content: %r{Property "metadata.broker.list" "myhost:9092"})
+ is_expected.to contain_file('write_kafka.load').with(content: %r{Topic "my-topic"})
+ is_expected.to contain_file('write_kafka.load').with(content: %r{Format "JSON"})
+ end
+ end
- context ':ensure => absent' do
- let :params do
- { kafka_host: ['myhost'], ensure: 'absent' }
- end
+ context ':ensure => absent' do
+ let :params do
+ { kafka_host: ['myhost'], ensure: 'absent' }
+ end
- it 'Will not create /etc/collectd/conf.d/10-write_kafka.conf' do
- is_expected.to contain_file('write_kafka.load').with(ensure: 'absent', path: '/etc/collectd/conf.d/10-write_kafka.conf')
- end
- end
+ it "Will not create #{options[:plugin_conf_dir]}/10-write_kafka.conf" do
+ is_expected.to contain_file('write_kafka.load').with(
+ ensure: 'absent',
+ path: "#{options[:plugin_conf_dir]}/10-write_kafka.conf"
+ )
+ end
+ end
- context ':topics is a hash' do
- let :params do
- { topics: %w[test] }
- end
+ context ':topics is a hash' do
+ let :params do
+ { topics: %w[test] }
+ end
- it 'Will raise an error about :topics being an Array' do
- is_expected.to compile.and_raise_error(%r{Array})
+ it 'Will raise an error about :topics being an Array' do
+ is_expected.to compile.and_raise_error(%r{Array})
+ end
+ end
end
end
end
diff --git a/spec/classes/collectd_plugin_write_tsdb_spec.rb b/spec/classes/collectd_plugin_write_tsdb_spec.rb
index 4859a3300..9f5f40a66 100644
--- a/spec/classes/collectd_plugin_write_tsdb_spec.rb
+++ b/spec/classes/collectd_plugin_write_tsdb_spec.rb
@@ -1,49 +1,35 @@
require 'spec_helper'
describe 'collectd::plugin::write_tsdb', type: :class do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '5.5.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: 'Debian',
- collectd_version: '5.5.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
+ options = os_specific_options(facts)
+ context 'ensure: present, default params' do
+ it "Will create #{options[:plugin_conf_dir]}/10-write_tsdb.conf" do
+ is_expected.to contain_file('write_tsdb.load').with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/10-write_tsdb.conf",
+ content: %r{LoadPlugin write_tsdb}
+ )
+ end
+ end
- it 'Will create /etc/collectd/conf.d/10-write_tsdb.conf' do
- is_expected.to contain_file('write_tsdb.load').with(ensure: 'present',
- path: '/etc/collectd/conf.d/10-write_tsdb.conf',
- content: %r{LoadPlugin write_tsdb})
- end
- end
-
- context 'ensure: absent' do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '5.5.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
- let :params do
- { ensure: 'absent' }
- end
+ context 'ensure: absent' do
+ let :params do
+ { ensure: 'absent' }
+ end
- it 'Will not create /etc/collectd/conf.d/10-write_tsdb.conf' do
- is_expected.to contain_file('write_tsdb.load').
- with(ensure: 'absent',
- path: '/etc/collectd/conf.d/10-write_tsdb.conf')
+ it "Will not create #{options[:plugin_conf_dir]}/10-write_tsdb.conf" do
+ is_expected.to contain_file('write_tsdb.load').with(
+ ensure: 'absent',
+ path: "#{options[:plugin_conf_dir]}/10-write_tsdb.conf"
+ )
+ end
+ end
end
end
end
diff --git a/spec/defines/collectd_plugin_filecount_directory_spec.rb b/spec/defines/collectd_plugin_filecount_directory_spec.rb
index 59e7b86c8..542fa2da5 100644
--- a/spec/defines/collectd_plugin_filecount_directory_spec.rb
+++ b/spec/defines/collectd_plugin_filecount_directory_spec.rb
@@ -1,72 +1,80 @@
require 'spec_helper'
describe 'collectd::plugin::filecount::directory', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- 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 'simple case' do
- let(:title) { 'test' }
- let :params do
- {
- path: '/var/tmp/test'
- }
- end
+ options = os_specific_options(facts)
+ context 'simple case' do
+ let(:title) { 'test' }
+ let :params do
+ {
+ path: '/var/tmp/test'
+ }
+ end
- it 'Will create /etc/collectd/conf.d/15-filecount-test.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/15-filecount-test.conf').with_content("\n \n Instance \"test\"\n \n\n")
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/15-filecount-test.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/15-filecount-test.conf").with_content(
+ "\n \n Instance \"test\"\n \n\n"
+ )
+ end
+ end
- context 'advanced case' do
- let(:title) { 'test' }
- let :params do
- {
- path: '/path/to/dir',
- pattern: '*.conf',
- mtime: '-5m',
- recursive: true,
- includehidden: false
- }
- end
+ context 'advanced case' do
+ let(:title) { 'test' }
+ let :params do
+ {
+ path: '/path/to/dir',
+ pattern: '*.conf',
+ mtime: '-5m',
+ recursive: true,
+ includehidden: false
+ }
+ end
- it 'Will create /etc/collectd/conf.d/15-filecount-test.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/15-filecount-test.conf').with_content("\n \n Instance \"test\"\n Name \"*.conf\"\n MTime \"-5m\"\n Recursive true\n IncludeHidden false\n \n\n")
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/15-filecount-test.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/15-filecount-test.conf").with_content(
+ "\n \n Instance \"test\"\n Name \"*.conf\"\n MTime \"-5m\"\n Recursive true\n IncludeHidden false\n \n\n"
+ )
+ end
+ end
- context 'recursive and includehidden false' do
- let(:title) { 'test' }
- let :params do
- {
- path: '/var/tmp/test',
- recursive: false,
- includehidden: false
- }
- end
+ context 'recursive and includehidden false' do
+ let(:title) { 'test' }
+ let :params do
+ {
+ path: '/var/tmp/test',
+ recursive: false,
+ includehidden: false
+ }
+ end
- it 'Will create /etc/collectd/conf.d/15-filecount-test.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/15-filecount-test.conf').with_content("\n \n Instance \"test\"\n Recursive false\n IncludeHidden false\n \n\n")
- end
- end
+ it "Will create #{options[:plugin_conf_dir]}/15-filecount-test.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/15-filecount-test.conf").with_content(
+ "\n \n Instance \"test\"\n Recursive false\n IncludeHidden false\n \n\n"
+ )
+ end
+ end
- context 'ensure => absent' do
- let(:title) { 'test' }
- let :params do
- {
- ensure: 'absent',
- path: '/var/tmp/test'
- }
- end
+ context 'ensure => absent' do
+ let(:title) { 'test' }
+ let :params do
+ {
+ ensure: 'absent',
+ path: '/var/tmp/test'
+ }
+ end
- it 'Will create /etc/collectd/conf.d/15-filecount-test.conf' do
- is_expected.to contain_file('/etc/collectd/conf.d/15-filecount-test.conf').with(ensure: 'absent',
- path: '/etc/collectd/conf.d/15-filecount-test.conf')
+ it "Will create #{options[:plugin_conf_dir]}/15-filecount-test.conf" do
+ is_expected.to contain_file("#{options[:plugin_conf_dir]}/15-filecount-test.conf").with(
+ ensure: 'absent',
+ path: "#{options[:plugin_conf_dir]}/15-filecount-test.conf"
+ )
+ end
+ end
end
end
end
diff --git a/spec/defines/collectd_plugin_filter_chain_spec.rb b/spec/defines/collectd_plugin_filter_chain_spec.rb
index 51ba92b8a..6b0dc57ea 100644
--- a/spec/defines/collectd_plugin_filter_chain_spec.rb
+++ b/spec/defines/collectd_plugin_filter_chain_spec.rb
@@ -1,73 +1,70 @@
require 'spec_helper'
describe 'collectd::plugin::filter::chain', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- concat_basedir: '/dne',
- id: 'root',
- kernel: 'Linux',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '5.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
- context ':ensure => present and default parameters' do
- let(:title) { 'MyChain' }
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
+ end
- it 'Will create /etc/collectd/conf.d/filter-chain-MyChain.conf' do
- is_expected.to contain_concat('/etc/collectd/conf.d/filter-chain-MyChain.conf').with(ensure: 'present').
- that_requires('File[collectd.d]')
- is_expected.to contain_concat__fragment('/etc/collectd/conf.d/filter-chain-MyChain.conf_MyChain_head').with(
- order: '00',
- content: '',
- target: '/etc/collectd/conf.d/filter-chain-MyChain.conf'
- )
- is_expected.to contain_concat__fragment('/etc/collectd/conf.d/filter-chain-MyChain.conf_MyChain_footer').with(
- order: '99',
- content: '',
- target: '/etc/collectd/conf.d/filter-chain-MyChain.conf'
- )
- end
- it { is_expected.not_to contain_collectd__plugin__filter__target('z_chain-MyChain-target') }
- end
+ options = os_specific_options(facts)
+ context ':ensure => present and default parameters' do
+ let(:title) { 'MyChain' }
- context ':ensure => present and set a default target' do
- let(:title) { 'MyChain' }
- let(:params) do
- {
- target: 'set',
- target_options: {
- 'PluginInstance' => 'coretemp',
- 'TypeInstance' => 'core3'
- }
- }
- end
+ it "Will create #{options[:plugin_conf_dir]}/filter-chain-MyChain.conf" do
+ is_expected.to contain_concat("#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf").with(ensure: 'present').
+ that_requires('File[collectd.d]')
+ is_expected.to contain_concat__fragment("#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf_MyChain_head").with(
+ order: '00',
+ content: '',
+ target: "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf"
+ )
+ is_expected.to contain_concat__fragment("#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf_MyChain_footer").with(
+ order: '99',
+ content: '',
+ target: "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf"
+ )
+ end
+ it { is_expected.not_to contain_collectd__plugin__filter__target('z_chain-MyChain-target') }
+ end
- it 'Will add a default target with plugin set and options' do
- is_expected.to contain_collectd__plugin__filter__target('z_chain-MyChain-target').with(
- chain: 'MyChain',
- plugin: 'set',
- options: {
- 'PluginInstance' => 'coretemp',
- 'TypeInstance' => 'core3'
- }
- )
- end
- end
+ context ':ensure => present and set a default target' do
+ let(:title) { 'MyChain' }
+ let(:params) do
+ {
+ target: 'set',
+ target_options: {
+ 'PluginInstance' => 'coretemp',
+ 'TypeInstance' => 'core3'
+ }
+ }
+ end
- context ':ensure => absent' do
- let(:title) { 'MyChain' }
- let(:params) do
- {
- ensure: 'absent'
- }
- end
+ it 'Will add a default target with plugin set and options' do
+ is_expected.to contain_collectd__plugin__filter__target('z_chain-MyChain-target').with(
+ chain: 'MyChain',
+ plugin: 'set',
+ options: {
+ 'PluginInstance' => 'coretemp',
+ 'TypeInstance' => 'core3'
+ }
+ )
+ end
+ end
+
+ context ':ensure => absent' do
+ let(:title) { 'MyChain' }
+ let(:params) do
+ {
+ ensure: 'absent'
+ }
+ end
- it 'Will remove file /etc/collectd/conf.d/filter-chain-MyChain.conf' do
- is_expected.to contain_concat('/etc/collectd/conf.d/filter-chain-MyChain.conf').with(ensure: 'absent')
+ it "Will remove file #{options[:plugin_conf_dir]}/filter-chain-MyChain.conf" do
+ is_expected.to contain_concat("#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf").with(ensure: 'absent')
+ end
+ end
end
end
end
diff --git a/spec/defines/collectd_plugin_filter_match_spec.rb b/spec/defines/collectd_plugin_filter_match_spec.rb
index 877c243db..2ad01adc8 100644
--- a/spec/defines/collectd_plugin_filter_match_spec.rb
+++ b/spec/defines/collectd_plugin_filter_match_spec.rb
@@ -1,62 +1,60 @@
require 'spec_helper'
describe 'collectd::plugin::filter::match', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- concat_basedir: '/dne',
- id: 'root',
- kernel: 'Linux',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '5.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
- let(:title) { 'MyMatch' }
- let(:default_params) { { chain: 'MyChain', rule: 'MyRule' } }
- let(:concat_fragment_target) { '/etc/collectd/conf.d/filter-chain-MyChain.conf' }
- let(:concat_fragment_order) { '10_MyRule_1_MyMatch' }
- let(:concat_fragment_name) { '/etc/collectd/conf.d/filter-chain-MyChain.conf_10_MyRule_1_MyMatch' }
+ options = os_specific_options(facts)
+ let(:title) { 'MyMatch' }
+ let(:default_params) { { chain: 'MyChain', rule: 'MyRule' } }
+ let(:concat_fragment_target) { "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf" }
+ let(:concat_fragment_order) { '10_MyRule_1_MyMatch' }
+ let(:concat_fragment_name) { "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf_10_MyRule_1_MyMatch" }
- context 'Add match regex to rule with options' do
- let(:params) do
- default_params.merge(plugin: 'regex',
- options: {
- 'Host' => 'customer[0-9]+',
- 'Plugin' => '^foobar$'
- })
- end
+ context 'Add match regex to rule with options' do
+ let(:params) do
+ default_params.merge(
+ plugin: 'regex',
+ options: {
+ 'Host' => 'customer[0-9]+',
+ 'Plugin' => '^foobar$'
+ }
+ )
+ end
- it 'Will ensure that plugin is loaded' do
- is_expected.to contain_collectd__plugin('match_regex').with(order: '02')
- end
- it 'Will add match to rule' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(
- order: concat_fragment_order,
- target: concat_fragment_target
- )
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{})
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Host "customer\[0-9\]\+"})
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Plugin "\^foobar\$"})
- end
- end
+ it 'Will ensure that plugin is loaded' do
+ is_expected.to contain_collectd__plugin('match_regex').with(order: '02')
+ end
+ it 'Will add match to rule' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ order: concat_fragment_order,
+ target: concat_fragment_target
+ )
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{})
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Host "customer\[0-9\]\+"})
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Plugin "\^foobar\$"})
+ end
+ end
- context 'Add match empty_counter to rule without options' do
- let(:params) do
- default_params.merge(plugin: 'empty_counter')
- end
+ context 'Add match empty_counter to rule without options' do
+ let(:params) do
+ default_params.merge(plugin: 'empty_counter')
+ end
- it 'Will ensure that plugin is loaded' do
- is_expected.to contain_collectd__plugin('match_empty_counter').with(order: '02')
- end
- it 'Will add match to rule' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(
- order: concat_fragment_order,
- target: concat_fragment_target
- )
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Match "empty_counter"})
+ it 'Will ensure that plugin is loaded' do
+ is_expected.to contain_collectd__plugin('match_empty_counter').with(order: '02')
+ end
+ it 'Will add match to rule' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ order: concat_fragment_order,
+ target: concat_fragment_target
+ )
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Match "empty_counter"})
+ end
+ end
end
end
end
diff --git a/spec/defines/collectd_plugin_filter_target_spec.rb b/spec/defines/collectd_plugin_filter_target_spec.rb
index 1b0c5e836..44f2c0286 100644
--- a/spec/defines/collectd_plugin_filter_target_spec.rb
+++ b/spec/defines/collectd_plugin_filter_target_spec.rb
@@ -1,65 +1,63 @@
require 'spec_helper'
describe 'collectd::plugin::filter::target', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- concat_basedir: '/dne',
- id: 'root',
- kernel: 'Linux',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '5.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
- let(:title) { 'MyTarget' }
- let(:default_params) { { chain: 'MyChain' } }
- let(:concat_fragment_target) { '/etc/collectd/conf.d/filter-chain-MyChain.conf' }
+ options = os_specific_options(facts)
+ let(:title) { 'MyTarget' }
+ let(:default_params) { { chain: 'MyChain' } }
+ let(:concat_fragment_target) { "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf" }
- context 'Add target set to rule with options' do
- let(:concat_fragment_order) { '10_MyRule_30_MyTarget' }
- let(:concat_fragment_name) { '/etc/collectd/conf.d/filter-chain-MyChain.conf_10_MyRule_30_MyTarget' }
- let(:params) do
- default_params.merge(plugin: 'set',
- rule: 'MyRule',
- options: {
- 'PluginInstance' => 'coretemp',
- 'TypeInstance' => 'core3'
- })
- end
+ context 'Add target set to rule with options' do
+ let(:concat_fragment_order) { '10_MyRule_30_MyTarget' }
+ let(:concat_fragment_name) { "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf_10_MyRule_30_MyTarget" }
+ let(:params) do
+ default_params.merge(
+ plugin: 'set',
+ rule: 'MyRule',
+ options: {
+ 'PluginInstance' => 'coretemp',
+ 'TypeInstance' => 'core3'
+ }
+ )
+ end
- it 'Will ensure that plugin is loaded' do
- is_expected.to contain_collectd__plugin('target_set').with(order: '02')
- end
- it 'Will add target to rule' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(
- order: concat_fragment_order,
- target: concat_fragment_target
- )
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{})
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{PluginInstance "coretemp"})
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{TypeInstance "core3"})
- end
- end
+ it 'Will ensure that plugin is loaded' do
+ is_expected.to contain_collectd__plugin('target_set').with(order: '02')
+ end
+ it 'Will add target to rule' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ order: concat_fragment_order,
+ target: concat_fragment_target
+ )
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{})
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{PluginInstance "coretemp"})
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{TypeInstance "core3"})
+ end
+ end
- context 'Add builtin target return without rule to chain' do
- let(:concat_fragment_order) { '20_50_MyTarget' }
- let(:concat_fragment_name) { '/etc/collectd/conf.d/filter-chain-MyChain.conf_20_50_MyTarget' }
- let(:params) do
- default_params.merge(plugin: 'return')
- end
+ context 'Add builtin target return without rule to chain' do
+ let(:concat_fragment_order) { '20_50_MyTarget' }
+ let(:concat_fragment_name) { "#{options[:plugin_conf_dir]}/filter-chain-MyChain.conf_20_50_MyTarget" }
+ let(:params) do
+ default_params.merge(plugin: 'return')
+ end
- it 'Builtin plugin should not be tried to load' do
- is_expected.not_to contain_collectd__plugin('target_return')
- end
- it 'Will add target to chain' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(
- order: concat_fragment_order,
- target: concat_fragment_target
- )
- is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Target "return"})
+ it 'Builtin plugin should not be tried to load' do
+ is_expected.not_to contain_collectd__plugin('target_return')
+ end
+ it 'Will add target to chain' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ order: concat_fragment_order,
+ target: concat_fragment_target
+ )
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(content: %r{Target "return"})
+ end
+ end
end
end
end
diff --git a/spec/defines/collectd_plugin_genericjmx_connection_spec.rb b/spec/defines/collectd_plugin_genericjmx_connection_spec.rb
index d7bd8ac55..ad1337c4a 100644
--- a/spec/defines/collectd_plugin_genericjmx_connection_spec.rb
+++ b/spec/defines/collectd_plugin_genericjmx_connection_spec.rb
@@ -1,94 +1,99 @@
require 'spec_helper'
describe 'collectd::plugin::genericjmx::connection', type: :define do
- let(:facts) do
- {
- osfamily: 'Debian',
- id: 'root',
- concat_basedir: '/dne',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '4.8.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
-
- let(:config_filename) { '/etc/collectd/conf.d/15-genericjmx.conf' }
-
- let(:default_params) do
- {
- service_url: 'foo:bar:baz'
- }
- end
-
- let(:title) { 'foo.example.com' }
- let(:concat_fragment_name) { 'collectd_plugin_genericjmx_conf_foo.example.com' }
-
- context 'required params' do
- let(:params) do
- default_params.merge(collect: [])
- end
-
- it 'provides a Connection concat fragment' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(target: config_filename,
- order: '20')
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
+ end
+
+ options = os_specific_options(facts)
+ let(:config_filename) { "#{options[:plugin_conf_dir]}/15-genericjmx.conf" }
+
+ let(:default_params) do
+ {
+ service_url: 'foo:bar:baz'
+ }
+ end
+
+ let(:title) { 'foo.example.com' }
+ let(:concat_fragment_name) { 'collectd_plugin_genericjmx_conf_foo.example.com' }
+
+ context 'required params' do
+ let(:params) do
+ default_params.merge(collect: [])
+ end
+
+ it 'provides a Connection concat fragment' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ target: config_filename,
+ order: '20'
+ )
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{.*}m) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{ServiceURL "foo:bar:baz"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{User}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{Password}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
+ end
+
+ context 'hostname override' do
+ let(:params) do
+ default_params.merge(host: 'bar.example.com',
+ collect: [])
+ end
+
+ it 'provides a Connection concat fragment' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ target: config_filename,
+ order: '20'
+ )
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Host "bar\.example\.com"}) }
+ end
+
+ context 'collect array' do
+ let(:params) do
+ default_params.merge(collect: %w[foo bar baz])
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Collect "foo".*Collect "bar".*Collect "baz"}m) }
+ end
+
+ context 'collect string' do
+ let(:params) do
+ default_params.merge(collect: 'bat')
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Collect "bat"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*Collect.*){2,}}m) }
+ end
+
+ context 'username and password' do
+ let(:params) do
+ default_params.merge(
+ user: 'alice',
+ password: 'aoeuhtns',
+ collect: []
+ )
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{User "alice"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Password "aoeuhtns"}) }
+ end
+
+ context 'instance_prefix ' do
+ let(:params) do
+ default_params.merge(
+ instance_prefix: 'bat',
+ collect: []
+ )
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstancePrefix "bat"}) }
+ end
end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{.*}m) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{ServiceURL "foo:bar:baz"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{User}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{Password}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
- end
-
- context 'hostname override' do
- let(:params) do
- default_params.merge(host: 'bar.example.com',
- collect: [])
- end
-
- it 'provides a Connection concat fragment' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(target: config_filename,
- order: '20')
- end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Host "bar\.example\.com"}) }
- end
-
- context 'collect array' do
- let(:params) do
- default_params.merge(collect: %w[foo bar baz])
- end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Collect "foo".*Collect "bar".*Collect "baz"}m) }
- end
-
- context 'collect string' do
- let(:params) do
- default_params.merge(collect: 'bat')
- end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Collect "bat"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*Collect.*){2,}}m) }
- end
-
- context 'username and password' do
- let(:params) do
- default_params.merge(user: 'alice',
- password: 'aoeuhtns',
- collect: [])
- end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{User "alice"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Password "aoeuhtns"}) }
- end
-
- context 'instance_prefix ' do
- let(:params) do
- default_params.merge(instance_prefix: 'bat',
- collect: [])
- end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstancePrefix "bat"}) }
end
end
diff --git a/spec/defines/collectd_plugin_genericjmx_mbean_spec.rb b/spec/defines/collectd_plugin_genericjmx_mbean_spec.rb
index ef121a367..359a133c2 100644
--- a/spec/defines/collectd_plugin_genericjmx_mbean_spec.rb
+++ b/spec/defines/collectd_plugin_genericjmx_mbean_spec.rb
@@ -1,174 +1,171 @@
require 'spec_helper'
describe 'collectd::plugin::genericjmx::mbean', type: :define do
- let(:facts) do
- {
- osfamily: 'Debian',
- id: 'root',
- concat_basedir: '/dne',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- collectd_version: '4.8.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
-
- let(:config_filename) { '/etc/collectd/conf.d/15-genericjmx.conf' }
-
- let(:default_params) do
- {
- object_name: 'bar',
- values: []
- }
- end
-
- let(:title) { 'foo' }
- let(:concat_fragment_name) { 'collectd_plugin_genericjmx_conf_foo' }
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
+ end
+ options = os_specific_options(facts)
- # empty values array is technically not valid, but we'll test those cases later
- context 'defaults' do
- let(:params) { default_params }
+ let(:config_filename) { "#{options[:plugin_conf_dir]}/15-genericjmx.conf" }
- it 'provides an MBean stanza concat fragment' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with(
- target: config_filename,
- order: '10'
- )
- end
+ let(:default_params) do
+ {
+ object_name: 'bar',
+ values: []
+ }
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{\s+ObjectName "bar".+}m) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstanceFrom}) }
- end
+ let(:title) { 'foo' }
+ let(:concat_fragment_name) { 'collectd_plugin_genericjmx_conf_foo' }
- context 'instance_prefix set' do
- let(:params) do
- default_params.merge(instance_prefix: 'baz')
- end
+ # empty values array is technically not valid, but we'll test those cases later
+ context 'defaults' do
+ let(:params) { default_params }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstancePrefix "baz"}) }
- end
+ it 'provides an MBean stanza concat fragment' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with(
+ target: config_filename,
+ order: '10'
+ )
+ end
- context 'instance_from array' do
- let(:params) do
- default_params.merge(instance_from: %w[foo bar baz])
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{\s+ObjectName "bar".+}m) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstanceFrom}) }
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "foo"\s+InstanceFrom "bar"\s+InstanceFrom "baz"}) }
- end
+ context 'instance_prefix set' do
+ let(:params) do
+ default_params.merge(instance_prefix: 'baz')
+ end
- context 'instance_from string' do
- let(:params) do
- default_params.merge(instance_from: 'bat')
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstancePrefix "baz"}) }
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "bat"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*InstanceFrom.*){2,}}) }
- end
- context 'with default_values_args' do
- let(:default_values_args) do
- {
- 'mbean_type' => 'foo',
- 'attribute' => 'bar'
- }
- end
+ context 'instance_from array' do
+ let(:params) do
+ default_params.merge(instance_from: %w[foo bar baz])
+ end
- # testing the Value template section is going to be messy
- context 'value section defaults' do
- let(:params) do
- default_params.merge(values: [default_values_args])
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "foo"\s+InstanceFrom "bar"\s+InstanceFrom "baz"}) }
end
- it 'has a value stanza' do
- is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{.*}m)
- end
+ context 'instance_from string' do
+ let(:params) do
+ default_params.merge(instance_from: 'bat')
+ end
- it 'has only one value stanza' do
- is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*.*){2,}})
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "bat"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*InstanceFrom.*){2,}}) }
end
+ context 'with default_values_args' do
+ let(:default_values_args) do
+ {
+ 'mbean_type' => 'foo',
+ 'attribute' => 'bar'
+ }
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Type "foo"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Table false}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "bar"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstanceFrom}) }
- end
+ # testing the Value template section is going to be messy
+ context 'value section defaults' do
+ let(:params) do
+ default_params.merge(values: [default_values_args])
+ end
+
+ it 'has a value stanza' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{.*}m)
+ end
+
+ it 'has only one value stanza' do
+ is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*.*){2,}})
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Type "foo"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Table false}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "bar"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstanceFrom}) }
+ end
- context 'value section instance_prefix set' do
- let(:params) do
- default_params.merge(values: [default_values_args.merge('instance_prefix' => 'baz')])
- end
+ context 'value section instance_prefix set' do
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('instance_prefix' => 'baz')])
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstancePrefix "baz"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstanceFrom}) }
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstancePrefix "baz"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstanceFrom}) }
+ end
- context 'value section instance_from array' do
- let(:params) do
- default_params.merge(values: [default_values_args.merge('instance_from' => %w[alice bob carol])])
- end
+ context 'value section instance_from array' do
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('instance_from' => %w[alice bob carol])])
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "alice"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "bob"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "carol"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "alice"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "bob"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "carol"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
+ end
- context 'value section instance_from string' do
- let(:params) do
- default_params.merge(values: [default_values_args.merge('instance_from' => 'dave')])
- end
+ context 'value section instance_from string' do
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('instance_from' => 'dave')])
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "dave"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*InstancePrefix.*){2,}}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{InstanceFrom "dave"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*InstancePrefix.*){2,}}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{InstancePrefix}) }
+ end
- context 'value section attribute array' do
- let(:params) do
- default_params.merge(values: [default_values_args.merge('attribute' => %w[alice bob carol])])
- end
+ context 'value section attribute array' do
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('attribute' => %w[alice bob carol])])
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "alice"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "bob"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "carol"}) }
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "alice"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "bob"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "carol"}) }
+ end
- context 'value section attribute string' do
- let(:params) do
- default_params.merge(values: [default_values_args.merge('attribute' => 'dave')])
- end
+ context 'value section attribute string' do
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('attribute' => 'dave')])
+ end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "dave"}) }
- it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*Attribute.*){2,}}) }
- end
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Attribute "dave"}) }
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).without_content(%r{(.*Attribute.*){2,}}) }
+ end
- context 'value section table true-like' do
- ['true', true].each do |truthy|
- let(:params) do
- default_params.merge(values: [default_values_args.merge('table' => truthy)])
+ context 'value section table true-like' do
+ ['true', true].each do |truthy|
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('table' => truthy)])
+ end
+
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Table true}) }
+ end
end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Table true}) }
- end
- end
+ context 'value section table false-like' do
+ ['false', false].each do |truthy|
+ let(:params) do
+ default_params.merge(values: [default_values_args.merge('table' => truthy)])
+ end
- context 'value section table false-like' do
- ['false', false].each do |truthy|
- let(:params) do
- default_params.merge(values: [default_values_args.merge('table' => truthy)])
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Table false}) }
+ end
end
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{Table false}) }
- end
- end
+ context 'multiple values' do
+ let(:params) do
+ default_params.merge(values: [default_values_args, default_values_args])
+ end
- context 'multiple values' do
- let(:params) do
- default_params.merge(values: [default_values_args, default_values_args])
+ it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{(.*.*.*){2}}m) }
+ end
end
-
- it { is_expected.to contain_concat__fragment(concat_fragment_name).with_content(%r{(.*.*.*){2}}m) }
end
end
end
diff --git a/spec/defines/collectd_plugin_snmp_data_spec.rb b/spec/defines/collectd_plugin_snmp_data_spec.rb
index 0ae8ba4c9..22754ded7 100644
--- a/spec/defines/collectd_plugin_snmp_data_spec.rb
+++ b/spec/defines/collectd_plugin_snmp_data_spec.rb
@@ -1,112 +1,114 @@
require 'spec_helper'
describe 'collectd::plugin::snmp::data', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '4.8.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
-
- let(:title) { 'foo' }
- let(:required_params) do
- {
- type: 'bar',
- instance: 'baz',
- values: 'bat'
- }
- end
-
- let(:filename) { 'snmp-data-foo.conf' }
-
- context 'required params' do
- let(:params) { required_params }
-
- it do
- is_expected.to contain_file(filename).with(
- ensure: 'present',
- path: '/etc/collectd/conf.d/15-snmp-data-foo.conf'
- )
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').that_notifies('Service[collectd]') }
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{}) }
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{}) }
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Type "bar"}) }
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Instance "baz"}) }
- end
-
- context 'values is an array' do
- let(:params) do
- required_params.merge(values: %w[foo bar baz])
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
+ end
+
+ options = os_specific_options(facts)
+
+ let(:title) { 'foo' }
+
+ let(:required_params) do
+ {
+ type: 'bar',
+ instance: 'baz',
+ values: 'bat'
+ }
+ end
+
+ let(:filename) { 'snmp-data-foo.conf' }
+
+ context 'required params' do
+ let(:params) { required_params }
+
+ it do
+ is_expected.to contain_file(filename).with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/15-snmp-data-foo.conf"
+ )
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').that_notifies('Service[collectd]') }
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{}) }
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{}) }
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Type "bar"}) }
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Instance "baz"}) }
+ end
+
+ context 'values is an array' do
+ let(:params) do
+ required_params.merge(values: %w[foo bar baz])
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Values "foo" "bar" "baz"}) }
+ end
+
+ context 'values is just a string' do
+ let(:params) do
+ required_params.merge(values: 'bat')
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Values "bat"}) }
+ end
+
+ context 'Ignore is an array' do
+ let(:params) do
+ required_params.merge(ignore: %w[hamilton burr jefferson])
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Ignore "hamilton" "burr" "jefferson"}) }
+ end
+
+ context 'Ignore is just a string' do
+ let(:params) do
+ required_params.merge(ignore: 'washington')
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Ignore "washington"}) }
+ end
+
+ context 'table is true' do
+ let(:params) do
+ {
+ table: true
+ }.merge(required_params)
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Table true}) }
+ end
+
+ context 'table is false' do
+ let(:params) do
+ {
+ table: false
+ }.merge(required_params)
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Table false}) }
+ end
+
+ context 'InvertMatch is true' do
+ let(:params) do
+ {
+ invertmatch: true
+ }.merge(required_params)
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{InvertMatch true}) }
+ end
+
+ context 'InvertMatch is false' do
+ let(:params) do
+ {
+ invertmatch: false
+ }.merge(required_params)
+ end
+
+ it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{InvertMatch false}) }
+ end
end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Values "foo" "bar" "baz"}) }
- end
-
- context 'values is just a string' do
- let(:params) do
- required_params.merge(values: 'bat')
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Values "bat"}) }
- end
-
- context 'Ignore is an array' do
- let(:params) do
- required_params.merge(ignore: %w[hamilton burr jefferson])
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Ignore "hamilton" "burr" "jefferson"}) }
- end
-
- context 'Ignore is just a string' do
- let(:params) do
- required_params.merge(ignore: 'washington')
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Ignore "washington"}) }
- end
-
- context 'table is true' do
- let(:params) do
- {
- table: true
- }.merge(required_params)
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Table true}) }
- end
-
- context 'table is false' do
- let(:params) do
- {
- table: false
- }.merge(required_params)
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{Table false}) }
- end
-
- context 'InvertMatch is true' do
- let(:params) do
- {
- invertmatch: true
- }.merge(required_params)
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{InvertMatch true}) }
- end
-
- context 'InvertMatch is false' do
- let(:params) do
- {
- invertmatch: false
- }.merge(required_params)
- end
-
- it { is_expected.to contain_file('snmp-data-foo.conf').with_content(%r{InvertMatch false}) }
end
end
diff --git a/spec/defines/collectd_plugin_snmp_host_spec.rb b/spec/defines/collectd_plugin_snmp_host_spec.rb
index d6314644e..596a1ca1b 100644
--- a/spec/defines/collectd_plugin_snmp_host_spec.rb
+++ b/spec/defines/collectd_plugin_snmp_host_spec.rb
@@ -1,74 +1,74 @@
require 'spec_helper'
describe 'collectd::plugin::snmp::host', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- 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
- let(:title) { 'foo.example.com' }
- let(:required_params) do
- {
- collect: 'foo'
- }
- end
+ options = os_specific_options(facts)
+ let(:title) { 'foo.example.com' }
+ let(:required_params) do
+ {
+ collect: 'foo'
+ }
+ end
- let(:filename) { 'snmp-host-foo.example.com.conf' }
+ let(:filename) { 'snmp-host-foo.example.com.conf' }
- context 'default params' do
- let(:params) { required_params }
+ context 'default params' do
+ let(:params) { required_params }
- it do
- is_expected.to contain_file(filename).with(
- ensure: 'present',
- path: '/etc/collectd/conf.d/25-snmp-host-foo.example.com.conf'
- )
- end
+ it do
+ is_expected.to contain_file(filename).with(
+ ensure: 'present',
+ path: "#{options[:plugin_conf_dir]}/25-snmp-host-foo.example.com.conf"
+ )
+ end
- it { is_expected.to contain_file(filename).that_notifies('Service[collectd]') }
- it { is_expected.to contain_file(filename).with_content(%r{}) }
- it { is_expected.to contain_file(filename).with_content(%r{}) }
- it { is_expected.to contain_file(filename).with_content(%r{Address "foo\.example\.com"}) }
- it { is_expected.to contain_file(filename).with_content(%r{Version 1}) }
- it { is_expected.to contain_file(filename).with_content(%r{Community "public"}) }
- it { is_expected.to contain_file(filename).without_content(%r{Interval \d+}) }
- end
+ it { is_expected.to contain_file(filename).that_notifies('Service[collectd]') }
+ it { is_expected.to contain_file(filename).with_content(%r{}) }
+ it { is_expected.to contain_file(filename).with_content(%r{}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Address "foo\.example\.com"}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Version 1}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Community "public"}) }
+ it { is_expected.to contain_file(filename).without_content(%r{Interval \d+}) }
+ end
- context 'all params set' do
- let(:params) do
- required_params.merge(address: 'bar.example.com',
- version: '2',
- community: 'opensesame',
- interval: '30')
- end
+ context 'all params set' do
+ let(:params) do
+ required_params.merge(address: 'bar.example.com',
+ version: '2',
+ community: 'opensesame',
+ interval: '30')
+ end
- it { is_expected.to contain_file(filename).with_content(%r{Address "bar\.example\.com"}) }
- it { is_expected.to contain_file(filename).with_content(%r{Version 2}) }
- it { is_expected.to contain_file(filename).with_content(%r{Community "opensesame"}) }
- it { is_expected.to contain_file(filename).with_content(%r{Interval 30}) }
- end
+ it { is_expected.to contain_file(filename).with_content(%r{Address "bar\.example\.com"}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Version 2}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Community "opensesame"}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Interval 30}) }
+ end
- context 'collect is an array' do
- let(:params) do
- {
- collect: %w[foo bar baz]
- }
- end
+ context 'collect is an array' do
+ let(:params) do
+ {
+ collect: %w[foo bar baz]
+ }
+ end
- it { is_expected.to contain_file(filename).with_content(%r{Collect "foo" "bar" "baz"}) }
- end
+ it { is_expected.to contain_file(filename).with_content(%r{Collect "foo" "bar" "baz"}) }
+ end
- context 'collect is just a string' do
- let(:params) do
- {
- collect: 'bat'
- }
- end
+ context 'collect is just a string' do
+ let(:params) do
+ {
+ collect: 'bat'
+ }
+ end
- it { is_expected.to contain_file(filename).with_content(%r{Collect "bat"}) }
+ it { is_expected.to contain_file(filename).with_content(%r{Collect "bat"}) }
+ end
+ end
end
end
diff --git a/spec/defines/collectd_plugin_tail_file_spec.rb b/spec/defines/collectd_plugin_tail_file_spec.rb
index b83aeb794..ff15d72ef 100644
--- a/spec/defines/collectd_plugin_tail_file_spec.rb
+++ b/spec/defines/collectd_plugin_tail_file_spec.rb
@@ -1,102 +1,102 @@
require 'spec_helper'
describe 'collectd::plugin::tail::file', type: :define do
- let :pre_condition do
- 'include ::collectd'
- end
+ on_supported_os.each do |os, facts|
+ context "on #{os} " do
+ let :facts do
+ facts
+ end
- let :facts do
- {
- osfamily: 'Debian',
- collectd_version: '4.8.0',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
+ options = os_specific_options(facts)
+ let :pre_condition do
+ 'include ::collectd'
+ end
- context 'Example from README' do
- let(:title) { 'exim-log' }
- let :params do
- {
- filename: '/var/log/exim4/mainlog',
- instance: 'exim',
- matches: [
- {
- 'regex' => 'S=([1-9][0-9]*)',
- 'dstype' => 'CounterAdd',
- 'type' => 'ipt_bytes',
- 'instance' => 'total'
- },
+ context 'Example from README' do
+ let(:title) { 'exim-log' }
+ let :params do
{
- 'regex' => '\\',
- 'dstype' => 'CounterInc',
- 'type' => 'counter',
- 'instance' => 'local_user'
+ filename: '/var/log/exim4/mainlog',
+ instance: 'exim',
+ matches: [
+ {
+ 'regex' => 'S=([1-9][0-9]*)',
+ 'dstype' => 'CounterAdd',
+ 'type' => 'ipt_bytes',
+ 'instance' => 'total'
+ },
+ {
+ 'regex' => '\\',
+ 'dstype' => 'CounterInc',
+ 'type' => 'counter',
+ 'instance' => 'local_user'
+ }
+ ]
}
- ]
- }
- end
+ end
- describe '/etc/collectd/conf.d/tail-exim-log.conf' do
- it 'Will create /etc/collectd/conf.d/tail-exim-log.conf' do
- is_expected.to contain_file('exim-log.conf').with(
- 'ensure' => 'present',
- 'path' => '/etc/collectd/conf.d/tail-exim-log.conf'
- ).that_notifies('Service[collectd]')
+ describe "#{options[:plugin_conf_dir]}/tail-exim-log.conf" do
+ it "Will create #{options[:plugin_conf_dir]}/tail-exim-log.conf" do
+ is_expected.to contain_file('exim-log.conf').with(
+ 'ensure' => 'present',
+ 'path' => "#{options[:plugin_conf_dir]}/tail-exim-log.conf"
+ ).that_notifies('Service[collectd]')
+ end
+ it "renders #{options[:plugin_conf_dir]}/tail-exim-log.conf correctly" do
+ content = catalogue.resource('file', 'exim-log.conf').send(:parameters)[:content]
+ expected_content = %(# Generated by Puppet\n)
+ expected_content += %(\n)
+ expected_content += %(\n)
+ expected_content += %( \n)
+ expected_content += %( Instance "exim"\n)
+ expected_content += %( \n)
+ expected_content += %( Regex "S=([1-9][0-9]*)"\n)
+ expected_content += %( DSType "CounterAdd"\n)
+ expected_content += %( Type "ipt_bytes"\n)
+ expected_content += %( Instance "total"\n)
+ expected_content += %( \n)
+ expected_content += %( \n)
+ expected_content += %( Regex "\\"\n)
+ expected_content += %( DSType "CounterInc"\n)
+ expected_content += %( Type "counter"\n)
+ expected_content += %( Instance "local_user"\n)
+ expected_content += %( \n)
+ expected_content += %( \n)
+ expected_content += %()
+ expect(content).to include(expected_content)
+ end
+ end
end
- it 'renders /etc/collectd/conf.d/tail-exim-log.conf correctly' do
- content = catalogue.resource('file', 'exim-log.conf').send(:parameters)[:content]
- expected_content = %(# Generated by Puppet\n)
- expected_content += %(\n)
- expected_content += %(\n)
- expected_content += %( \n)
- expected_content += %( Instance "exim"\n)
- expected_content += %( \n)
- expected_content += %( Regex "S=([1-9][0-9]*)"\n)
- expected_content += %( DSType "CounterAdd"\n)
- expected_content += %( Type "ipt_bytes"\n)
- expected_content += %( Instance "total"\n)
- expected_content += %( \n)
- expected_content += %( \n)
- expected_content += %( Regex "\\"\n)
- expected_content += %( DSType "CounterInc"\n)
- expected_content += %( Type "counter"\n)
- expected_content += %( Instance "local_user"\n)
- expected_content += %( \n)
- expected_content += %( \n)
- expected_content += %()
- expect(content).to include(expected_content)
- end
- end
- end
- context "with match containing 'excluderegex'" do
- let(:title) { 'test' }
- let :params do
- {
- filename: '/var/log/exim4/mainlog',
- instance: 'exim',
- matches: [
+ context "with match containing 'excluderegex'" do
+ let(:title) { 'test' }
+ let :params do
{
- 'regex' => 'S=([1-9][0-9]*)',
- 'excluderegex' => 'U=root.*S=',
- 'dstype' => 'CounterAdd',
- 'type' => 'ipt_bytes',
- 'instance' => 'total'
+ filename: '/var/log/exim4/mainlog',
+ instance: 'exim',
+ matches: [
+ {
+ 'regex' => 'S=([1-9][0-9]*)',
+ 'excluderegex' => 'U=root.*S=',
+ 'dstype' => 'CounterAdd',
+ 'type' => 'ipt_bytes',
+ 'instance' => 'total'
+ }
+ ]
}
- ]
- }
- end
+ end
- it "templated file contains the 'ExcludeRegex' line" do
- content = catalogue.resource('file', 'test.conf').send(:parameters)[:content]
- expected_content = %( \n)
- expected_content += %( Regex "S=([1-9][0-9]*)"\n)
- expected_content += %( ExcludeRegex "U=root.*S="\n)
- expected_content += %( DSType "CounterAdd"\n)
- expected_content += %( Type "ipt_bytes"\n)
- expected_content += %( Instance "total"\n)
- expected_content += %( \n)
- expect(content).to include(expected_content)
+ it "templated file contains the 'ExcludeRegex' line" do
+ content = catalogue.resource('file', 'test.conf').send(:parameters)[:content]
+ expected_content = %( \n)
+ expected_content += %( Regex "S=([1-9][0-9]*)"\n)
+ expected_content += %( ExcludeRegex "U=root.*S="\n)
+ expected_content += %( DSType "CounterAdd"\n)
+ expected_content += %( Type "ipt_bytes"\n)
+ expected_content += %( Instance "total"\n)
+ expected_content += %( \n)
+ expect(content).to include(expected_content)
+ end
+ end
end
end
end
diff --git a/spec/defines/collectd_plugin_write_graphite_spec.rb b/spec/defines/collectd_plugin_write_graphite_spec.rb
index 61b8e4888..5dbf0bfef 100644
--- a/spec/defines/collectd_plugin_write_graphite_spec.rb
+++ b/spec/defines/collectd_plugin_write_graphite_spec.rb
@@ -1,81 +1,71 @@
require 'spec_helper'
describe 'collectd::plugin::write_graphite::carbon', type: :define do
- let :facts do
- {
- osfamily: 'Debian',
- id: 'root',
- concat_basedir: '/dne',
- path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
- 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 'protocol should not be include with version < 5.4' do
- let(:title) { 'graphite_udp' }
- let :facts do
- {
- osfamily: 'RedHat',
- collectd_version: '5.3',
- concat_basedir: '/dne',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
- let :params do
- {
- protocol: 'udp'
- }
- end
+ options = os_specific_options(facts)
- it 'does not include protocol in /etc/collectd.d/write_graphite.conf for collectd < 5.4' do
- is_expected.not_to contain_concat__fragment(
- 'collectd_plugin_write_graphite_conf_localhost_2003'
- ).with_content(%r{.*Protocol \"udp\".*})
- end
- end
+ context 'protocol should not be include with version < 5.4' do
+ let(:title) { 'graphite_udp' }
+ let :facts do
+ facts.merge(collectd_version: '5.3')
+ end
+ let :params do
+ {
+ protocol: 'udp'
+ }
+ end
- context 'protocol should be include with version >= 5.4' do
- let(:title) { 'wg' }
- let :facts do
- {
- osfamily: 'RedHat',
- collectd_version: '5.4',
- concat_basedir: '/dne',
- operatingsystemmajrelease: '7',
- python_dir: '/usr/local/lib/python2.7/dist-packages'
- }
- end
- let :params do
- {
- protocol: 'udp'
- }
- end
+ it "does not include protocol in #{options[:plugin_conf_dir]}/write_graphite.conf for collectd < 5.4" do
+ is_expected.not_to contain_concat__fragment('collectd_plugin_write_graphite_conf_localhost_2003').with_content(%r{.*Protocol \"udp\".*})
+ end
+ end
- it 'includes protocol in /etc/collectd.d/write_graphite.conf for collectd >= 5.4' do
- is_expected.to contain_concat__fragment(
- 'collectd_plugin_write_graphite_conf_wg_udp_2003'
- ).with_content(%r{.*Protocol \"udp\".*})
- end
+ context 'protocol should be include with version >= 5.4' do
+ let(:title) { 'wg' }
+ let :facts do
+ facts.merge(collectd_version: '5.4')
+ end
+ let :params do
+ {
+ protocol: 'udp'
+ }
+ end
- it 'uses Node definition' do
- is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_wg_udp_2003').with(content: %r{},
- target: '/etc/collectd.d/write_graphite-config.conf')
- end
- end
+ it "includes protocol in #{options[:plugin_conf_dir]}/write_graphite.conf for collectd >= 5.4" do
+ is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_wg_udp_2003').with_content(%r{.*Protocol \"udp\".*})
+ end
+
+ it 'uses Node definition' do
+ is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_wg_udp_2003').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/write_graphite-config.conf"
+ )
+ end
+ end
+
+ context 'default configuration (undefined collectd version)' do
+ let(:title) { 'graphite_default' }
- context 'default configuration (undefined collectd version)' do
- let(:title) { 'graphite_default' }
+ let :facts do
+ facts.merge(collectd_version: '5.2')
+ end
- it 'includes carbon configuration' do
- is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{},
- target: '/etc/collectd/conf.d/write_graphite-config.conf')
+ it 'includes carbon configuration' do
+ is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(
+ content: %r{},
+ target: "#{options[:plugin_conf_dir]}/write_graphite-config.conf"
+ )
+ end
- is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{Host "localhost"})
+ it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{Host "localhost"}) }
- is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{Port "2003"})
+ it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{Port "2003"}) }
+ end
end
end
end
diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb
index ab79a2180..bc3d5fb86 100644
--- a/spec/spec_helper_methods.rb
+++ b/spec/spec_helper_methods.rb
@@ -1,5 +1,5 @@
def os_specific_options(facts)
- case facts[:osfamily]
+ case facts[:os]['family']
when 'Gentoo'
{ package: 'app-admin/collectd', service: 'collectd', plugin_conf_dir: '/etc/collectd.d' }
when 'Solaris'