Convert to rspec-puppet-facts

Change-Id: Id3748b79510756ff32d6523bd7e7727175c94542
This commit is contained in:
Tobias Urdin 2018-11-24 15:16:05 +01:00
parent 94247b3362
commit c944e90617
9 changed files with 448 additions and 516 deletions

View File

@ -1,27 +1,26 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::api' do describe 'mistral::api' do
let :params do let :params do
{ :api_workers => '1', {
:api_workers => '1',
:enabled => true, :enabled => true,
:manage_service => true, :manage_service => true,
:bind_host => '127.0.0.1', :bind_host => '127.0.0.1',
:bind_port => '1234', :bind_port => '1234',
:enable_proxy_headers_parsing => false, :enable_proxy_headers_parsing => false,
:allow_action_execution_deletion => false} :allow_action_execution_deletion => false
}
end end
let :pre_condition do let :pre_condition do
"class { '::mistral::keystone::authtoken': "class { '::mistral::keystone::authtoken':
password => 'foo', password => 'foo',
}" }"
end end
shared_examples_for 'mistral-api' do shared_examples 'mistral::api' do
context 'config params' do context 'config params' do
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_class('mistral::policy') } it { is_expected.to contain_class('mistral::policy') }
it { is_expected.to contain_class('mistral::keystone::authtoken') } it { is_expected.to contain_class('mistral::keystone::authtoken') }
@ -43,7 +42,6 @@ describe 'mistral::api' do
end end
it 'configures mistral-api service' do it 'configures mistral-api service' do
is_expected.to contain_service('mistral-api').with( is_expected.to contain_service('mistral-api').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:api_service_name], :name => platform_params[:api_service_name],
@ -75,7 +73,6 @@ describe 'mistral::api' do
end end
it 'configures mistral-api service' do it 'configures mistral-api service' do
is_expected.to contain_service('mistral-api').with( is_expected.to contain_service('mistral-api').with(
:ensure => nil, :ensure => nil,
:name => platform_params[:api_service_name], :name => platform_params[:api_service_name],
@ -117,46 +114,31 @@ describe 'mistral::api' do
params.merge!({ :service_name => 'foobar' }) params.merge!({ :service_name => 'foobar' })
end end
it_raises 'a Puppet::Error', /Invalid service_name/ it { should raise_error(Puppet::Error, /Invalid service_name/) }
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
@default_facts.merge({ }).each do |os,facts|
:osfamily => 'Debian', context "on #{os}" do
:operatingsystem => 'Debian', let (:facts) do
:operatingsystemrelease => '8.0', facts.merge!(OSDefaults.get_facts({
:concat_basedir => '/var/lib/puppet/concat', :concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld', :fqdn => 'some.host.tld',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } }, }))
}) end
end
let :platform_params do let (:platform_params) do
{ :api_service_name => 'mistral-api' } case facts[:osfamily]
end when 'Debian'
{ :api_service_name => 'mistral-api' }
when 'RedHat'
{ :api_service_name => 'openstack-mistral-api' }
end
end
it_configures 'mistral-api' it_behaves_like 'mistral::api'
end
end end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.1',
:fqdn => 'some.host.tld',
:concat_basedir => '/var/lib/puppet/concat',
:os => { :name => 'RedHat', :family => 'RedHat', :release => { :major => '7', :minor => '1' } },
})
end
let :platform_params do
{ :api_service_name => 'openstack-mistral-api' }
end
it_configures 'mistral-api'
end
end end

View File

@ -1,22 +1,35 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::config' do describe 'mistral::config' do
shared_examples 'mistral::config' do
let :params do
{
:mistral_config => {
'DEFAULT/foo' => { 'value' => 'fooValue' },
'DEFAULT/bar' => { 'value' => 'barValue' },
'DEFAULT/baz' => { 'ensure' => 'absent' }
}
}
end
let :params do it { should contain_class('mistral::deps') }
{ :mistral_config => {
'DEFAULT/foo' => { 'value' => 'fooValue' }, it {
'DEFAULT/bar' => { 'value' => 'barValue' }, should contain_mistral_config('DEFAULT/foo').with_value('fooValue')
'DEFAULT/baz' => { 'ensure' => 'absent' } should contain_mistral_config('DEFAULT/bar').with_value('barValue')
} should contain_mistral_config('DEFAULT/baz').with_ensure('absent')
} }
end end
it { is_expected.to contain_class('mistral::deps') } 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 arbitrary mistral configurations' do it_behaves_like 'mistral::config'
is_expected.to contain_mistral_config('DEFAULT/foo').with_value('fooValue') end
is_expected.to contain_mistral_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_mistral_config('DEFAULT/baz').with_ensure('absent')
end end
end end

View File

@ -1,64 +1,58 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::db::mysql' do describe 'mistral::db::mysql' do
let :pre_condition do let :pre_condition do
[ "include mysql::server"
'include mysql::server',
]
end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end end
let :params do let :params do
{ {
'password' => 'fooboozoo_default_password', :password => 'fooboozoo_default_password',
} }
end end
describe 'with only required params' do shared_examples 'mistral::db::mysql' do
it { is_expected.to contain_openstacklib__db__mysql('mistral').with( context 'with only required params' do
'user' => 'mistral', it { should contain_openstacklib__db__mysql('mistral').with(
'password_hash' => '*3DDF34A86854A312A8E2C65B506E21C91800D206', :user => 'mistral',
'dbname' => 'mistral', :password_hash => '*3DDF34A86854A312A8E2C65B506E21C91800D206',
'host' => '127.0.0.1', :dbname => 'mistral',
'charset' => 'utf8', :host => '127.0.0.1',
:collate => 'utf8_general_ci', :charset => 'utf8',
)} :collate => 'utf8_general_ci',
end )}
describe "overriding allowed_hosts param to array" do
let :params do
{
:password => 'mistralpass',
:allowed_hosts => ['127.0.0.1','%']
}
end end
end context 'overriding allowed_hosts param to array' do
describe "overriding allowed_hosts param to string" do before do
let :params do params.merge!( :allowed_hosts => ['127.0.01', '%'] )
{ end
:password => 'mistralpass2',
:allowed_hosts => '192.168.1.1' it { should contain_openstacklib__db__mysql('mistral').with(
} :allowed_hosts => params[:allowed_hosts],
)}
end end
end context 'overriding allowed_hosts param to string' do
before do
params.merge!( :allowed_hosts => '192.168.1.1' )
end
describe "overriding allowed_hosts param equals to host param " do it { should contain_openstacklib__db__mysql('mistral').with(
let :params do :allowed_hosts => params[:allowed_hosts],
{ )}
:password => 'mistralpass2',
:allowed_hosts => '127.0.0.1'
}
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_behaves_like 'mistral::db::mysql'
end
end
end end

View File

@ -1,12 +1,9 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::db' do describe 'mistral::db' do
shared_examples 'mistral::db' do shared_examples 'mistral::db' do
context 'with default parameters' do context 'with default parameters' do
it { should contain_oslo__db('mistral_config').with(
it { is_expected.to contain_oslo__db('mistral_config').with(
:db_max_retries => '<SERVICE DEFAULT>', :db_max_retries => '<SERVICE DEFAULT>',
:connection => 'sqlite:////var/lib/mistral/mistral.sqlite', :connection => 'sqlite:////var/lib/mistral/mistral.sqlite',
:idle_timeout => '<SERVICE DEFAULT>', :idle_timeout => '<SERVICE DEFAULT>',
@ -17,12 +14,12 @@ describe 'mistral::db' do
:max_overflow => '<SERVICE DEFAULT>', :max_overflow => '<SERVICE DEFAULT>',
:pool_timeout => '<SERVICE DEFAULT>', :pool_timeout => '<SERVICE DEFAULT>',
)} )}
end end
context 'with specific parameters' do context 'with specific parameters' do
let :params do let :params do
{ :database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral', {
:database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral',
:database_idle_timeout => '3601', :database_idle_timeout => '3601',
:database_min_pool_size => '2', :database_min_pool_size => '2',
:database_max_pool_size => '11', :database_max_pool_size => '11',
@ -34,7 +31,7 @@ describe 'mistral::db' do
} }
end end
it { is_expected.to contain_oslo__db('mistral_config').with( it { should contain_oslo__db('mistral_config').with(
:db_max_retries => '-1', :db_max_retries => '-1',
:connection => 'mysql+pymysql://mistral:mistral@localhost/mistral', :connection => 'mysql+pymysql://mistral:mistral@localhost/mistral',
:idle_timeout => '3601', :idle_timeout => '3601',
@ -49,101 +46,54 @@ describe 'mistral::db' do
context 'with postgresql backend' do context 'with postgresql backend' do
let :params do let :params do
{ :database_connection => 'postgresql://mistral:mistral@localhost/mistral', } {
end :database_connection => 'postgresql://mistral:mistral@localhost/mistral'
}
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
end end
it { should contain_package('python-psycopg2').with_ensure('present') }
end end
context 'with MySQL-python library as backend package' do context 'with MySQL-python library as backend package' do
let :params do let :params do
{ :database_connection => 'mysql://mistral:mistral@localhost/mistral', } {
:database_connection => 'mysql://mistral:mistral@localhost/mistral'
}
end end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') } it { should contain_package('python-mysqldb').with_ensure('present') }
end end
context 'with incorrect database_connection string' do context 'with incorrect database_connection string' do
let :params do let :params do
{ :database_connection => 'redis://mistral:mistral@localhost/mistral', } {
:database_connection => 'redis://mistral:mistral@localhost/mistral'
}
end end
it_raises 'a Puppet::Error', /validate_re/ it { should raise_error(Puppet::Error, /validate_re/) }
end end
context 'with incorrect pymysql database_connection string' do context 'with incorrect pymysql database_connection string' do
let :params do let :params do
{ :database_connection => 'foo+pymysql://mistral:mistral@localhost/mistral', } {
end :database_connection => 'foo+pymysql://mistral:mistral@localhost/mistral'
}
it_raises 'a Puppet::Error', /validate_re/
end
end
context 'on Debian platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
it_configures 'mistral::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-pymysql').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => ['openstack'],
)
end
end
context 'with sqlite backend' do
let :params do
{ :database_connection => 'sqlite:///var/lib/mistral/mistral.sqlite', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-pysqlite2').with(
:ensure => 'present',
:name => 'python-pysqlite2',
:tag => ['openstack'],
)
end
end
end
context 'on Redhat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '1' } },
})
end
it_configures 'mistral::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://mistral:mistral@localhost/mistral', }
end end
it { should raise_error(Puppet::Error, /validate_re/) }
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_behaves_like 'mistral::db'
end
end
end end

View File

@ -1,17 +1,30 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::deps' do describe 'mistral::deps' do
shared_examples 'mistral::deps' do
it {
should contain_anchor('mistral::install::begin')
should contain_anchor('mistral::install::end')
should contain_anchor('mistral::config::begin')
should contain_anchor('mistral::config::end')
should contain_anchor('mistral::db::begin')
should contain_anchor('mistral::db::end')
should contain_anchor('mistral::dbsync::begin')
should contain_anchor('mistral::dbsync::end')
should contain_anchor('mistral::service::begin')
should contain_anchor('mistral::service::end')
}
end
it 'set up the anchors' do on_supported_os({
is_expected.to contain_anchor('mistral::install::begin') :supported_os => OSDefaults.get_supported_os
is_expected.to contain_anchor('mistral::install::end') }).each do |os,facts|
is_expected.to contain_anchor('mistral::config::begin') context "on #{os}" do
is_expected.to contain_anchor('mistral::config::end') let (:facts) do
is_expected.to contain_anchor('mistral::db::begin') facts.merge!(OSDefaults.get_facts())
is_expected.to contain_anchor('mistral::db::end') end
is_expected.to contain_anchor('mistral::dbsync::begin')
is_expected.to contain_anchor('mistral::dbsync::end') it_behaves_like 'mistral::deps'
is_expected.to contain_anchor('mistral::service::begin') end
is_expected.to contain_anchor('mistral::service::end')
end end
end end

View File

@ -1,22 +1,21 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::engine' do describe 'mistral::engine' do
let :params do let :params do
{ :enabled => true, {
:manage_service => true, :enabled => true,
:host => 'foo_host', :manage_service => true,
:topic => 'foo_topic', :host => 'foo_host',
:version => '1.0', :topic => 'foo_topic',
:execution_field_size_limit_kb => '1234', :version => '1.0',
:evaluation_interval => 1234, :execution_field_size_limit_kb => '1234',
:older_than => 60} :evaluation_interval => 1234,
:older_than => 60
}
end end
shared_examples_for 'mistral-engine' do shared_examples 'mistral::engine' do
context 'config params' do context 'config params' do
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_mistral_config('engine/host').with_value( params[:host] ) } it { is_expected.to contain_mistral_config('engine/host').with_value( params[:host] ) }
@ -25,7 +24,6 @@ describe 'mistral::engine' do
it { is_expected.to contain_mistral_config('engine/execution_field_size_limit_kb').with_value( params[:execution_field_size_limit_kb] ) } it { is_expected.to contain_mistral_config('engine/execution_field_size_limit_kb').with_value( params[:execution_field_size_limit_kb] ) }
it { is_expected.to contain_mistral_config('execution_expiration_policy/evaluation_interval').with_value( params[:evaluation_interval] ) } it { is_expected.to contain_mistral_config('execution_expiration_policy/evaluation_interval').with_value( params[:evaluation_interval] ) }
it { is_expected.to contain_mistral_config('execution_expiration_policy/older_than').with_value( params[:older_than] ) } it { is_expected.to contain_mistral_config('execution_expiration_policy/older_than').with_value( params[:older_than] ) }
end end
[{:enabled => true}, {:enabled => false}].each do |param_hash| [{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -35,7 +33,6 @@ describe 'mistral::engine' do
end end
it 'configures mistral-engine service' do it 'configures mistral-engine service' do
is_expected.to contain_service('mistral-engine').with( is_expected.to contain_service('mistral-engine').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:engine_service_name], :name => platform_params[:engine_service_name],
@ -57,7 +54,6 @@ describe 'mistral::engine' do
end end
it 'configures mistral-engine service' do it 'configures mistral-engine service' do
is_expected.to contain_service('mistral-engine').with( is_expected.to contain_service('mistral-engine').with(
:ensure => nil, :ensure => nil,
:name => platform_params[:engine_service_name], :name => platform_params[:engine_service_name],
@ -69,37 +65,26 @@ describe 'mistral::engine' do
is_expected.to contain_service('mistral-engine').that_subscribes_to(nil) is_expected.to contain_service('mistral-engine').that_subscribes_to(nil)
end end
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:osfamily => 'Debian', context "on #{os}" do
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } }, let (:facts) do
}) facts.merge!(OSDefaults.get_facts())
end end
let :platform_params do let (:platform_params) do
{ :engine_service_name => 'mistral-engine' } case facts[:osfamily]
end when 'Debian'
{ :engine_service_name => 'mistral-engine' }
when 'RedHat'
{ :engine_service_name => 'openstack-mistral-engine' }
end
end
it_configures 'mistral-engine' it_behaves_like 'mistral::engine'
end
end end
context 'on RedHat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '0' } },
})
end
let :platform_params do
{ :engine_service_name => 'openstack-mistral-engine' }
end
it_configures 'mistral-engine'
end
end end

View File

@ -1,25 +1,23 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral::executor' do describe 'mistral::executor' do
let :params do let :params do
{ :enabled => true, {
:manage_service => true, :enabled => true,
:host => true, :manage_service => true,
:topic => true, :host => true,
:version => true} :topic => true,
:version => true
}
end end
shared_examples_for 'mistral-executor' do shared_examples 'mistral::executor' do
context 'config params' do context 'config params' do
it { is_expected.to contain_class('mistral::params') } it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_mistral_config('executor/host').with_value( params[:host] ) } it { is_expected.to contain_mistral_config('executor/host').with_value( params[:host] ) }
it { is_expected.to contain_mistral_config('executor/topic').with_value( params[:topic] ) } it { is_expected.to contain_mistral_config('executor/topic').with_value( params[:topic] ) }
it { is_expected.to contain_mistral_config('executor/version').with_value( params[:version] ) } it { is_expected.to contain_mistral_config('executor/version').with_value( params[:version] ) }
end end
[{:enabled => true}, {:enabled => false}].each do |param_hash| [{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -51,7 +49,6 @@ describe 'mistral::executor' do
end end
it 'configures mistral-executor service' do it 'configures mistral-executor service' do
is_expected.to contain_service('mistral-executor').with( is_expected.to contain_service('mistral-executor').with(
:ensure => nil, :ensure => nil,
:name => platform_params[:executor_service_name], :name => platform_params[:executor_service_name],
@ -63,37 +60,26 @@ describe 'mistral::executor' do
is_expected.to contain_service('mistral-executor').that_subscribes_to(nil) is_expected.to contain_service('mistral-executor').that_subscribes_to(nil)
end end
end end
end end
context 'on Debian platforms' do on_supported_os({
let :facts do :supported_os => OSDefaults.get_supported_os
OSDefaults.get_facts({ }).each do |os,facts|
:osfamily => 'Debian', context "on #{os}" do
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } }, let (:facts) do
}) facts.merge!(OSDefaults.get_facts())
end end
let :platform_params do let (:platform_params) do
{ :executor_service_name => 'mistral-executor' } case facts[:osfamily]
end when 'Debian'
{ :executor_service_name => 'mistral-executor' }
when 'RedHat'
{ :executor_service_name => 'openstack-mistral-executor' }
end
end
it_configures 'mistral-executor' it_behaves_like 'mistral::executor'
end
end end
context 'on RedHat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Redhat',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '0' } },
})
end
let :platform_params do
{ :executor_service_name => 'openstack-mistral-executor' }
end
it_configures 'mistral-executor'
end
end end

View File

@ -1,4 +1,5 @@
require 'spec_helper' require 'spec_helper'
describe 'mistral' do describe 'mistral' do
let :req_params do let :req_params do
{ {
@ -7,217 +8,220 @@ describe 'mistral' do
} }
end end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
let :pre_condition do let :pre_condition do
"class { '::mistral::keystone::authtoken': "class { '::mistral::keystone::authtoken':
password => 'foo', password => 'foo',
}" }"
end end
describe 'with only required params' do shared_examples 'mistral' do
let :params do context 'with only required params' do
req_params let :params do
req_params
end
it { should contain_class('mistral::logging') }
it { should contain_class('mistral::params') }
it { should contain_class('mysql::bindings::python') }
it 'passes purge to resource' do
should contain_resources('mistral_config').with({
:purge => false
})
end
it 'should contain default config' do
should contain_mistral_config('DEFAULT/control_exchange').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('DEFAULT/rpc_response_timeout').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('DEFAULT/report_interval').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('DEFAULT/service_down_time').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('DEFAULT/transport_url').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_notifications/transport_url').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_notifications/driver').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_notifications/topics').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_rabbit/kombu_reconnect_delay').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('oslo_messaging_rabbit/kombu_failover_strategy').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('coordination/backend_url').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('coordination/heartbeat_interval').with(:value => '<SERVICE DEFAULT>')
should contain_mistral_config('keystone_authtoken/www_authenticate_uri').with(
:value => 'http://localhost:5000'
)
should contain_mistral_config('keystone_authtoken/auth_url').with(
:value => 'http://localhost:5000'
)
should contain_mistral_config('keystone_authtoken/project_name').with(
:value => 'services'
)
should contain_mistral_config('keystone_authtoken/username').with(
:value => 'mistral'
)
should contain_mistral_config('keystone_authtoken/password').with(
:value => 'foo'
)
should contain_mistral_config('DEFAULT/os_actions_endpoint_type').with(
:value => '<SERVICE DEFAULT>'
)
end
end end
it { is_expected.to contain_class('mistral::logging') } context 'with enable ha queues' do
it { is_expected.to contain_class('mistral::params') } let :params do
it { is_expected.to contain_class('mysql::bindings::python') } req_params.merge({'rabbit_ha_queues' => true})
end
it 'passes purge to resource' do it 'should contain rabbit_ha_queues' do
is_expected.to contain_resources('mistral_config').with({ should contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true)
:purge => false end
})
end end
it 'should contain default config' do context 'with rabbit default transport url configured' do
is_expected.to contain_mistral_config('DEFAULT/control_exchange').with(:value => '<SERVICE DEFAULT>') let :params do
is_expected.to contain_mistral_config('DEFAULT/rpc_response_timeout').with(:value => '<SERVICE DEFAULT>') req_params.merge({'default_transport_url' => 'rabbit://user:pass@host:1234/virt' })
is_expected.to contain_mistral_config('DEFAULT/report_interval').with(:value => '<SERVICE DEFAULT>') end
is_expected.to contain_mistral_config('DEFAULT/service_down_time').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/transport_url').with(:value => '<SERVICE DEFAULT>') it 'should contain transport_url' do
is_expected.to contain_mistral_config('oslo_messaging_notifications/transport_url').with(:value => '<SERVICE DEFAULT>') should contain_mistral_config('DEFAULT/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt')
is_expected.to contain_mistral_config('oslo_messaging_notifications/driver').with(:value => '<SERVICE DEFAULT>') end
is_expected.to contain_mistral_config('oslo_messaging_notifications/topics').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_reconnect_delay').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/kombu_failover_strategy').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('coordination/backend_url').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('coordination/heartbeat_interval').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('keystone_authtoken/www_authenticate_uri').with(
:value => 'http://localhost:5000'
)
is_expected.to contain_mistral_config('keystone_authtoken/auth_url').with(
:value => 'http://localhost:5000'
)
is_expected.to contain_mistral_config('keystone_authtoken/project_name').with(
:value => 'services'
)
is_expected.to contain_mistral_config('keystone_authtoken/username').with(
:value => 'mistral'
)
is_expected.to contain_mistral_config('keystone_authtoken/password').with(
:value => 'foo'
)
is_expected.to contain_mistral_config('DEFAULT/os_actions_endpoint_type').with(
:value => '<SERVICE DEFAULT>'
)
end end
end context 'with rabbit notification transport url configured' do
let :params do
req_params.merge({
:notification_transport_url => 'rabbit://user:pass@host:1234/virt',
:notification_topics => 'openstack',
:notification_driver => 'messagingv1',
})
end
describe 'with enable ha queues' do it 'should contain transport_url' do
let :params do should contain_mistral_config('oslo_messaging_notifications/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt')
req_params.merge({'rabbit_ha_queues' => true}) should contain_mistral_config('oslo_messaging_notifications/driver').with(:value => 'messagingv1')
should contain_mistral_config('oslo_messaging_notifications/topics').with(:value => 'openstack')
end
end end
it 'should contain rabbit_ha_queues' do context 'with rabbitmq heartbeats' do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true) let :params do
end req_params.merge({'rabbit_heartbeat_timeout_threshold' => '60', 'rabbit_heartbeat_rate' => '10'})
end end
describe 'with rabbit default transport url configured' do it 'should contain heartbeat config' do
let :params do should contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
req_params.merge({'default_transport_url' => 'rabbit://user:pass@host:1234/virt' }) should contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
end
end end
it 'should contain transport_url' do context 'with SSL enabled with kombu' do
is_expected.to contain_mistral_config('DEFAULT/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt') let :params do
end req_params.merge!({
end :rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
:kombu_ssl_certfile => '/path/to/ssl/cert/file',
:kombu_ssl_keyfile => '/path/to/ssl/keyfile',
:kombu_ssl_version => 'TLSv1'
})
end
describe 'with rabbit notification transport url configured' do it { should contain_oslo__messaging__rabbit('mistral_config').with(
let :params do
req_params.merge({
:notification_transport_url => 'rabbit://user:pass@host:1234/virt',
:notification_topics => 'openstack',
:notification_driver => 'messagingv1',
})
end
it 'should contain transport_url' do
is_expected.to contain_mistral_config('oslo_messaging_notifications/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt')
is_expected.to contain_mistral_config('oslo_messaging_notifications/driver').with(:value => 'messagingv1')
is_expected.to contain_mistral_config('oslo_messaging_notifications/topics').with(:value => 'openstack')
end
end
describe 'with rabbitmq heartbeats' do
let :params do
req_params.merge({'rabbit_heartbeat_timeout_threshold' => '60', 'rabbit_heartbeat_rate' => '10'})
end
it 'should contain heartbeat config' do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
is_expected.to contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
end
end
describe 'with SSL enabled with kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true, :rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs', :kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
:kombu_ssl_certfile => '/path/to/ssl/cert/file', :kombu_ssl_certfile => '/path/to/ssl/cert/file',
:kombu_ssl_keyfile => '/path/to/ssl/keyfile', :kombu_ssl_keyfile => '/path/to/ssl/keyfile',
:kombu_ssl_version => 'TLSv1' :kombu_ssl_version => 'TLSv1'
}) )}
end end
it { is_expected.to contain_oslo__messaging__rabbit('mistral_config').with( context 'with SSL enabled without kombu' do
:rabbit_use_ssl => true, let :params do
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs', req_params.merge!({
:kombu_ssl_certfile => '/path/to/ssl/cert/file', :rabbit_use_ssl => true,
:kombu_ssl_keyfile => '/path/to/ssl/keyfile', })
:kombu_ssl_version => 'TLSv1' end
)}
end
describe 'with SSL enabled without kombu' do it { should contain_oslo__messaging__rabbit('mistral_config').with(
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
})
end
it { is_expected.to contain_oslo__messaging__rabbit('mistral_config').with(
:rabbit_use_ssl => true, :rabbit_use_ssl => true,
)} )}
end
describe 'with SSL disabled' do
let :params do
req_params.merge!({
:rabbit_use_ssl => false,
})
end end
it { is_expected.to contain_oslo__messaging__rabbit('mistral_config').with( context 'with SSL disabled' do
let :params do
req_params.merge!({
:rabbit_use_ssl => false,
})
end
it { should contain_oslo__messaging__rabbit('mistral_config').with(
:rabbit_use_ssl => false, :rabbit_use_ssl => false,
)} )}
end
describe 'with amqp_durable_queues disabled' do
let :params do
req_params
end end
it { is_expected.to contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') } context 'with amqp_durable_queues disabled' do
end let :params do
req_params
end
describe 'with amqp_durable_queues enabled' do it { should contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') }
let :params do
req_params.merge({
:amqp_durable_queues => true,
})
end end
it { is_expected.to contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) } context 'with amqp_durable_queues enabled' do
end let :params do
req_params.merge({
:amqp_durable_queues => true,
})
end
describe 'with postgresql' do it { should contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
let :params do
req_params.merge({
:database_connection => 'postgresql://user:drowssap@host/database',
})
end end
it { is_expected.to_not contain_class('mysql::python') } context 'with postgresql' do
it { is_expected.to_not contain_class('mysql::bindings') } let :params do
it { is_expected.to_not contain_class('mysql::bindings::python') } req_params.merge({
end :database_connection => 'postgresql://user:drowssap@host/database',
})
end
describe 'with coordination' do it { should_not contain_class('mysql::python') }
let :params do it { should_not contain_class('mysql::bindings') }
req_params.merge({ it { should_not contain_class('mysql::bindings::python') }
:coordination_backend_url => 'redis://127.0.0.1',
:coordination_heartbeat_interval => '10.0',
})
end end
it 'should contain coordination config' do context 'with coordination' do
is_expected.to contain_mistral_config('coordination/backend_url').with(:value => 'redis://127.0.0.1') let :params do
is_expected.to contain_mistral_config('coordination/heartbeat_interval').with(:value => '10.0') req_params.merge({
:coordination_backend_url => 'redis://127.0.0.1',
:coordination_heartbeat_interval => '10.0',
})
end
it 'should contain coordination config' do
should contain_mistral_config('coordination/backend_url').with(:value => 'redis://127.0.0.1')
should contain_mistral_config('coordination/heartbeat_interval').with(:value => '10.0')
end
end
context 'with os_actions_keystone_endpoint overridden' do
let :params do
req_params.merge({
:os_actions_endpoint_type => 'internal',
})
end
it { should contain_mistral_config('DEFAULT/os_actions_endpoint_type').with_value('internal') }
end end
end end
describe 'with os_actions_keystone_endpoint overridden' do on_supported_os({
let :params do :supported_os => OSDefaults.get_supported_os
req_params.merge({ }).each do |os,facts|
:os_actions_endpoint_type => 'internal', context "on #{os}" do
}) let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'mistral'
end end
it { is_expected.to contain_mistral_config('DEFAULT/os_actions_endpoint_type').with_value('internal') }
end end
end end

View File

@ -1,93 +1,98 @@
#
# Unit tests for mistral::keystone::auth
#
require 'spec_helper' require 'spec_helper'
describe 'mistral::keystone::auth' do describe 'mistral::keystone::auth' do
shared_examples 'mistral::keystone::auth' do
context 'with default class parameters' do
let :params do
{
:password => 'mistral_password',
:tenant => 'services'
}
end
let :facts do it { should contain_keystone_user('mistral').with(
{ :osfamily => 'Debian', :ensure => 'present',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } }, } :password => 'mistral_password',
end )}
describe 'with default class parameters' do it { should contain_keystone_user_role('mistral@services').with(
let :params do :ensure => 'present',
{ :password => 'mistral_password', :roles => ['admin']
:tenant => 'services' } )}
it { should contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present',
:description => 'OpenStack Workflow Service'
)}
it { should contain_keystone_endpoint('RegionOne/mistral::workflowv2').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:8989/v2",
:admin_url => "http://127.0.0.1:8989/v2",
:internal_url => "http://127.0.0.1:8989/v2"
)}
end end
it { is_expected.to contain_keystone_user('mistral').with( context 'when overriding auth and service name' do
:ensure => 'present', let :params do
:password => 'mistral_password', {
) } :service_name => 'mistraly',
:auth_name => 'mistraly',
:password => 'mistral_password'
}
end
it { is_expected.to contain_keystone_user_role('mistral@services').with( it { should contain_keystone_user('mistraly') }
:ensure => 'present', it { should contain_keystone_user_role('mistraly@services') }
:roles => ['admin'] it { should contain_keystone_service('mistraly::workflowv2') }
)} it { should contain_keystone_endpoint('RegionOne/mistraly::workflowv2') }
it { is_expected.to contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present',
:description => 'OpenStack Workflow Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/mistral::workflowv2').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:8989/v2",
:admin_url => "http://127.0.0.1:8989/v2",
:internal_url => "http://127.0.0.1:8989/v2"
) }
end
describe 'when overriding auth and service name' do
let :params do
{ :service_name => 'mistraly',
:auth_name => 'mistraly',
:password => 'mistral_password' }
end end
it { is_expected.to contain_keystone_user('mistraly') } context 'when disabling user configuration' do
it { is_expected.to contain_keystone_user_role('mistraly@services') } let :params do
it { is_expected.to contain_keystone_service('mistraly::workflowv2') } {
it { is_expected.to contain_keystone_endpoint('RegionOne/mistraly::workflowv2') } :password => 'mistral_password',
end :configure_user => false
}
end
describe 'when disabling user configuration' do it { should_not contain_keystone_user('mistral') }
it { should contain_keystone_user_role('mistral@services') }
let :params do it { should contain_keystone_service('mistral::workflowv2').with(
{ :ensure => 'present',
:password => 'mistral_password', :description => 'OpenStack Workflow Service'
:configure_user => false )}
}
end end
it { is_expected.not_to contain_keystone_user('mistral') } context 'when disabling user and user role configuration' do
it { is_expected.to contain_keystone_user_role('mistral@services') } let :params do
it { is_expected.to contain_keystone_service('mistral::workflowv2').with( {
:ensure => 'present', :password => 'mistral_password',
:description => 'OpenStack Workflow Service' :configure_user => false,
) } :configure_user_role => false
}
end
end it { should_not contain_keystone_user('mistral') }
it { should_not contain_keystone_user_role('mistral@services') }
describe 'when disabling user and user role configuration' do it { should contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present',
let :params do :description => 'OpenStack Workflow Service'
{ )}
:password => 'mistral_password',
:configure_user => false,
:configure_user_role => false
}
end end
it { is_expected.not_to contain_keystone_user('mistral') }
it { is_expected.not_to contain_keystone_user_role('mistral@services') }
it { is_expected.to contain_keystone_service('mistral::workflowv2').with(
:ensure => 'present',
:description => 'OpenStack Workflow Service'
) }
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 'mistral::keystone::auth'
end
end
end end