From 365c73dd5273ba543bb9958eacf8db2203c24dd0 Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Mon, 12 Oct 2020 09:24:32 +0200 Subject: [PATCH 1/3] Fix type mismatch for ovs_stats port Resolves: #958 --- templates/plugin/ovs_stats.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/plugin/ovs_stats.conf.erb b/templates/plugin/ovs_stats.conf.erb index 399021dbf..27b4415df 100644 --- a/templates/plugin/ovs_stats.conf.erb +++ b/templates/plugin/ovs_stats.conf.erb @@ -1,6 +1,6 @@ <%- if @port %> - Port <%= @port %> + Port "<%= @port %>" <%- end -%> <%- if @address %> Address "<%= @address %>" From ff706d52056b7aa3a232bc0e4ddce30e9089cfc7 Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Mon, 12 Oct 2020 10:22:38 +0200 Subject: [PATCH 2/3] Fix already existing tests There are already tests, but they did not require quotation marks. --- spec/classes/collectd_plugin_ovs_stats_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/collectd_plugin_ovs_stats_spec.rb b/spec/classes/collectd_plugin_ovs_stats_spec.rb index cf2c8bbf4..1424e389c 100644 --- a/spec/classes/collectd_plugin_ovs_stats_spec.rb +++ b/spec/classes/collectd_plugin_ovs_stats_spec.rb @@ -26,7 +26,7 @@ it 'will create config which will contain port configuration' do is_expected.to contain_file('ovs_stats.load').with( - content: %r{Port 666} + content: %r{Port "666"} ) end From d0a1caac2875e575218210e3ae8e7e2d84518f5e Mon Sep 17 00:00:00 2001 From: Matthias Runge Date: Mon, 12 Oct 2020 15:47:49 +0200 Subject: [PATCH 3/3] Add acceptance test for ovs_stats --- .../acceptance/class_plugin_ovs_stats_spec.rb | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 spec/acceptance/class_plugin_ovs_stats_spec.rb diff --git a/spec/acceptance/class_plugin_ovs_stats_spec.rb b/spec/acceptance/class_plugin_ovs_stats_spec.rb new file mode 100644 index 000000000..85df4c1c6 --- /dev/null +++ b/spec/acceptance/class_plugin_ovs_stats_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper_acceptance' + +describe 'collectd::plugin::ovs_stats class' do + context 'basic parameters' do + # Using puppet_apply as a helper + it 'works idempotently with no errors' do + pp = <<-EOS + class{'collectd': + utils => true, + } + class{ 'collectd::plugin::ovs_stats': + port => 6639, + } + # Add one write plugin to keep logs quiet + class{'collectd::plugin::csv':} + # Create a socket to query + class{'collectd::plugin::unixsock': + socketfile => '/var/run/collectd-sock', + socketgroup => 'root', + } + + EOS + # Run 3 times since the collectd_version + # fact is impossible until collectd is + # installed. + apply_manifest(pp, catch_failures: false) + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + # Wait to get some data + shell('sleep 10') + end + + describe service('collectd') do + it { is_expected.to be_running } + end + + # it is expected to unload the ovs_stats plugin, since there + # is no ovs running inside the docker container. + # At the same time, collectd should continue to run. + describe command('collectdctl -s /var/run/collectd-sock listval') do + its(:exit_status) { is_expected.to eq 0 } + end +end