From 9b69415e19baa925ecf0d7e8568b2a157fe8aeb6 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sat, 8 Aug 2015 12:05:02 -0700 Subject: [PATCH 1/2] add $::osfamily == debian unit test coverage for selenium::config --- spec/unit/defines/selenium_config_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/unit/defines/selenium_config_spec.rb b/spec/unit/defines/selenium_config_spec.rb index 95ec907..38e3c58 100644 --- a/spec/unit/defines/selenium_config_spec.rb +++ b/spec/unit/defines/selenium_config_spec.rb @@ -93,4 +93,14 @@ end end + context 'for osfamily Debian' do + let(:title) { 'server' } + let(:facts) {{ :osfamily => 'Debian' }} + let :pre_condition do + "include selenium" + end + + it { should contain_package('daemon').with_ensure('present') } + end + end From 97f1fe2aeb7f88c78e6e1f7d7eac1e69ff01f100 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sat, 8 Aug 2015 12:06:09 -0700 Subject: [PATCH 2/2] add acceptance test coverage of combined hub+node --- manifests/config.pp | 10 +++--- spec/acceptance/selenium_hub_and_node_spec.rb | 33 +++++++++++++++++++ spec/unit/defines/selenium_config_spec.rb | 2 +- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 spec/acceptance/selenium_hub_and_node_spec.rb diff --git a/manifests/config.pp b/manifests/config.pp index 5db11a1..5d1cb59 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -19,20 +19,18 @@ validate_string($java) validate_string($jar_name) - $init_script = "init-script-${name}" + # prog is the 'name' of the init.d script. + $prog = "selenium${name}" case $::osfamily { 'debian': { ensure_packages(['daemon']) - Package['daemon'] -> File[$init_script] + Package['daemon'] -> File[$prog] } default : {} } - # prog is the 'name' of the init.d script. - $prog = "selenium${name}" - - file { $init_script: + file { $prog: ensure => 'file', path => "/etc/init.d/${prog}", owner => 'root', diff --git a/spec/acceptance/selenium_hub_and_node_spec.rb b/spec/acceptance/selenium_hub_and_node_spec.rb new file mode 100644 index 0000000..5ea13e8 --- /dev/null +++ b/spec/acceptance/selenium_hub_and_node_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper_acceptance' + +describe 'selenium::hub & selenium::node on the same host' do + after(:all) do + shell "service seleniumhub stop" + shell "service seleniumnode stop" + end + + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + include java + Class['java'] -> Class['selenium::hub'] + Class['java'] -> Class['selenium::node'] + + class { 'selenium::hub': } + class { 'selenium::node': } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + end + + ['seleniumhub', 'seleniumnode'].each do |service| + describe service(service) do + it { should be_running } + it { should be_enabled } + end + end +end diff --git a/spec/unit/defines/selenium_config_spec.rb b/spec/unit/defines/selenium_config_spec.rb index 38e3c58..9b7eeef 100644 --- a/spec/unit/defines/selenium_config_spec.rb +++ b/spec/unit/defines/selenium_config_spec.rb @@ -18,7 +18,7 @@ p.merge!(params) if params it do - should contain_file("init-script-#{title}").with({ + should contain_file("selenium#{title}").with({ 'ensure' => 'file', 'path' => "/etc/init.d/selenium#{title}", 'owner' => 'root',