Update tests to leverage rspec-puppet-facts

This change updates the test that currently do Debian/RedHat sets of
tests to use on_supported_os from rspec-puppet-facts. This improves the
over all coverage with the specific CentOS, Debian, RedHat and Ubuntu
flavors of facts.

Change-Id: Ibd7e2914419a492363de70d1e93c86abeeabc357
This commit is contained in:
Alex Schultz 2016-01-11 21:26:03 -07:00
parent a446693bae
commit a6e6657811
12 changed files with 205 additions and 302 deletions

View File

@ -119,80 +119,8 @@ describe 'aodh::api' do
it_raises 'a Puppet::Error', /Invalid service_name/ it_raises 'a Puppet::Error', /Invalid service_name/
end end
end
context 'on Debian platforms' do context "with custom keystone identity_uri and auth_uri" do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '8.0',
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld',
:processorcount => 2,
})
end
let :platform_params do
{ :api_package_name => 'aodh-api',
:api_service_name => 'aodh-api' }
end
it_configures 'aodh-api'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.1',
:fqdn => 'some.host.tld',
:concat_basedir => '/var/lib/puppet/concat',
:processorcount => 2,
})
end
let :platform_params do
{ :api_package_name => 'openstack-aodh-api',
:api_service_name => 'openstack-aodh-api' }
end
it_configures 'aodh-api'
end
describe 'with custom auth_uri' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
before do
params.merge!({
:keystone_auth_uri => 'https://foo.bar:1234/',
})
end
it 'should configure custom auth_uri correctly' do
is_expected.to contain_aodh_config('keystone_authtoken/auth_uri').with_value( 'https://foo.bar:1234/' )
end
end
describe "with custom keystone identity_uri" do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
before do
params.merge!({
:keystone_identity_uri => 'https://foo.bar:1234/',
})
end
it 'configures identity_uri' do
is_expected.to contain_aodh_config('keystone_authtoken/identity_uri').with_value("https://foo.bar:1234/");
end
end
describe "with custom keystone identity_uri and auth_uri" do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
before do before do
params.merge!({ params.merge!({
:keystone_identity_uri => 'https://foo.bar:35357/', :keystone_identity_uri => 'https://foo.bar:35357/',
@ -204,5 +132,32 @@ describe 'aodh::api' do
is_expected.to contain_aodh_config('keystone_authtoken/auth_uri').with_value("https://foo.bar:5000/v2.0/"); is_expected.to contain_aodh_config('keystone_authtoken/auth_uri').with_value("https://foo.bar:5000/v2.0/");
end end
end end
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(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :api_package_name => 'aodh-api',
:api_service_name => 'aodh-api' }
when 'RedHat'
{ :api_package_name => 'openstack-aodh-api',
:api_service_name => 'openstack-aodh-api' }
end
end
it_configures 'aodh-api'
end
end
end end

View File

@ -36,20 +36,16 @@ describe 'aodh::auth' do
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
{ :osfamily => 'Debian' } }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
it_configures 'aodh-auth' it_configures 'aodh-auth'
end end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'aodh-auth'
end end
end end

View File

@ -15,19 +15,16 @@ describe 'aodh::client' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
{ :osfamily => 'Debian' } }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
it_configures 'aodh client' it_configures 'aodh client'
end end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end end
it_configures 'aodh client'
end
end end

View File

@ -10,15 +10,7 @@ describe 'aodh::db::postgresql' do
'include postgresql::server' 'include postgresql::server'
end end
context 'on a RedHat osfamily' do shared_examples 'aodh::db::postgresql' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
context 'with only required parameters' do context 'with only required parameters' do
let :params do let :params do
req_params req_params
@ -32,27 +24,19 @@ describe 'aodh::db::postgresql' do
end end
context 'on a Debian osfamily' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
{ }).each do |os,facts|
:operatingsystemrelease => '7.8', context "on #{os}" do
:operatingsystem => 'Debian', let (:facts) do
:osfamily => 'Debian', facts.merge!(OSDefaults.get_facts({
:concat_basedir => '/var/lib/puppet/concat' :concat_basedir => '/var/lib/puppet/concat'
} }))
end end
context 'with only required parameters' do it_configures 'aodh::db::postgresql'
let :params do end
req_params
end end
it { is_expected.to contain_postgresql__server__db('aodh').with(
:user => 'aodh',
:password => 'md534e5dd092d680f3d8c11c62951fb5c19'
)}
end
end
end end

View File

@ -87,16 +87,7 @@ describe 'aodh::db' do
end end
end end
context 'on Debian platforms' do shared_examples_for 'aodh::db on Debian' do
let :facts do
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
}
end
it_configures 'aodh::db'
context 'with sqlite backend' do context 'with sqlite backend' do
let :params do let :params do
{ :database_connection => 'sqlite:///var/lib/aodh/aodh.sqlite', } { :database_connection => 'sqlite:///var/lib/aodh/aodh.sqlite', }
@ -109,7 +100,6 @@ describe 'aodh::db' do
:tag => 'openstack' :tag => 'openstack'
) )
end end
end end
context 'using pymysql driver' do context 'using pymysql driver' do
@ -127,15 +117,7 @@ describe 'aodh::db' do
end end
end end
context 'on Redhat platforms' do shared_examples_for 'aodh::db on RedHat' do
let :facts do
{ :osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
}
end
it_configures 'aodh::db'
context 'using pymysql driver' do context 'using pymysql driver' do
let :params do let :params do
{ :database_connection => 'mysql+pymysql://aodh:aodh@localhost/aodh', } { :database_connection => 'mysql+pymysql://aodh:aodh@localhost/aodh', }
@ -144,5 +126,23 @@ describe 'aodh::db' do
it { is_expected.not_to contain_package('aodh-backend-package') } it { is_expected.not_to contain_package('aodh-backend-package') }
end end
end 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())
end
case facts[:osfamily]
when 'Debian'
it_configures 'aodh::db on Debian'
when 'RedHat'
it_configures 'aodh::db on RedHat'
end
it_configures 'aodh::db'
end
end
end end

View File

@ -85,29 +85,31 @@ describe 'aodh::evaluator' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ :osfamily => 'Debian' }) }).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 end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :evaluator_package_name => 'aodh-evaluator', { :evaluator_package_name => 'aodh-evaluator',
:evaluator_service_name => 'aodh-evaluator' } :evaluator_service_name => 'aodh-evaluator' }
end when 'RedHat'
it_configures 'aodh-evaluator'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
{ :evaluator_package_name => 'openstack-aodh-evaluator', { :evaluator_package_name => 'openstack-aodh-evaluator',
:evaluator_service_name => 'openstack-aodh-evaluator' } :evaluator_service_name => 'openstack-aodh-evaluator' }
end end
end
it_configures 'aodh-evaluator' it_configures 'aodh-evaluator'
end end
end
end end

View File

@ -212,31 +212,25 @@ describe 'aodh' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ }).each do |os,facts|
:osfamily => 'Debian', context "on #{os}" do
:operatingsystem => 'Debian', let (:facts) do
}) facts.merge!(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :aodh_common_package => 'aodh-common' } { :aodh_common_package => 'aodh-common' }
end when 'RedHat'
it_behaves_like 'aodh'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
{ :aodh_common_package => 'openstack-aodh-common' } { :aodh_common_package => 'openstack-aodh-common' }
end end
end
it_behaves_like 'aodh' it_behaves_like 'aodh'
end end
end
end end

View File

@ -71,29 +71,27 @@ describe 'aodh::listener' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ :osfamily => 'Debian' }) }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :listener_package_name => 'aodh-listener', { :listener_package_name => 'aodh-listener',
:listener_service_name => 'aodh-listener' } :listener_service_name => 'aodh-listener' }
end when 'RedHat'
it_configures 'aodh-listener'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
{ :listener_package_name => 'openstack-aodh-listener', { :listener_package_name => 'openstack-aodh-listener',
:listener_service_name => 'openstack-aodh-listener' } :listener_service_name => 'openstack-aodh-listener' }
end end
end
it_configures 'aodh-listener' it_configures 'aodh-listener'
end end
end
end end

View File

@ -125,20 +125,16 @@ describe 'aodh::logging' do
} }
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ :osfamily => 'Debian' }) }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
it_configures 'aodh-logging' it_configures 'aodh-logging'
end end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'aodh-logging'
end end
end end

View File

@ -71,29 +71,26 @@ describe 'aodh::notifier' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ :osfamily => 'Debian' }) }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
let :platform_params do let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :notifier_package_name => 'aodh-notifier', { :notifier_package_name => 'aodh-notifier',
:notifier_service_name => 'aodh-notifier' } :notifier_service_name => 'aodh-notifier' }
end when 'RedHat'
it_configures 'aodh-notifier'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
{ :notifier_package_name => 'openstack-aodh-notifier', { :notifier_package_name => 'openstack-aodh-notifier',
:notifier_service_name => 'openstack-aodh-notifier' } :notifier_service_name => 'openstack-aodh-notifier' }
end end
end
it_configures 'aodh-notifier' it_configures 'aodh-notifier'
end end
end
end end

View File

@ -23,19 +23,16 @@ describe 'aodh::policy' do
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
{ :osfamily => 'Debian' } }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end end
it_configures 'aodh policies' it_configures 'aodh policies'
end end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end end
it_configures 'aodh policies'
end
end end

View File

@ -2,14 +2,6 @@ require 'spec_helper'
describe 'aodh::wsgi::apache' do describe 'aodh::wsgi::apache' do
let :global_facts do
{
:processorcount => 42,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
}
end
shared_examples_for 'apache serving aodh with mod_wsgi' do shared_examples_for 'apache serving aodh with mod_wsgi' do
it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) } it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) }
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
@ -81,44 +73,39 @@ describe 'aodh::wsgi::apache' do
end end
end end
context 'on RedHat platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
global_facts.merge({ }).each do |os,facts|
:osfamily => 'RedHat', context "on #{os}" do
:operatingsystemrelease => '7.0' let (:facts) do
}) facts.merge!(OSDefaults.get_facts({
:processorcount => 42,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
}))
end end
let :platform_parameters do let(:platform_parameters) do
{ case facts[:osfamily]
:httpd_service_name => 'httpd', when 'Debian'
:httpd_ports_file => '/etc/httpd/conf/ports.conf',
:wsgi_script_path => '/var/www/cgi-bin/aodh',
:wsgi_script_source => '/usr/lib/python2.7/site-packages/aodh/api/app.wsgi'
}
end
it_configures 'apache serving aodh 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_service_name => 'apache2',
:httpd_ports_file => '/etc/apache2/ports.conf', :httpd_ports_file => '/etc/apache2/ports.conf',
:wsgi_script_path => '/usr/lib/cgi-bin/aodh', :wsgi_script_path => '/usr/lib/cgi-bin/aodh',
:wsgi_script_source => '/usr/share/aodh-common/app.wsgi' :wsgi_script_source => '/usr/share/aodh-common/app.wsgi'
} }
end when 'RedHat'
{
:httpd_service_name => 'httpd',
:httpd_ports_file => '/etc/httpd/conf/ports.conf',
:wsgi_script_path => '/var/www/cgi-bin/aodh',
:wsgi_script_source => '/usr/lib/python2.7/site-packages/aodh/api/app.wsgi'
}
end
end
it_configures 'apache serving aodh with mod_wsgi' it_configures 'apache serving aodh with mod_wsgi'
end end
end
end end