From fe1385bef994ab5a9d60ca2784a6e96a793abf84 Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Wed, 21 Dec 2016 20:42:07 +0800 Subject: [PATCH] Switch wsgi test to use rspec-puppet-facts The apache module expects the operatingsystem fact to be set and because the wsgi tests were not using rspec-puppet-facts the missing fact is causing failures. This change switches the wsgi test to leverage rspec-puppet-facts to ensure all the basic facts are being provided to resolve the unit test failures. Change-Id: Ief0e3889549cdd462758af0fee9e6d7b5aebc332 Related-Bug: #1651522 --- spec/classes/mistral_wsgi_apache_spec.rb | 78 ++++++++++-------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/spec/classes/mistral_wsgi_apache_spec.rb b/spec/classes/mistral_wsgi_apache_spec.rb index 9d9fee4..079f1f9 100644 --- a/spec/classes/mistral_wsgi_apache_spec.rb +++ b/spec/classes/mistral_wsgi_apache_spec.rb @@ -2,14 +2,6 @@ require 'spec_helper' describe 'mistral::wsgi::apache' do - let :global_facts do - @default_facts.merge({ - :os_workers => 8, - :concat_basedir => '/var/lib/puppet/concat', - :fqdn => 'some.host.tld', - }) - end - shared_examples_for 'apache serving mistral with mod_wsgi' do it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) } it { is_expected.to contain_class('mistral::params') } @@ -81,44 +73,38 @@ describe 'mistral::wsgi::apache' do end end - context 'on RedHat platforms' do - let :facts do - global_facts.merge({ - :osfamily => 'RedHat', - :operatingsystemrelease => '7.0' - }) + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts({ + :os_workers => 8, + :concat_basedir => '/var/lib/puppet/concat', + :fqdn => 'some.host.tld' + })) + end + + let(:platform_parameters) do + case facts[:osfamily] + when 'Debian' + { + :httpd_service_name => 'apache2', + :httpd_ports_file => '/etc/apache2/ports.conf', + :wsgi_script_path => '/usr/lib/cgi-bin/mistral', + :wsgi_script_source => '/usr/lib/python2.7/dist-packages/mistral/api/wsgi.py' + } + when 'RedHat' + { + :httpd_service_name => 'httpd', + :httpd_ports_file => '/etc/httpd/conf/ports.conf', + :wsgi_script_path => '/var/www/cgi-bin/mistral', + :wsgi_script_source => '/usr/lib/python2.7/site-packages/mistral/api/wsgi.py' + } + + end + end + it_configures 'apache serving mistral with mod_wsgi' end - - let :platform_parameters do - { - :httpd_service_name => 'httpd', - :httpd_ports_file => '/etc/httpd/conf/ports.conf', - :wsgi_script_path => '/var/www/cgi-bin/mistral', - :wsgi_script_source => '/usr/lib/python2.7/site-packages/mistral/api/wsgi.py' - } - end - - it_configures 'apache serving mistral with mod_wsgi' - end - - context 'on Debian platforms' do - let :facts do - global_facts.merge({ - :osfamily => 'Debian', - :operatingsystem => 'Debian', - :operatingsystemrelease => '7.0' - }) - end - - let :platform_parameters do - { - :httpd_service_name => 'apache2', - :httpd_ports_file => '/etc/apache2/ports.conf', - :wsgi_script_path => '/usr/lib/cgi-bin/mistral', - :wsgi_script_source => '/usr/lib/python2.7/dist-packages/mistral/api/wsgi.py' - } - end - - it_configures 'apache serving mistral with mod_wsgi' end end