Switch heat to rspec-puppet-facts

This change updates the heat tests to use rspec-puppet-facts
to test multiple operating systems.

Change-Id: Ic6e1542d5befba529f753b346ff842ed88d1292e
This commit is contained in:
Mykyta Karpin 2016-11-11 13:11:39 +02:00
parent a6a860106b
commit 7359b5129e
18 changed files with 273 additions and 339 deletions

View File

@ -110,33 +110,25 @@ describe 'heat::api_cfn' do
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
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :api_service_name => 'heat-api-cfn' }
when 'RedHat'
{ :api_service_name => 'openstack-heat-api-cfn' }
end
end
it_behaves_like 'heat-api-cfn'
end
let :platform_params do
{ :api_service_name => 'heat-api-cfn' }
end
it_configures 'heat-api-cfn'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
let :platform_params do
{ :api_service_name => 'openstack-heat-api-cfn' }
end
it_configures 'heat-api-cfn'
end
end

View File

@ -111,32 +111,25 @@ describe 'heat::api_cloudwatch' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :api_service_name => 'heat-api-cloudwatch' }
when 'RedHat'
{ :api_service_name => 'openstack-heat-api-cloudwatch' }
end
end
it_behaves_like 'heat-api-cloudwatch'
end
let :platform_params do
{ :api_service_name => 'heat-api-cloudwatch' }
end
it_configures 'heat-api-cloudwatch'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
let :platform_params do
{ :api_service_name => 'openstack-heat-api-cloudwatch' }
end
it_configures 'heat-api-cloudwatch'
end
end

View File

@ -109,32 +109,25 @@ describe 'heat::api' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :api_service_name => 'heat-api' }
when 'RedHat'
{ :api_service_name => 'openstack-heat-api' }
end
end
it_behaves_like 'heat-api'
end
let :platform_params do
{ :api_service_name => 'heat-api' }
end
it_configures 'heat-api'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
let :platform_params do
{ :api_service_name => 'openstack-heat-api' }
end
it_configures 'heat-api'
end
end

View File

@ -27,23 +27,16 @@ describe 'heat::client' do
end
context 'on Debian platform' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
it_configures 'heat client'
it_behaves_like 'heat client'
end
end
context 'on RedHat platform' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
it_configures 'heat client'
end
end

View File

@ -42,7 +42,7 @@ describe 'heat::cors' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'heat cors'
it_behaves_like 'heat cors'
end
end

View File

@ -1,102 +1,113 @@
require 'spec_helper'
describe 'heat::cron::purge_deleted' do
shared_examples_for 'heat::cron::purge_deleted' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
let :params do
{ :ensure => 'present',
:minute => 1,
:hour => 0,
:monthday => '*',
:month => '*',
:weekday => '*',
:maxdelay => 0,
:user => 'heat',
:age => 1,
:age_type => 'days',
:destination => '/var/log/heat/heat-purge_deleted.log' }
end
let :pre_condition do
"class { 'heat::keystone::authtoken':
password => 'password',
}
include ::heat"
end
describe 'with default parameters' do
it 'configures a cron' do
is_expected.to contain_cron('heat-manage purge_deleted').with(
:ensure => params[:ensure],
:command => "heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
let :params do
{ :ensure => 'present',
:minute => 1,
:hour => 0,
:monthday => '*',
:month => '*',
:weekday => '*',
:maxdelay => 0,
:user => 'heat',
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday]
)
is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]')
:age => 1,
:age_type => 'days',
:destination => '/var/log/heat/heat-purge_deleted.log' }
end
let :pre_condition do
"class { 'heat::keystone::authtoken':
password => 'password',
}
include ::heat"
end
describe 'with default parameters' do
it 'configures a cron' do
is_expected.to contain_cron('heat-manage purge_deleted').with(
:ensure => params[:ensure],
:command => "heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'heat',
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday]
)
is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]')
end
end
describe 'when specifying a maxdelay param' do
before :each do
params.merge!(
:maxdelay => 600
)
end
it 'configures a cron with delay' do
is_expected.to contain_cron('heat-manage purge_deleted').with(
:ensure => params[:ensure],
:command => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'heat',
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday]
)
is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]')
end
end
describe 'when disabling cron job' do
before :each do
params.merge!(
:ensure => 'absent'
)
end
it 'configures a cron with delay' do
is_expected.to contain_cron('heat-manage purge_deleted').with(
:ensure => params[:ensure],
:command => "heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'heat',
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday]
)
is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]')
end
end
describe 'when setting a wrong age_type' do
before :each do
params.merge!(
:age_type => 'foobar'
)
end
it_raises 'a Puppet::Error', /age_type possible values are only days, hours, minutes, or seconds./
end
end
describe 'when specifying a maxdelay param' do
before :each do
params.merge!(
:maxdelay => 600
)
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
it 'configures a cron with delay' do
is_expected.to contain_cron('heat-manage purge_deleted').with(
:ensure => params[:ensure],
:command => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'heat',
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday]
)
is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]')
it_behaves_like 'heat::cron::purge_deleted'
end
end
describe 'when disabling cron job' do
before :each do
params.merge!(
:ensure => 'absent'
)
end
it 'configures a cron with delay' do
is_expected.to contain_cron('heat-manage purge_deleted').with(
:ensure => params[:ensure],
:command => "heat-manage purge_deleted -g days 1 >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'heat',
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday]
)
is_expected.to contain_package('heat-common').that_comes_before('Cron[heat-manage purge_deleted]')
end
end
describe 'when setting a wrong age_type' do
before :each do
params.merge!(
:age_type => 'foobar'
)
end
it_raises 'a Puppet::Error', /age_type possible values are only days, hours, minutes, or seconds./
end
end

View File

@ -1,11 +1,6 @@
require 'spec_helper'
describe 'heat::db::mysql' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
let :params do
{ :password => 's3cr3t',
@ -31,7 +26,6 @@ describe 'heat::db::mysql' do
:host => params[:host],
:charset => params[:charset],
:collate => 'utf8_general_ci',
:require => 'Class[Mysql::Config]'
)
end
end
@ -65,4 +59,17 @@ describe 'heat::db::mysql' do
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
it_behaves_like 'heat mysql database'
end
end
end

View File

@ -37,7 +37,7 @@ describe 'heat::db::postgresql' do
}))
end
it_configures 'heat::db::postgresql'
it_behaves_like 'heat::db::postgresql'
end
end

View File

@ -77,42 +77,29 @@ describe 'heat::db' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
it_configures 'heat::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://heat:heat@localhost/heat' }
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
it { is_expected.to contain_package('db_backend_package').with({ :ensure => 'present', :name => 'python-pymysql' }) }
end
end
it_behaves_like 'heat::db'
context 'on Redhat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://heat:heat@localhost/heat' }
end
it_configures 'heat::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://heat:heat@localhost/heat' }
case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_package('db_backend_package').with({ :ensure => 'present', :name => 'python-pymysql' }) }
when 'RedHat'
it { is_expected.not_to contain_package('db_backend_package') }
end
end
it { is_expected.not_to contain_package('db_backend_package') }
end
end

View File

@ -44,7 +44,7 @@ describe 'heat::db::sync' do
}))
end
it_configures 'heat-dbsync'
it_behaves_like 'heat-dbsync'
end
end

View File

@ -59,13 +59,13 @@ describe 'heat::engine' do
it { is_expected.to contain_package('heat-engine').with(
:ensure => 'present',
:name => os_params[:package_name],
:name => platform_params[:package_name],
:tag => ['openstack', 'heat-package'],
) }
it { is_expected.to contain_service('heat-engine').with(
:ensure => (expected_params[:manage_service] && expected_params[:enabled]) ? 'running' : 'stopped',
:name => os_params[:service_name],
:name => platform_params[:service_name],
:enable => expected_params[:enabled],
:hasstatus => 'true',
:hasrestart => 'true',
@ -100,7 +100,7 @@ describe 'heat::engine' do
it { is_expected.to contain_service('heat-engine').with(
:ensure => nil,
:name => os_params[:service_name],
:name => platform_params[:service_name],
:enable => false,
:hasstatus => 'true',
:hasrestart => 'true',
@ -116,35 +116,29 @@ describe 'heat::engine' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
let :os_params do
{ :package_name => 'heat-engine',
:service_name => 'heat-engine'
}
end
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :package_name => 'heat-engine',
:service_name => 'heat-engine'
}
when 'RedHat'
{ :package_name => 'openstack-heat-engine',
:service_name => 'openstack-heat-engine'
}
end
end
it_configures 'heat-engine'
it_behaves_like 'heat-engine'
end
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
let :os_params do
{ :package_name => 'openstack-heat-engine',
:service_name => 'openstack-heat-engine'
}
end
it_configures 'heat-engine'
end
end

View File

@ -482,31 +482,25 @@ describe 'heat' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
let :platform_params do
{ :common_package_name => 'heat-common' }
end
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :common_package_name => 'heat-common' }
when 'RedHat'
{ :common_package_name => 'openstack-heat-common' }
end
end
it_configures 'heat'
it_behaves_like 'heat'
end
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
let :platform_params do
{ :common_package_name => 'openstack-heat-common' }
end
it_configures 'heat'
end
end

View File

@ -123,23 +123,16 @@ describe 'heat::keystone::auth_cfn' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
it_configures 'heat keystone auth'
it_behaves_like 'heat keystone auth'
end
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
it_configures 'heat keystone auth'
end
end

View File

@ -157,23 +157,16 @@ describe 'heat::keystone::auth' do
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
it_configures 'heat keystone auth'
it_behaves_like 'heat keystone auth'
end
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
it_configures 'heat keystone auth'
end
end

View File

@ -138,7 +138,7 @@ describe 'heat::keystone::authtoken' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'heat authtoken'
it_behaves_like 'heat authtoken'
end
end

View File

@ -82,24 +82,16 @@ describe 'heat::keystone::domain' do
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
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
it_behaves_like 'heat keystone domain'
end
it_configures 'heat keystone domain'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
it_configures 'heat keystone domain'
end
end

View File

@ -120,24 +120,16 @@ describe 'heat::logging' do
}
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
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
it_behaves_like 'heat-logging'
end
it_configures 'heat-logging'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
})
end
it_configures 'heat-logging'
end
end

View File

@ -32,7 +32,7 @@ describe 'heat::policy' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'heat policies'
it_behaves_like 'heat policies'
end
end