Skip to content

Commit

Permalink
fix write_graphite specs
Browse files Browse the repository at this point in the history
  • Loading branch information
deric committed Jul 4, 2015
1 parent 15125a9 commit 7ecf13d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,3 @@ DEPENDENCIES
rspec-puppet
serverspec
simplecov

BUNDLED WITH
1.10.3
2 changes: 1 addition & 1 deletion manifests/plugin/write_graphite/carbon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
validate_bool($separateinstances)
validate_bool($logsenderrors)

concat::fragment{"collectd_plugin_write_graphite_conf_${title}":
concat::fragment{"collectd_plugin_write_graphite_conf_${title}_${protocol}_${graphiteport}":
ensure => $ensure,
order => '50', # somewhere between header and footer
target => $collectd::plugin::write_graphite::graphite_conf,
Expand Down
10 changes: 4 additions & 6 deletions spec/classes/collectd_plugin_write_graphite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
}
end


context 'single carbon writer' do

let :params do
{
:carbons => { 'graphite_tcp' => {} },
:carbons => { 'graphite' => {} },
}
end

Expand All @@ -39,16 +37,16 @@
end

it 'includes carbon configuration' do
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp_2003').with({
:content => /<Carbon>/,
:target => '/etc/collectd/conf.d/write_graphite-config.conf',
})

should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp_2003').with({
:content => /Host "localhost"/,
})

should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp_2003').with({
:content => /Port "2003"/,
})
end
Expand Down
17 changes: 10 additions & 7 deletions spec/defines/collectd_plugin_write_graphite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let :facts do
{ :osfamily => 'RedHat',
:collectd_version => '5.3',
:concat_basedir => tmpfilename('collectd-graphite'),
}
end
let :params do
Expand All @@ -30,37 +31,39 @@
end

context 'protocol should be include with version >= 5.4' do
let(:title) { 'graphite_udp' }
let(:title) { 'wg' }
let :facts do
{ :osfamily => 'RedHat',
:collectd_version => '5.4',
:concat_basedir => tmpfilename('collectd-graphite'),
}
end
let :params do
{ :protocol => 'udp',
{
:protocol => 'udp',
}
end

it 'Should include protocol in /etc/collectd.d/write_graphite.conf for collectd >= 5.4' do
should contain_concat__fragment(
'collectd_plugin_write_graphite_conf_localhost_2003'
'collectd_plugin_write_graphite_conf_wg_udp_2003'
).with_content(/.*Protocol \"udp\".*/)
end
end

context 'default configuration' do
let(:title) { 'graphite_default' }

it 'includes carbon configuration' do
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with({
:content => /<Carbon>/,
:target => '/etc/collectd/conf.d/write_graphite-config.conf',
})

should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with({
:content => /Host "localhost"/,
})

should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with({
:content => /Port "2003"/,
})
end
Expand Down

0 comments on commit 7ecf13d

Please sign in to comment.