From 113ba77dbcbd826d10aee00e1c0dc14282b3e398 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 23 Oct 2017 10:43:39 +0200 Subject: [PATCH 1/3] use correct datatype in zookeeper tests --- spec/classes/collectd_plugin_zookeeper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/collectd_plugin_zookeeper_spec.rb b/spec/classes/collectd_plugin_zookeeper_spec.rb index 44bb6459c..008bf05d4 100644 --- a/spec/classes/collectd_plugin_zookeeper_spec.rb +++ b/spec/classes/collectd_plugin_zookeeper_spec.rb @@ -25,7 +25,7 @@ context ':ensure => absent' do let :params do - { zookeeper_host: ['myhost'], ensure: 'absent' } + { zookeeper_host: 'myhost', ensure: 'absent' } end it 'Will not create ' do From b5f8f3dc0b8753e4eb9ab4e9a1244765ad108e05 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 23 Oct 2017 10:56:11 +0200 Subject: [PATCH 2/3] convert zookeeper tests to rspec-puppet-facts --- .../classes/collectd_plugin_zookeeper_spec.rb | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/spec/classes/collectd_plugin_zookeeper_spec.rb b/spec/classes/collectd_plugin_zookeeper_spec.rb index 008bf05d4..0e551e9fa 100644 --- a/spec/classes/collectd_plugin_zookeeper_spec.rb +++ b/spec/classes/collectd_plugin_zookeeper_spec.rb @@ -1,36 +1,39 @@ require 'spec_helper' describe 'collectd::plugin::zookeeper', type: :class do - let :facts do - { - osfamily: 'RedHat', - collectd_version: '5.5.0', - operatingsystemmajrelease: '7', - python_dir: '/usr/local/lib/python2.7/dist-packages' - } - end + on_supported_os(test_on).each do |os, facts| + context "on #{os} " do + let :facts do + facts + end - context ':ensure => present and :zookeeper_host => \'myhost\'' do - let :params do - { zookeeper_host: 'myhost', zookeeper_port: '2181' } - end + options = os_specific_options(facts) - it 'Will create /etc/collectd.d/10-zookeeper.conf' do - is_expected.to contain_file('write_riemann.load').with(ensure: 'present') - is_expected.to contain_file('write_riemann.load').with(path: '/etc/collectd.d/10-zookeeper.conf') - is_expected.to contain_file('write_riemann.load').with(content: %r{Host "myhost"}) - is_expected.to contain_file('write_riemann.load').with(content: %r{Port "2181"}) - end - end + context ":ensure => present and :zookeeper_host => 'myhost'" do + let :params do + { zookeeper_host: 'myhost', zookeeper_port: '2181' } + end - context ':ensure => absent' do - let :params do - { zookeeper_host: 'myhost', ensure: 'absent' } - end + it "Will create #{options[:plugin_conf_dir]}/10-zookeeper.conf" do + is_expected.to contain_file('write_riemann.load').with(ensure: 'present') + is_expected.to contain_file('write_riemann.load').with(path: "#{options[:plugin_conf_dir]}/10-zookeeper.conf") + is_expected.to contain_file('write_riemann.load').with(content: %r{Host "myhost"}) + is_expected.to contain_file('write_riemann.load').with(content: %r{Port "2181"}) + end + end + + context ':ensure => absent' do + let :params do + { zookeeper_host: 'myhost', ensure: 'absent' } + end - it 'Will not create ' do - is_expected.to contain_file('zookeeper.load').with(ensure: 'absent', - path: '/etc/collectd.d/10-zookeeper.conf') + it 'Will not create ' do + is_expected.to contain_file('zookeeper.load').with( + ensure: 'absent', + path: "#{options[:plugin_conf_dir]}/10-zookeeper.conf" + ) + end + end end end end From 2a0a258e1378965df1b3820c03749dda292c3684 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 23 Oct 2017 11:04:40 +0200 Subject: [PATCH 3/3] use correct resource names in zookeeper tests --- spec/classes/collectd_plugin_zookeeper_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/classes/collectd_plugin_zookeeper_spec.rb b/spec/classes/collectd_plugin_zookeeper_spec.rb index 0e551e9fa..e5a71a3d7 100644 --- a/spec/classes/collectd_plugin_zookeeper_spec.rb +++ b/spec/classes/collectd_plugin_zookeeper_spec.rb @@ -14,11 +14,11 @@ { zookeeper_host: 'myhost', zookeeper_port: '2181' } end - it "Will create #{options[:plugin_conf_dir]}/10-zookeeper.conf" do - is_expected.to contain_file('write_riemann.load').with(ensure: 'present') - is_expected.to contain_file('write_riemann.load').with(path: "#{options[:plugin_conf_dir]}/10-zookeeper.conf") - is_expected.to contain_file('write_riemann.load').with(content: %r{Host "myhost"}) - is_expected.to contain_file('write_riemann.load').with(content: %r{Port "2181"}) + it "Will create #{options[:plugin_conf_dir]}/10-zookeeper.load" do + is_expected.to contain_file('zookeeper.load').with(ensure: 'present') + is_expected.to contain_file('zookeeper.load').with(path: "#{options[:plugin_conf_dir]}/10-zookeeper.conf") + is_expected.to contain_file('zookeeper.load').with(content: %r{Host "myhost"}) + is_expected.to contain_file('zookeeper.load').with(content: %r{Port "2181"}) end end