From 7ecf13de6766630da37eb9bb8ed15342af6d2cff Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Sat, 4 Jul 2015 12:47:23 +0200 Subject: [PATCH] fix write_graphite specs --- Gemfile.lock | 3 --- manifests/plugin/write_graphite/carbon.pp | 2 +- .../collectd_plugin_write_graphite_spec.rb | 10 ++++------ .../collectd_plugin_write_graphite_spec.rb | 17 ++++++++++------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f06159581..a6a1ba49d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -282,6 +282,3 @@ DEPENDENCIES rspec-puppet serverspec simplecov - -BUNDLED WITH - 1.10.3 diff --git a/manifests/plugin/write_graphite/carbon.pp b/manifests/plugin/write_graphite/carbon.pp index 94afa5f2b..78d46d2ad 100644 --- a/manifests/plugin/write_graphite/carbon.pp +++ b/manifests/plugin/write_graphite/carbon.pp @@ -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, diff --git a/spec/classes/collectd_plugin_write_graphite_spec.rb b/spec/classes/collectd_plugin_write_graphite_spec.rb index 134372d5b..5c1640b45 100644 --- a/spec/classes/collectd_plugin_write_graphite_spec.rb +++ b/spec/classes/collectd_plugin_write_graphite_spec.rb @@ -13,12 +13,10 @@ } end - context 'single carbon writer' do - let :params do { - :carbons => { 'graphite_tcp' => {} }, + :carbons => { 'graphite' => {} }, } end @@ -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 => //, :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 diff --git a/spec/defines/collectd_plugin_write_graphite_spec.rb b/spec/defines/collectd_plugin_write_graphite_spec.rb index da8baf4d5..f503faaf2 100644 --- a/spec/defines/collectd_plugin_write_graphite_spec.rb +++ b/spec/defines/collectd_plugin_write_graphite_spec.rb @@ -15,6 +15,7 @@ let :facts do { :osfamily => 'RedHat', :collectd_version => '5.3', + :concat_basedir => tmpfilename('collectd-graphite'), } end let :params do @@ -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 => //, :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