Browse Source

Finish rspec-puppet-facts update

Since this module was last updated to use rspec-puppet-facts, a few
additional tests were missed. This change updates the last two tests to
use rspec-puppet-facts.

Change-Id: Idd5f80e797574d0e5661e22ec4d631beba0e358e
changes/26/378026/2
Alex Schultz 5 years ago
parent
commit
c4f24cb85c
  1. 79
      spec/classes/aodh_db_mysql_spec.rb
  2. 186
      spec/classes/aodh_keystone_auth_spec.rb
  3. 5
      spec/spec_helper.rb

79
spec/classes/aodh_db_mysql_spec.rb

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

186
spec/classes/aodh_keystone_auth_spec.rb

@ -5,116 +5,124 @@
require 'spec_helper'
describe 'aodh::keystone::auth' do
let :facts do
{ :osfamily => 'Debian' }
end
describe 'with default class parameters' do
let :params do
{ :password => 'aodh_password',
:tenant => 'foobar' }
shared_examples_for 'aodh::keystone::auth' do
context 'with default class parameters' do
let :params do
{ :password => 'aodh_password',
:tenant => 'foobar' }
end
it { is_expected.to contain_keystone_user('aodh').with(
:ensure => 'present',
:password => 'aodh_password',
) }
it { is_expected.to contain_keystone_user_role('aodh@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('aodh::alarming').with(
:ensure => 'present',
:description => 'OpenStack Alarming Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh::alarming').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8042',
:admin_url => 'http://127.0.0.1:8042',
:internal_url => 'http://127.0.0.1:8042',
) }
end
it { is_expected.to contain_keystone_user('aodh').with(
:ensure => 'present',
:password => 'aodh_password',
) }
it { is_expected.to contain_keystone_user_role('aodh@foobar').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('aodh::alarming').with(
:ensure => 'present',
:description => 'OpenStack Alarming Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh::alarming').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8042',
:admin_url => 'http://127.0.0.1:8042',
:internal_url => 'http://127.0.0.1:8042',
) }
end
context 'when overriding URL parameters' do
let :params do
{ :password => 'aodh_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
describe 'when overriding URL parameters' do
let :params do
{ :password => 'aodh_password',
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh::alarming').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/aodh::alarming').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 => 'aodhany' }
end
describe 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'aodhany' }
it { is_expected.to contain_keystone_user('aodhany') }
it { is_expected.to contain_keystone_user_role('aodhany@services') }
it { is_expected.to contain_keystone_service('aodh::alarming') }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh::alarming') }
end
it { is_expected.to contain_keystone_user('aodhany') }
it { is_expected.to contain_keystone_user_role('aodhany@services') }
it { is_expected.to contain_keystone_service('aodh::alarming') }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh::alarming') }
end
describe 'when overriding service name' do
let :params do
{ :service_name => 'aodh_service',
:auth_name => 'aodh',
:password => 'aodh_password' }
context 'when overriding service name' do
let :params do
{ :service_name => 'aodh_service',
:auth_name => 'aodh',
:password => 'aodh_password' }
end
it { is_expected.to contain_keystone_user('aodh') }
it { is_expected.to contain_keystone_user_role('aodh@services') }
it { is_expected.to contain_keystone_service('aodh_service::alarming') }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh_service::alarming') }
end
it { is_expected.to contain_keystone_user('aodh') }
it { is_expected.to contain_keystone_user_role('aodh@services') }
it { is_expected.to contain_keystone_service('aodh_service::alarming') }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh_service::alarming') }
end
context 'when disabling user configuration' do
let :params do
{
:password => 'aodh_password',
:configure_user => false
}
end
describe 'when disabling user configuration' do
it { is_expected.not_to contain_keystone_user('aodh') }
it { is_expected.to contain_keystone_user_role('aodh@services') }
it { is_expected.to contain_keystone_service('aodh::alarming').with(
:ensure => 'present',
:description => 'OpenStack Alarming Service'
) }
let :params do
{
:password => 'aodh_password',
:configure_user => false
}
end
it { is_expected.not_to contain_keystone_user('aodh') }
it { is_expected.to contain_keystone_user_role('aodh@services') }
it { is_expected.to contain_keystone_service('aodh::alarming').with(
:ensure => 'present',
:description => 'OpenStack Alarming Service'
) }
context 'when disabling user and user role configuration' do
end
let :params do
{
:password => 'aodh_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('aodh') }
it { is_expected.not_to contain_keystone_user_role('aodh@services') }
it { is_expected.to contain_keystone_service('aodh::alarming').with(
:ensure => 'present',
:description => 'OpenStack Alarming Service'
) }
let :params do
{
:password => 'aodh_password',
:configure_user => false,
:configure_user_role => false
}
end
end
it { is_expected.not_to contain_keystone_user('aodh') }
it { is_expected.not_to contain_keystone_user_role('aodh@services') }
it { is_expected.to contain_keystone_service('aodh::alarming').with(
:ensure => 'present',
:description => 'OpenStack Alarming Service'
) }
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 'aodh::keystone::auth'
end
end
end

5
spec/spec_helper.rb

@ -8,11 +8,6 @@ include RspecPuppetFacts
RSpec.configure do |c|
c.alias_it_should_behave_like_to :it_configures, 'configures'
c.alias_it_should_behave_like_to :it_raises, 'raises'
# TODO(aschultz): remove this after all tests converted to use OSDefaults
# instead of referencing @default_facts
c.before :each do
@default_facts = OSDefaults.get_facts
end
end
at_exit { RSpec::Puppet::Coverage.report! }

Loading…
Cancel
Save