From 3a702ecf4e3ae3c474743feba0ecbbde98cebe29 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Wed, 18 Feb 2015 10:34:51 -0800 Subject: [PATCH] SuPHP acceptance fixes?, chasing the test bug that is timing --- spec/acceptance/mod_suphp_spec.rb | 42 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/spec/acceptance/mod_suphp_spec.rb b/spec/acceptance/mod_suphp_spec.rb index 190edfc61..308173a11 100644 --- a/spec/acceptance/mod_suphp_spec.rb +++ b/spec/acceptance/mod_suphp_spec.rb @@ -2,10 +2,10 @@ describe 'apache::mod::suphp class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do case fact('osfamily') - when 'Debian' - context "default suphp config" do - it 'succeeds in puppeting suphp' do - pp = <<-EOS + when 'Debian' + context "default suphp config" do + it 'succeeds in puppeting suphp' do + pp = <<-EOS class { 'apache': mpm_module => 'prefork', } @@ -22,24 +22,28 @@ class { 'apache::mod::suphp': } group => 'daemon', content => "\\n", } - EOS - apply_manifest(pp, :catch_failures => true) - end + EOS + apply_manifest(pp, :catch_failures => true) + end - describe service('apache2') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end + describe service('apache2') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end - it 'should answer to suphp.example.com' do - shell("/bin/sleep 10") - shell("/usr/bin/curl suphp.example.com:80") do |r| - expect(r.stdout).to match(/^daemon$/) - expect(r.exit_code).to eq(0) + it 'should answer to suphp.example.com' do + timeout = 0 + loop do + r = shell('curl suphp.example.com:80') + timeout += 1 + break if timeout > 20 || r.stdout =~ /^daemon$/ + sleep(1) + end + shell("/usr/bin/curl suphp.example.com:80") do |r| + expect(r.stdout).to match(/^daemon$/) + expect(r.exit_code).to eq(0) + end end end - end - when 'RedHat' - # Not implemented yet end end