Finish converting to rspec-puppet-facts

This change updates the last few tests that don't leverage
rspec-puppet-facts do use the on_supported_os method for testing.

Change-Id: Ife1442cf0be103327af70560363ce58f1a29ac92
This commit is contained in:
Alex Schultz 2016-10-24 11:42:44 -06:00
parent 5f29d12afe
commit b0666a4b95
5 changed files with 221 additions and 212 deletions

View File

@ -9,17 +9,14 @@ describe 'vitrage::db::mysql' do
] ]
end end
let :facts do shared_examples_for 'vitrage::db::mysql' do
@default_facts.merge({ :osfamily => 'Debian' }) context 'with only required params' do
end
let :params do let :params do
{ {
'password' => 'fooboozoo_default_password', 'password' => 'fooboozoo_default_password',
} }
end end
describe 'with only required params' do
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with( it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage', :user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206', :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
@ -30,7 +27,7 @@ describe 'vitrage::db::mysql' do
)} )}
end end
describe "overriding allowed_hosts param to array" do context "overriding allowed_hosts param to array" do
let :params do let :params do
{ {
:password => 'fooboozoo_default_password', :password => 'fooboozoo_default_password',
@ -50,7 +47,7 @@ describe 'vitrage::db::mysql' do
end end
describe "overriding allowed_hosts param to string" do context "overriding allowed_hosts param to string" do
let :params do let :params do
{ {
:password => 'fooboozoo_default_password', :password => 'fooboozoo_default_password',
@ -70,7 +67,7 @@ describe 'vitrage::db::mysql' do
end end
describe "overriding allowed_hosts equal to host param" do context "overriding allowed_hosts equal to host param" do
let :params do let :params do
{ {
:password => 'fooboozoo_default_password', :password => 'fooboozoo_default_password',
@ -89,5 +86,18 @@ describe 'vitrage::db::mysql' do
)} )}
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
it_configures 'vitrage::db::mysql'
end
end
end end

View File

@ -70,17 +70,7 @@ describe 'vitrage::db' do
end end
end end
context 'on Debian platforms' do shared_examples_for 'vitrage::db on Debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
})
end
it_configures 'vitrage::db'
context 'using pymysql driver' do context 'using pymysql driver' do
let :params do let :params do
{ :database_connection => 'mysql+pymysql://vitrage:vitrage@localhost/vitrage', } { :database_connection => 'mysql+pymysql://vitrage:vitrage@localhost/vitrage', }
@ -96,16 +86,7 @@ describe 'vitrage::db' do
end end
end end
context 'on Redhat platforms' do shared_examples_for 'vitrage::db on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
end
it_configures 'vitrage::db'
context 'using pymysql driver' do context 'using pymysql driver' do
let :params do let :params do
{ :database_connection => 'mysql+pymysql://vitrage:vitrage@localhost/vitrage', } { :database_connection => 'mysql+pymysql://vitrage:vitrage@localhost/vitrage', }
@ -115,4 +96,17 @@ describe 'vitrage::db' do
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
it_configures 'vitrage::db'
it_configures "vitrage::db on #{facts[:osfamily]} platforms"
end
end
end end

View File

@ -10,7 +10,8 @@ describe 'vitrage::keystone::auth' do
@default_facts.merge({ :osfamily => 'Debian' }) @default_facts.merge({ :osfamily => 'Debian' })
end end
describe 'with default class parameters' do shared_examples_for 'vitrage::keystone::auth' do
context 'with default class parameters' do
let :params do let :params do
{ :password => 'vitrage_password', { :password => 'vitrage_password',
:tenant => 'foobar' } :tenant => 'foobar' }
@ -39,7 +40,7 @@ describe 'vitrage::keystone::auth' do
) } ) }
end end
describe 'when overriding URL parameters' do context 'when overriding URL parameters' do
let :params do let :params do
{ :password => 'vitrage_password', { :password => 'vitrage_password',
:public_url => 'https://10.10.10.10:80', :public_url => 'https://10.10.10.10:80',
@ -55,7 +56,7 @@ describe 'vitrage::keystone::auth' do
) } ) }
end end
describe 'when overriding auth name' do context 'when overriding auth name' do
let :params do let :params do
{ :password => 'foo', { :password => 'foo',
:auth_name => 'vitrageany' } :auth_name => 'vitrageany' }
@ -67,7 +68,7 @@ describe 'vitrage::keystone::auth' do
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrageany::rca') } it { is_expected.to contain_keystone_endpoint('RegionOne/vitrageany::rca') }
end end
describe 'when overriding service name' do context 'when overriding service name' do
let :params do let :params do
{ :service_name => 'vitrage_service', { :service_name => 'vitrage_service',
:auth_name => 'vitrage', :auth_name => 'vitrage',
@ -80,7 +81,7 @@ describe 'vitrage::keystone::auth' do
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage_service::rca') } it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage_service::rca') }
end end
describe 'when disabling user configuration' do context 'when disabling user configuration' do
let :params do let :params do
{ {
@ -98,7 +99,7 @@ describe 'vitrage::keystone::auth' do
end end
describe 'when disabling user and user role configuration' do context 'when disabling user and user role configuration' do
let :params do let :params do
{ {
@ -116,5 +117,18 @@ describe 'vitrage::keystone::auth' do
) } ) }
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
it_configures 'vitrage::keystone::auth'
end
end
end end

View File

@ -32,7 +32,7 @@ describe 'vitrage::logging' do
} }
end end
shared_examples_for 'vitrage-logging' do shared_examples_for 'vitrage::logging' do
context 'with basic logging options and default settings' do context 'with basic logging options and default settings' do
it_configures 'basic default logging settings' it_configures 'basic default logging settings'
@ -53,8 +53,7 @@ describe 'vitrage::logging' do
end end
end end
shared_examples_for 'basic default logging settings' do
shared_examples 'basic default logging settings' do
it 'configures vitrage logging settins with default values' do it 'configures vitrage logging settins with default values' do
is_expected.to contain_vitrage_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>') is_expected.to contain_vitrage_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_vitrage_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>') is_expected.to contain_vitrage_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
@ -64,7 +63,7 @@ describe 'vitrage::logging' do
end end
end end
shared_examples 'basic non-default logging settings' do shared_examples_for 'basic non-default logging settings' do
it 'configures vitrage logging settins with non-default values' do it 'configures vitrage logging settins with non-default values' do
is_expected.to contain_vitrage_config('DEFAULT/use_syslog').with(:value => 'true') is_expected.to contain_vitrage_config('DEFAULT/use_syslog').with(:value => 'true')
is_expected.to contain_vitrage_config('DEFAULT/use_stderr').with(:value => 'false') is_expected.to contain_vitrage_config('DEFAULT/use_stderr').with(:value => 'false')
@ -110,7 +109,6 @@ describe 'vitrage::logging' do
end end
end end
shared_examples_for 'logging params unset' do shared_examples_for 'logging params unset' do
[ :logging_context_format_string, :logging_default_format_string, [ :logging_context_format_string, :logging_default_format_string,
:logging_debug_format_suffix, :logging_exception_prefix, :logging_debug_format_suffix, :logging_exception_prefix,
@ -122,20 +120,16 @@ describe 'vitrage::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 'vitrage-logging' it_configures 'vitrage::logging'
end end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'vitrage-logging'
end end
end end

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe 'vitrage::policy' do describe 'vitrage::policy' do
shared_examples_for 'vitrage policies' do shared_examples_for 'vitrage::policy' do
let :params do let :params do
{ {
:policy_path => '/etc/vitrage/policy.json', :policy_path => '/etc/vitrage/policy.json',
@ -24,19 +24,16 @@ describe 'vitrage::policy' 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
it_configures 'vitrage policies' it_configures 'vitrage::policy'
end
end end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'vitrage policies'
end
end end