Switch tests to use rspec-puppet-facts
This change updates the default tests to use rspec-puppet-facts to do testing with each of the supported operating systems. Change-Id: I53420e4ad7c143a8b2be932c8f2f9d62b465e792
This commit is contained in:
parent
c4807e6cfa
commit
2221ccce57
@ -3,58 +3,71 @@ require 'spec_helper'
|
||||
describe '{{cookiecutter.project_name}}::db::mysql' do
|
||||
|
||||
let :pre_condition do
|
||||
[
|
||||
'include mysql::server',
|
||||
'include {{cookiecutter.project_name}}::db::sync'
|
||||
]
|
||||
'include mysql::server'
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
let :required_params do
|
||||
{ :password => 'fooboozoo_default_password', }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
'password' => 'fooboozoo_default_password',
|
||||
}
|
||||
shared_examples_for '{{cookiecutter.project_name}}-db-mysql' do
|
||||
context 'with only required params' do
|
||||
let :params do
|
||||
required_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => '{{cookiecutter.project_name}}',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'overriding allowed_hosts param to array' do
|
||||
let :params do
|
||||
{ :allowed_hosts => ['127.0.0.1','%'] }.merge(required_params)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => '{{cookiecutter.project_name}}',
|
||||
: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
|
||||
{ :allowed_hosts => '192.168.1.1' }.merge(required_params)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => '{{cookiecutter.project_name}}',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
it { is_expected.to contain_openstacklib__db__mysql('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => '{{cookiecutter.project_name}}',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
)}
|
||||
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 '{{cookiecutter.project_name}}-db-mysql'
|
||||
end
|
||||
end
|
||||
|
||||
describe "overriding allowed_hosts param to array" do
|
||||
before { params.merge!( :allowed_hosts => ['127.0.0.1','%'] ) }
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => '{{cookiecutter.project_name}}',
|
||||
: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
|
||||
before { params.merge!( :allowed_hosts => '192.168.1.1' ) }
|
||||
|
||||
it { is_expected.to contain_openstacklib__db__mysql('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
|
||||
:dbname => '{{cookiecutter.project_name}}',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'utf8',
|
||||
:collate => 'utf8_general_ci',
|
||||
:allowed_hosts => '192.168.1.1'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -2,26 +2,18 @@ require 'spec_helper'
|
||||
|
||||
describe '{{cookiecutter.project_name}}::db::postgresql' do
|
||||
|
||||
let :req_params do
|
||||
{ :password => 'pw' }
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
'include postgresql::server'
|
||||
end
|
||||
|
||||
context 'on a RedHat osfamily' do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.0',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
end
|
||||
let :required_params do
|
||||
{ :password => 'pw' }
|
||||
end
|
||||
|
||||
shared_examples_for '{{cookiecutter.project_name}}-db-postgresql' do
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
req_params
|
||||
required_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_postgresql__server__db('{{cookiecutter.project_name}}').with(
|
||||
@ -29,30 +21,17 @@ describe '{{cookiecutter.project_name}}::db::postgresql' do
|
||||
:password => 'md5c530c33636c58ae83ca933f39319273e'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on a Debian osfamily' do
|
||||
let :facts do
|
||||
{
|
||||
:operatingsystemrelease => '7.8',
|
||||
:operatingsystem => 'Debian',
|
||||
:osfamily => 'Debian',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
end
|
||||
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
req_params
|
||||
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({ :concat_basedir => '/var/lib/puppet/concat' }))
|
||||
end
|
||||
|
||||
it { is_expected.to contain_postgresql__server__db('{{cookiecutter.project_name}}').with(
|
||||
:user => '{{cookiecutter.project_name}}',
|
||||
:password => 'md5c530c33636c58ae83ca933f39319273e'
|
||||
)}
|
||||
it_behaves_like '{{cookiecutter.project_name}}-db-postgresql'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -71,17 +71,7 @@ describe '{{cookiecutter.project_name}}::db' do
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => 'jessie',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures '{{cookiecutter.project_name}}::db'
|
||||
|
||||
shared_examples_for '{{cookiecutter.project_name}}::db on Debian' do
|
||||
context 'using pymysql driver' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://{{cookiecutter.project_name}}:{{cookiecutter.project_name}}@localhost/{{cookiecutter.project_name}}', }
|
||||
@ -97,16 +87,7 @@ describe '{{cookiecutter.project_name}}::db' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystemrelease => '7.1',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures '{{cookiecutter.project_name}}::db'
|
||||
|
||||
shared_examples_for '{{cookiecutter.project_name}}::db on RedHat' do
|
||||
context 'using pymysql driver' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://{{cookiecutter.project_name}}:{{cookiecutter.project_name}}@localhost/{{cookiecutter.project_name}}', }
|
||||
@ -118,4 +99,16 @@ describe '{{cookiecutter.project_name}}::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 '{{cookiecutter.project_name}}::db'
|
||||
it_configures "{{cookiecutter.project_name}}::db on #{facts[:osfamily]}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,116 +5,124 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe '{{cookiecutter.project_name}}::keystone::auth' do
|
||||
shared_examples_for '{{cookiecutter.project_name}}-keystone-auth' do
|
||||
context 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => '{{cookiecutter.project_name}}_password',
|
||||
:tenant => 'foobar' }
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { is_expected.to contain_keystone_user('{{cookiecutter.project_name}}').with(
|
||||
:ensure => 'present',
|
||||
:password => '{{cookiecutter.project_name}}_password',
|
||||
) }
|
||||
|
||||
describe 'with default class parameters' do
|
||||
let :params do
|
||||
{ :password => '{{cookiecutter.project_name}}_password',
|
||||
:tenant => 'foobar' }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:description => '{{cookiecutter.project_name}} FIXME Service'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:FIXME',
|
||||
:admin_url => 'http://127.0.0.1:FIXME',
|
||||
:internal_url => 'http://127.0.0.1:FIXME',
|
||||
) }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('{{cookiecutter.project_name}}').with(
|
||||
:ensure => 'present',
|
||||
:password => '{{cookiecutter.project_name}}_password',
|
||||
) }
|
||||
context 'when overriding URL parameters' do
|
||||
let :params do
|
||||
{ :password => '{{cookiecutter.project_name}}_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('{{cookiecutter.project_name}}@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:description => '{{cookiecutter.project_name}} FIXME Service'
|
||||
) }
|
||||
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:FIXME',
|
||||
:admin_url => 'http://127.0.0.1:FIXME',
|
||||
:internal_url => 'http://127.0.0.1:FIXME',
|
||||
) }
|
||||
end
|
||||
|
||||
describe 'when overriding URL parameters' do
|
||||
let :params do
|
||||
{ :password => '{{cookiecutter.project_name}}_password',
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}::FIXME').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/{{cookiecutter.project_name}}::FIXME').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',
|
||||
) }
|
||||
end
|
||||
context 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => '{{cookiecutter.project_name}}y' }
|
||||
end
|
||||
|
||||
describe 'when overriding auth name' do
|
||||
let :params do
|
||||
{ :password => 'foo',
|
||||
:auth_name => '{{cookiecutter.project_name}}y' }
|
||||
it { is_expected.to contain_keystone_user('{{cookiecutter.project_name}}y') }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}y@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}y::FIXME') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}y::FIXME') }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('{{cookiecutter.project_name}}y') }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}y@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}y::FIXME') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}y::FIXME') }
|
||||
end
|
||||
context 'when overriding service name' do
|
||||
let :params do
|
||||
{ :service_name => '{{cookiecutter.project_name}}_service',
|
||||
:auth_name => '{{cookiecutter.project_name}}',
|
||||
:password => '{{cookiecutter.project_name}}_password' }
|
||||
end
|
||||
|
||||
describe 'when overriding service name' do
|
||||
let :params do
|
||||
{ :service_name => '{{cookiecutter.project_name}}_service',
|
||||
:auth_name => '{{cookiecutter.project_name}}',
|
||||
:password => '{{cookiecutter.project_name}}_password' }
|
||||
it { is_expected.to contain_keystone_user('{{cookiecutter.project_name}}') }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}_service::FIXME') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}_service::FIXME') }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_keystone_user('{{cookiecutter.project_name}}') }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}_service::FIXME') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/{{cookiecutter.project_name}}_service::FIXME') }
|
||||
end
|
||||
context 'when disabling user configuration' do
|
||||
|
||||
describe 'when disabling user configuration' do
|
||||
let :params do
|
||||
{
|
||||
:password => '{{cookiecutter.project_name}}_password',
|
||||
:configure_user => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('{{cookiecutter.project_name}}') }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:description => '{{cookiecutter.project_name}} FIXME Service'
|
||||
) }
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => '{{cookiecutter.project_name}}_password',
|
||||
:configure_user => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('{{cookiecutter.project_name}}') }
|
||||
it { is_expected.to contain_keystone_user_role('{{cookiecutter.project_name}}@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:description => '{{cookiecutter.project_name}} FIXME Service'
|
||||
) }
|
||||
context 'when disabling user and user role configuration' do
|
||||
|
||||
end
|
||||
let :params do
|
||||
{
|
||||
:password => '{{cookiecutter.project_name}}_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
end
|
||||
|
||||
describe 'when disabling user and user role configuration' do
|
||||
it { is_expected.not_to contain_keystone_user('{{cookiecutter.project_name}}') }
|
||||
it { is_expected.not_to contain_keystone_user_role('{{cookiecutter.project_name}}@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:description => '{{cookiecutter.project_name}} FIXME Service'
|
||||
) }
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => '{{cookiecutter.project_name}}_password',
|
||||
:configure_user => false,
|
||||
:configure_user_role => false
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_keystone_user('{{cookiecutter.project_name}}') }
|
||||
it { is_expected.not_to contain_keystone_user_role('{{cookiecutter.project_name}}@services') }
|
||||
it { is_expected.to contain_keystone_service('{{cookiecutter.project_name}}::FIXME').with(
|
||||
:ensure => 'present',
|
||||
:description => '{{cookiecutter.project_name}} FIXME Service'
|
||||
) }
|
||||
|
||||
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 '{{cookiecutter.project_name}}-keystone-auth'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -128,20 +128,15 @@ describe '{{cookiecutter.project_name}}::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 '{{cookiecutter.project_name}}-logging'
|
||||
end
|
||||
|
||||
it_configures '{{cookiecutter.project_name}}-logging'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat' })
|
||||
end
|
||||
|
||||
it_configures '{{cookiecutter.project_name}}-logging'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,8 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe '{{cookiecutter.project_name}}::policy' do
|
||||
|
||||
shared_examples_for '{{cookiecutter.project_name}} policies' do
|
||||
shared_examples_for '{{cookiecutter.project_name}}-policies' do
|
||||
let :params do
|
||||
{
|
||||
:policy_path => '/etc/{{cookiecutter.project_name}}/policy.json',
|
||||
@ -23,19 +22,15 @@ describe '{{cookiecutter.project_name}}::policy' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :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 '{{cookiecutter.project_name}}-policies'
|
||||
end
|
||||
|
||||
it_configures '{{cookiecutter.project_name}} policies'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures '{{cookiecutter.project_name}} policies'
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user