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,85 +9,95 @@ describe 'vitrage::db::mysql' do
]
end
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
end
shared_examples_for 'vitrage::db::mysql' do
context 'with only required params' do
let :params do
{
'password' => 'fooboozoo_default_password',
}
end
let :params do
{
'password' => 'fooboozoo_default_password',
}
end
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
describe 'with only required params' do
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
context "overriding allowed_hosts param to array" do
let :params do
{
:password => 'fooboozoo_default_password',
:allowed_hosts => ['127.0.0.1','%'],
}
end
describe "overriding allowed_hosts param to array" do
let :params do
{
:password => 'fooboozoo_default_password',
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
: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('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => ['127.0.0.1','%'],
)}
context "overriding allowed_hosts param to string" do
let :params do
{
:password => 'fooboozoo_default_password',
:allowed_hosts => '192.168.1.1',
}
end
end
describe "overriding allowed_hosts param to string" do
let :params do
{
:password => 'fooboozoo_default_password',
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1',
}
)}
end
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1',
)}
context "overriding allowed_hosts equal to host param" do
let :params do
{
:password => 'fooboozoo_default_password',
:allowed_hosts => '127.0.0.1',
}
end
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '127.0.0.1',
)}
end
end
describe "overriding allowed_hosts equal to host param" do
let :params do
{
:password => 'fooboozoo_default_password',
:allowed_hosts => '127.0.0.1',
}
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
it { is_expected.to contain_openstacklib__db__mysql('vitrage').with(
:user => 'vitrage',
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
:dbname => 'vitrage',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '127.0.0.1',
)}
end
end

View File

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

View File

@ -10,111 +10,125 @@ describe 'vitrage::keystone::auth' do
@default_facts.merge({ :osfamily => 'Debian' })
end
describe 'with default class parameters' do
let :params do
{ :password => 'vitrage_password',
:tenant => 'foobar' }
shared_examples_for 'vitrage::keystone::auth' do
context 'with default class parameters' do
let :params do
{ :password => 'vitrage_password',
:tenant => 'foobar' }
end
it { is_expected.to contain_keystone_user('vitrage').with(
:ensure => 'present',
:password => 'vitrage_password',
) }
it { is_expected.to contain_keystone_user_role('vitrage@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('vitrage::rca').with(
:ensure => 'present',
:description => 'Root Cause Analysis Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage::rca').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8999',
:admin_url => 'http://127.0.0.1:8999',
:internal_url => 'http://127.0.0.1:8999',
) }
end
it { is_expected.to contain_keystone_user('vitrage').with(
:ensure => 'present',
:password => 'vitrage_password',
) }
context 'when overriding URL parameters' do
let :params do
{ :password => 'vitrage_password',
:public_url => 'https://10.10.10.10:80',
:internal_url => 'http://10.10.10.11:81',
:admin_url => 'http://10.10.10.12:81', }
end
it { is_expected.to contain_keystone_user_role('vitrage@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('vitrage::rca').with(
:ensure => 'present',
:description => 'Root Cause Analysis Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage::rca').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8999',
:admin_url => 'http://127.0.0.1:8999',
:internal_url => 'http://127.0.0.1:8999',
) }
end
describe 'when overriding URL parameters' do
let :params do
{ :password => 'vitrage_password',
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage::rca').with(
:ensure => 'present',
:public_url => 'https://10.10.10.10:80',
:internal_url => 'http://10.10.10.11:81',
:admin_url => 'http://10.10.10.12:81', }
:admin_url => 'http://10.10.10.12:81',
) }
end
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage::rca').with(
:ensure => 'present',
:public_url => 'https://10.10.10.10:80',
:internal_url => 'http://10.10.10.11:81',
:admin_url => 'http://10.10.10.12:81',
) }
context 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'vitrageany' }
end
it { is_expected.to contain_keystone_user('vitrageany') }
it { is_expected.to contain_keystone_user_role('vitrageany@services') }
it { is_expected.to contain_keystone_service('vitrageany::rca') }
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrageany::rca') }
end
context 'when overriding service name' do
let :params do
{ :service_name => 'vitrage_service',
:auth_name => 'vitrage',
:password => 'vitrage_password' }
end
it { is_expected.to contain_keystone_user('vitrage') }
it { is_expected.to contain_keystone_user_role('vitrage@services') }
it { is_expected.to contain_keystone_service('vitrage_service::rca') }
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage_service::rca') }
end
context 'when disabling user configuration' do
let :params do
{
:password => 'vitrage_password',
:configure_user => false
}
end
it { is_expected.not_to contain_keystone_user('vitrage') }
it { is_expected.to contain_keystone_user_role('vitrage@services') }
it { is_expected.to contain_keystone_service('vitrage::rca').with(
:ensure => 'present',
:description => 'Root Cause Analysis Service'
) }
end
context 'when disabling user and user role configuration' do
let :params do
{
:password => 'vitrage_password',
:configure_user => false,
:configure_user_role => false
}
end
it { is_expected.not_to contain_keystone_user('vitrage') }
it { is_expected.not_to contain_keystone_user_role('vitrage@services') }
it { is_expected.to contain_keystone_service('vitrage::rca').with(
:ensure => 'present',
:description => 'Root Cause Analysis Service'
) }
end
end
describe 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'vitrageany' }
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
it { is_expected.to contain_keystone_user('vitrageany') }
it { is_expected.to contain_keystone_user_role('vitrageany@services') }
it { is_expected.to contain_keystone_service('vitrageany::rca') }
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrageany::rca') }
end
describe 'when overriding service name' do
let :params do
{ :service_name => 'vitrage_service',
:auth_name => 'vitrage',
:password => 'vitrage_password' }
end
it { is_expected.to contain_keystone_user('vitrage') }
it { is_expected.to contain_keystone_user_role('vitrage@services') }
it { is_expected.to contain_keystone_service('vitrage_service::rca') }
it { is_expected.to contain_keystone_endpoint('RegionOne/vitrage_service::rca') }
end
describe 'when disabling user configuration' do
let :params do
{
:password => 'vitrage_password',
:configure_user => false
}
end
it { is_expected.not_to contain_keystone_user('vitrage') }
it { is_expected.to contain_keystone_user_role('vitrage@services') }
it { is_expected.to contain_keystone_service('vitrage::rca').with(
:ensure => 'present',
:description => 'Root Cause Analysis Service'
) }
end
describe 'when disabling user and user role configuration' do
let :params do
{
:password => 'vitrage_password',
:configure_user => false,
:configure_user_role => false
}
end
it { is_expected.not_to contain_keystone_user('vitrage') }
it { is_expected.not_to contain_keystone_user_role('vitrage@services') }
it { is_expected.to contain_keystone_service('vitrage::rca').with(
:ensure => 'present',
:description => 'Root Cause Analysis Service'
) }
end
end

View File

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

View File

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