Merge "Switch horizon to use rspec-puppet-facts"
This commit is contained in:
commit
4e0e34de8a
@ -0,0 +1,4 @@
|
||||
---
|
||||
other:
|
||||
- Tests updated to leverage rspec-puppet-facts for testing
|
||||
multiple OS versions.
|
@ -15,13 +15,7 @@ describe 'horizon' do
|
||||
File.expand_path(File.join(__FILE__, '..', '..', 'fixtures'))
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :concat_basedir => '/var/lib/puppet/concat',
|
||||
:fqdn => 'some.host.tld'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'horizon' do
|
||||
shared_examples_for 'horizon' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it {
|
||||
@ -396,23 +390,7 @@ describe 'horizon' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
before do
|
||||
facts.merge!({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:os_package_type => 'rpm'
|
||||
})
|
||||
end
|
||||
|
||||
let :platforms_params do
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/dashboard' }
|
||||
end
|
||||
|
||||
it_behaves_like 'horizon'
|
||||
|
||||
shared_examples_for 'horizon on RedHat' do
|
||||
it 'sets WEBROOT in local_settings.py' do
|
||||
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
|
||||
"WEBROOT = '/dashboard/'",
|
||||
@ -420,24 +398,7 @@ describe 'horizon' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
before do
|
||||
facts.merge!({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:operatingsystem => 'Debian',
|
||||
:os_package_type => 'debian'
|
||||
})
|
||||
end
|
||||
|
||||
let :platforms_params do
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings.py',
|
||||
:package_name => 'openstack-dashboard-apache',
|
||||
:root_url => '/horizon' }
|
||||
end
|
||||
|
||||
it_behaves_like 'horizon'
|
||||
|
||||
shared_examples_for 'horizon on Debian' do
|
||||
it 'sets WEBROOT in local_settings.py' do
|
||||
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
|
||||
"WEBROOT = '/horizon/'",
|
||||
@ -445,28 +406,34 @@ describe 'horizon' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Ubuntu platforms' do
|
||||
before do
|
||||
facts.merge!({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:operatingsystemrelease => '14.04',
|
||||
:os_package_type => 'ubuntu'
|
||||
})
|
||||
end
|
||||
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({
|
||||
:fqdn => 'some.host.tld',
|
||||
:processorcount => 2,
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}))
|
||||
end
|
||||
|
||||
let :platforms_params do
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings.py',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/horizon' }
|
||||
end
|
||||
let(:platforms_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings.py',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/horizon' }
|
||||
when 'RedHat'
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/dashboard' }
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'horizon'
|
||||
|
||||
it 'sets WEBROOT in local_settings.py' do
|
||||
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
|
||||
"WEBROOT = '/horizon/'",
|
||||
])
|
||||
it_behaves_like 'horizon'
|
||||
it_behaves_like "horizon on #{facts[:osfamily]}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -19,13 +19,7 @@ describe 'horizon::wsgi::apache' do
|
||||
File.expand_path(File.join(__FILE__, '..', '..', 'fixtures'))
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :concat_basedir => '/var/lib/puppet/concat',
|
||||
:fqdn => 'some.host.tld'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'apache for horizon' do
|
||||
shared_examples_for 'apache for horizon' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'configures apache' do
|
||||
@ -186,27 +180,7 @@ describe 'horizon::wsgi::apache' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
before do
|
||||
facts.merge!({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '6.0'
|
||||
})
|
||||
end
|
||||
|
||||
let :platforms_params do
|
||||
{ :http_service => 'httpd',
|
||||
:httpd_config_file => '/etc/httpd/conf.d/openstack-dashboard.conf',
|
||||
:root_url => '/dashboard',
|
||||
:apache_user => 'apache',
|
||||
:apache_group => 'apache',
|
||||
:wsgi_user => 'apache',
|
||||
:wsgi_group => 'apache',
|
||||
:unix_user => 'apache',
|
||||
:unix_group => 'apache' }
|
||||
end
|
||||
|
||||
it_behaves_like 'apache for horizon'
|
||||
shared_examples_for 'apache for horizon on RedHat platforms' do
|
||||
it {
|
||||
is_expected.to contain_class('apache::mod::wsgi').with(:wsgi_socket_prefix => '/var/run/wsgi')
|
||||
}
|
||||
@ -223,29 +197,7 @@ describe 'horizon::wsgi::apache' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
before do
|
||||
facts.merge!({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:os_package_type => 'debian'
|
||||
})
|
||||
end
|
||||
|
||||
let :platforms_params do
|
||||
{ :http_service => 'apache2',
|
||||
:httpd_config_file => '/etc/apache2/sites-available/openstack-dashboard-alias-only.conf',
|
||||
:root_url => '/horizon',
|
||||
:apache_user => 'www-data',
|
||||
:apache_group => 'www-data',
|
||||
:wsgi_user => 'horizon',
|
||||
:wsgi_group => 'horizon',
|
||||
:unix_user => 'horizon',
|
||||
:unix_group => 'horizon' }
|
||||
end
|
||||
|
||||
it_behaves_like 'apache for horizon'
|
||||
shared_examples_for 'apache for horizon on Debian platforms' do
|
||||
it 'configures webroot alias' do
|
||||
if (Gem::Version.new(Puppet.version) >= Gem::Version.new('4.0'))
|
||||
is_expected.to contain_apache__vhost('horizon_vhost').with(
|
||||
@ -259,39 +211,64 @@ describe 'horizon::wsgi::apache' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Ubuntu platforms' do
|
||||
before do
|
||||
facts.merge!({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:operatingsystemrelease => '14.04',
|
||||
:os_package_type => 'ubuntu'
|
||||
})
|
||||
end
|
||||
|
||||
let :platforms_params do
|
||||
{ :http_service => 'apache2',
|
||||
:httpd_config_file => '/etc/apache2/conf-available/openstack-dashboard.conf',
|
||||
:root_url => '/horizon',
|
||||
:apache_user => 'www-data',
|
||||
:apache_group => 'www-data',
|
||||
:wsgi_user => 'horizon',
|
||||
:wsgi_group => 'horizon',
|
||||
:unix_user => 'horizon',
|
||||
:unix_group => 'horizon' }
|
||||
end
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
if facts[:operatingsystem] == 'Debian'
|
||||
facts.merge!({:os_package_type => 'debian'})
|
||||
end
|
||||
|
||||
it_behaves_like 'apache for horizon'
|
||||
it 'configures webroot alias' do
|
||||
if (Gem::Version.new(Puppet.version) >= Gem::Version.new('4.0'))
|
||||
is_expected.to contain_apache__vhost('horizon_vhost').with(
|
||||
'aliases' => [{'alias' => '/horizon/static', 'path' => '/usr/share/openstack-dashboard/static'}],
|
||||
)
|
||||
else
|
||||
is_expected.to contain_apache__vhost('horizon_vhost').with(
|
||||
'aliases' => [['alias', '/horizon/static'], ['path', '/usr/share/openstack-dashboard/static']],
|
||||
)
|
||||
facts.merge!(OSDefaults.get_facts({
|
||||
:fqdn => 'some.host.tld',
|
||||
:processorcount => 2,
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}))
|
||||
end
|
||||
|
||||
let(:platforms_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
case facts[:operatingsystem]
|
||||
when 'Debian'
|
||||
{ :http_service => 'apache2',
|
||||
:httpd_config_file => '/etc/apache2/sites-available/openstack-dashboard-alias-only.conf',
|
||||
:root_url => '/horizon',
|
||||
:apache_user => 'www-data',
|
||||
:apache_group => 'www-data',
|
||||
:wsgi_user => 'horizon',
|
||||
:wsgi_group => 'horizon',
|
||||
:unix_user => 'horizon',
|
||||
:unix_group => 'horizon' }
|
||||
when 'Ubuntu'
|
||||
{ :http_service => 'apache2',
|
||||
:httpd_config_file => '/etc/apache2/conf-available/openstack-dashboard.conf',
|
||||
:root_url => '/horizon',
|
||||
:apache_user => 'www-data',
|
||||
:apache_group => 'www-data',
|
||||
:wsgi_user => 'horizon',
|
||||
:wsgi_group => 'horizon',
|
||||
:unix_user => 'horizon',
|
||||
:unix_group => 'horizon' }
|
||||
end
|
||||
when 'RedHat'
|
||||
{ :http_service => 'httpd',
|
||||
:httpd_config_file => '/etc/httpd/conf.d/openstack-dashboard.conf',
|
||||
:root_url => '/dashboard',
|
||||
:apache_user => 'apache',
|
||||
:apache_group => 'apache',
|
||||
:wsgi_user => 'apache',
|
||||
:wsgi_group => 'apache',
|
||||
:unix_user => 'apache',
|
||||
:unix_group => 'apache' }
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'apache for horizon'
|
||||
it_behaves_like "apache for horizon on #{facts[:osfamily]} platforms"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -8,11 +8,6 @@ include RspecPuppetFacts
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
# TODO(aschultz): remove this after all tests converted to use OSDefaults
|
||||
# instead of referencing @default_facts
|
||||
c.before :each do
|
||||
@default_facts = OSDefaults.get_facts
|
||||
end
|
||||
end
|
||||
|
||||
def verify_concat_fragment_contents(subject, title, expected_lines)
|
||||
|
Loading…
x
Reference in New Issue
Block a user