-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #805 from traylenator/pythonaccept
A collectd::plugin::python acceptance test
- Loading branch information
Showing
4 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'collectd::plugin::python class' do | ||
context 'basic parameters' do | ||
# Using puppet_apply as a helper | ||
it 'works idempotently with no errors' do | ||
pp = <<-EOS | ||
class{'collectd::plugin::python': | ||
} | ||
EOS | ||
# Run 3 times since the collectd_version | ||
# fact is impossible until collectd is | ||
# installed. This acceptance test happens | ||
# to be first. | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
|
||
describe service('collectd') do | ||
it { is_expected.to be_running } | ||
end | ||
end | ||
|
||
context 'trivial module' do | ||
it 'works idempotently with no errors' do | ||
pp = <<-EOS | ||
if $facts['os']['family'] == 'Debian' { | ||
# for collectdctl command | ||
package{'collectd-utils': | ||
ensure => present, | ||
} | ||
} | ||
package{'python-pip': | ||
ensure => present, | ||
} | ||
package{['collectd-connect-time']: | ||
ensure => 'present', | ||
provider => 'pip', | ||
require => Package['python-pip'], | ||
before => Service['collectd'], | ||
} | ||
class{'collectd::plugin::python': | ||
logtraces => true, | ||
interactive => false, | ||
modules => { | ||
'collectd_connect_time' => { | ||
config => [{'target' => 'google.de'}], | ||
}, | ||
}, | ||
} | ||
class{'collectd::plugin::unixsock': | ||
socketfile => '/var/run/collectd-sock', | ||
} | ||
EOS | ||
|
||
# Run it twice and test for idempotency | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
shell('sleep 10') | ||
end | ||
describe service('collectd') do | ||
it { is_expected.to be_running } | ||
end | ||
# Check metric is really there. | ||
describe command('collectdctl -s /var/run/collectd-sock listval') do | ||
its(:exit_status) { is_expected.to eq 0 } | ||
its(:stdout) { is_expected.to match %r{google.de} } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters