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

View File

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

View File

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

View File

@ -1,12 +1,9 @@
require 'spec_helper'
describe 'mistral::db' do
shared_examples 'mistral::db' do
context 'with default parameters' do
it { is_expected.to contain_oslo__db('mistral_config').with(
it { should contain_oslo__db('mistral_config').with(
:db_max_retries => '<SERVICE DEFAULT>',
:connection => 'sqlite:////var/lib/mistral/mistral.sqlite',
:idle_timeout => '<SERVICE DEFAULT>',
@ -17,12 +14,12 @@ describe 'mistral::db' do
:max_overflow => '<SERVICE DEFAULT>',
:pool_timeout => '<SERVICE DEFAULT>',
)}
end
context 'with specific parameters' 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_min_pool_size => '2',
:database_max_pool_size => '11',
@ -34,7 +31,7 @@ describe 'mistral::db' do
}
end
it { is_expected.to contain_oslo__db('mistral_config').with(
it { should contain_oslo__db('mistral_config').with(
:db_max_retries => '-1',
:connection => 'mysql+pymysql://mistral:mistral@localhost/mistral',
:idle_timeout => '3601',
@ -49,101 +46,54 @@ describe 'mistral::db' do
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://mistral:mistral@localhost/mistral', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
{
:database_connection => 'postgresql://mistral:mistral@localhost/mistral'
}
end
it { should contain_package('python-psycopg2').with_ensure('present') }
end
context 'with MySQL-python library as backend package' do
let :params do
{ :database_connection => 'mysql://mistral:mistral@localhost/mistral', }
{
:database_connection => 'mysql://mistral:mistral@localhost/mistral'
}
end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
it { should contain_package('python-mysqldb').with_ensure('present') }
end
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'redis://mistral:mistral@localhost/mistral', }
{
:database_connection => 'redis://mistral:mistral@localhost/mistral'
}
end
it_raises 'a Puppet::Error', /validate_re/
it { should raise_error(Puppet::Error, /validate_re/) }
end
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://mistral:mistral@localhost/mistral', }
end
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', }
{
:database_connection => 'foo+pymysql://mistral:mistral@localhost/mistral'
}
end
it { should raise_error(Puppet::Error, /validate_re/) }
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

View File

@ -1,17 +1,30 @@
require 'spec_helper'
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
is_expected.to contain_anchor('mistral::install::begin')
is_expected.to contain_anchor('mistral::install::end')
is_expected.to contain_anchor('mistral::config::begin')
is_expected.to contain_anchor('mistral::config::end')
is_expected.to contain_anchor('mistral::db::begin')
is_expected.to contain_anchor('mistral::db::end')
is_expected.to contain_anchor('mistral::dbsync::begin')
is_expected.to contain_anchor('mistral::dbsync::end')
is_expected.to contain_anchor('mistral::service::begin')
is_expected.to contain_anchor('mistral::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 'mistral::deps'
end
end
end

View File

@ -1,22 +1,21 @@
require 'spec_helper'
describe 'mistral::engine' do
let :params do
{ :enabled => true,
:manage_service => true,
:host => 'foo_host',
:topic => 'foo_topic',
:version => '1.0',
:execution_field_size_limit_kb => '1234',
:evaluation_interval => 1234,
:older_than => 60}
{
:enabled => true,
:manage_service => true,
:host => 'foo_host',
:topic => 'foo_topic',
:version => '1.0',
:execution_field_size_limit_kb => '1234',
:evaluation_interval => 1234,
:older_than => 60
}
end
shared_examples_for 'mistral-engine' do
shared_examples 'mistral::engine' do
context 'config params' do
it { is_expected.to contain_class('mistral::params') }
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('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] ) }
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -35,7 +33,6 @@ describe 'mistral::engine' do
end
it 'configures mistral-engine service' do
is_expected.to contain_service('mistral-engine').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:engine_service_name],
@ -57,7 +54,6 @@ describe 'mistral::engine' do
end
it 'configures mistral-engine service' do
is_expected.to contain_service('mistral-engine').with(
:ensure => nil,
: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)
end
end
end
context 'on Debian platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
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
let :platform_params do
{ :engine_service_name => 'mistral-engine' }
end
let (:platform_params) do
case facts[:osfamily]
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
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

View File

@ -1,25 +1,23 @@
require 'spec_helper'
describe 'mistral::executor' do
let :params do
{ :enabled => true,
:manage_service => true,
:host => true,
:topic => true,
:version => true}
{
:enabled => true,
:manage_service => true,
:host => true,
:topic => true,
:version => true
}
end
shared_examples_for 'mistral-executor' do
shared_examples 'mistral::executor' do
context 'config params' do
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/topic').with_value( params[:topic] ) }
it { is_expected.to contain_mistral_config('executor/version').with_value( params[:version] ) }
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -51,7 +49,6 @@ describe 'mistral::executor' do
end
it 'configures mistral-executor service' do
is_expected.to contain_service('mistral-executor').with(
:ensure => nil,
: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)
end
end
end
context 'on Debian platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
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
let :platform_params do
{ :executor_service_name => 'mistral-executor' }
end
let (:platform_params) do
case facts[:osfamily]
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
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

View File

@ -1,4 +1,5 @@
require 'spec_helper'
describe 'mistral' do
let :req_params do
{
@ -7,217 +8,220 @@ describe 'mistral' do
}
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
"class { '::mistral::keystone::authtoken':
password => 'foo',
}"
"class { '::mistral::keystone::authtoken':
password => 'foo',
}"
end
describe 'with only required params' do
let :params do
req_params
shared_examples 'mistral' do
context 'with only required params' do
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
it { is_expected.to contain_class('mistral::logging') }
it { is_expected.to contain_class('mistral::params') }
it { is_expected.to contain_class('mysql::bindings::python') }
context 'with enable ha queues' do
let :params do
req_params.merge({'rabbit_ha_queues' => true})
end
it 'passes purge to resource' do
is_expected.to contain_resources('mistral_config').with({
:purge => false
})
it 'should contain rabbit_ha_queues' do
should contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true)
end
end
it 'should contain default config' do
is_expected.to contain_mistral_config('DEFAULT/control_exchange').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/rpc_response_timeout').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('DEFAULT/report_interval').with(:value => '<SERVICE DEFAULT>')
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>')
is_expected.to contain_mistral_config('oslo_messaging_notifications/transport_url').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('oslo_messaging_notifications/driver').with(:value => '<SERVICE DEFAULT>')
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>'
)
context 'with rabbit default transport url configured' do
let :params do
req_params.merge({'default_transport_url' => 'rabbit://user:pass@host:1234/virt' })
end
it 'should contain transport_url' do
should contain_mistral_config('DEFAULT/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt')
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
let :params do
req_params.merge({'rabbit_ha_queues' => true})
it 'should contain transport_url' do
should contain_mistral_config('oslo_messaging_notifications/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt')
should contain_mistral_config('oslo_messaging_notifications/driver').with(:value => 'messagingv1')
should contain_mistral_config('oslo_messaging_notifications/topics').with(:value => 'openstack')
end
end
it 'should contain rabbit_ha_queues' do
is_expected.to contain_mistral_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true)
end
end
context 'with rabbitmq heartbeats' do
let :params do
req_params.merge({'rabbit_heartbeat_timeout_threshold' => '60', 'rabbit_heartbeat_rate' => '10'})
end
describe 'with rabbit default transport url configured' do
let :params do
req_params.merge({'default_transport_url' => 'rabbit://user:pass@host:1234/virt' })
it 'should contain heartbeat config' do
should contain_mistral_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
should contain_mistral_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
end
end
it 'should contain transport_url' do
is_expected.to contain_mistral_config('DEFAULT/transport_url').with(:value => 'rabbit://user:pass@host:1234/virt')
end
end
context 'with SSL enabled with kombu' do
let :params do
req_params.merge!({
: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
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!({
it { should contain_oslo__messaging__rabbit('mistral_config').with(
: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
it { is_expected.to contain_oslo__messaging__rabbit('mistral_config').with(
: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
context 'with SSL enabled without kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
})
end
describe 'with SSL enabled without kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
})
end
it { is_expected.to contain_oslo__messaging__rabbit('mistral_config').with(
it { should contain_oslo__messaging__rabbit('mistral_config').with(
:rabbit_use_ssl => true,
)}
end
describe 'with SSL disabled' do
let :params do
req_params.merge!({
:rabbit_use_ssl => false,
})
)}
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,
)}
end
describe 'with amqp_durable_queues disabled' do
let :params do
req_params
)}
end
it { is_expected.to contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') }
end
context 'with amqp_durable_queues disabled' do
let :params do
req_params
end
describe 'with amqp_durable_queues enabled' do
let :params do
req_params.merge({
:amqp_durable_queues => true,
})
it { should contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') }
end
it { is_expected.to contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
end
context 'with amqp_durable_queues enabled' do
let :params do
req_params.merge({
:amqp_durable_queues => true,
})
end
describe 'with postgresql' do
let :params do
req_params.merge({
:database_connection => 'postgresql://user:drowssap@host/database',
})
it { should contain_mistral_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
end
it { is_expected.to_not contain_class('mysql::python') }
it { is_expected.to_not contain_class('mysql::bindings') }
it { is_expected.to_not contain_class('mysql::bindings::python') }
end
context 'with postgresql' do
let :params do
req_params.merge({
:database_connection => 'postgresql://user:drowssap@host/database',
})
end
describe 'with coordination' do
let :params do
req_params.merge({
:coordination_backend_url => 'redis://127.0.0.1',
:coordination_heartbeat_interval => '10.0',
})
it { should_not contain_class('mysql::python') }
it { should_not contain_class('mysql::bindings') }
it { should_not contain_class('mysql::bindings::python') }
end
it 'should contain coordination config' do
is_expected.to contain_mistral_config('coordination/backend_url').with(:value => 'redis://127.0.0.1')
is_expected.to contain_mistral_config('coordination/heartbeat_interval').with(:value => '10.0')
context 'with coordination' do
let :params do
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
describe 'with os_actions_keystone_endpoint overridden' do
let :params do
req_params.merge({
:os_actions_endpoint_type => 'internal',
})
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'
end
it { is_expected.to contain_mistral_config('DEFAULT/os_actions_endpoint_type').with_value('internal') }
end
end

View File

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