Update tests with rspec facts

This patch updates tests that perform on Debian/RedHat sets to use
on_supported_os from rspec-puppet-facts.

Change-Id: I4b7bec3e0b314cda34e41bda3892847a23325bb9
This commit is contained in:
Nate Potter 2016-04-22 14:15:11 -07:00
parent 3545f54f29
commit ac3b678746
6 changed files with 128 additions and 151 deletions

View File

@ -1,93 +1,102 @@
require 'spec_helper'
describe 'magnum::db::mysql' do
shared_examples_for 'magnum::db::mysql' do
let :pre_condition do
[
'include mysql::server',
'include magnum::db::sync'
]
end
let :pre_condition do
[
'include mysql::server',
'include magnum::db::sync'
]
end
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
let :params do
{
'password' => 'secrete',
}
end
describe 'with only required params' do
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
describe "overriding allowed_hosts param to array" do
let :params do
{
:password => 'secrete',
:allowed_hosts => ['127.0.0.1','%'],
'password' => 'secrete',
}
end
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => ['127.0.0.1', '%'],
)}
end
describe "overriding allowed_hosts param to string" do
let :params do
{
:password => 'secrete',
:allowed_hosts => '192.168.1.1',
}
context 'with only required params' do
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1',
)}
context "overriding allowed_hosts param to array" do
let :params do
{
:password => 'secrete',
:allowed_hosts => ['127.0.0.1','%'],
}
end
end
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => ['127.0.0.1', '%'],
)}
describe "overriding allowed_hosts equal to host param" do
let :params do
{
:password => 'secrete',
end
context "overriding allowed_hosts param to string" do
let :params do
{
:password => 'secrete',
:allowed_hosts => '192.168.1.1',
}
end
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1',
)}
end
context "overriding allowed_hosts equal to host param" do
let :params do
{
:password => 'secrete',
:allowed_hosts => '127.0.0.1',
}
end
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '127.0.0.1',
}
)}
end
it { is_expected.to contain_openstacklib__db__mysql('magnum').with(
:user => 'magnum',
:password_hash => '*FBA9D2346613CFE4A811FC2A4A648432C6FA2CFD',
:dbname => 'magnum',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '127.0.0.1',
)}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "os #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'magnum::db::mysql'
end
end
end

View File

@ -54,27 +54,15 @@ describe 'magnum::db' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
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 'magnum::db'
end
it_configures 'magnum::db'
end
context 'on Redhat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'magnum::db'
end
end

View File

@ -152,36 +152,25 @@ describe 'magnum' do
end
end
context 'on Ubuntu platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu'
})
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({:processorcount => 8}))
end
let :platform_params do
if facts[:os_family] == 'Debian'
{ :magnum_common_package => 'magnum-common' }
else
{ :magnum_common_package => 'openstack-magnum-common' }
end
end
it_behaves_like 'magnum'
end
let :platform_params do
{ :magnum_common_package => 'nova-common',
:lock_path => '/var/lock/nova'
}
end
it_behaves_like 'magnum'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
{ :nova_common_package => 'openstack-nova-common',
:lock_path => '/var/lib/nova/tmp'
}
end
it_behaves_like 'magnum'
end
end

View File

@ -7,7 +7,7 @@ require 'spec_helper'
describe 'magnum::keystone::auth' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
OSDefaults.get_facts({ :osfamily => 'Debian' })
end
describe 'with default class parameters' do

View File

@ -122,20 +122,15 @@ describe 'magnum::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 'magnum-logging'
end
it_configures 'magnum-logging'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'magnum-logging'
end
end

View File

@ -24,19 +24,15 @@ describe 'magnum::policy' 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
it_behaves_like 'magnum policies'
end
it_configures 'magnum policies'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'magnum policies'
end
end