1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
require 'spec_helper'
describe 'mistral::notifier' do
shared_examples_for 'mistral::notifier' do
context 'with defaults' do
it 'configure notifier default params' do
is_expected.to contain_mistral_config('notifier/type').with_value('remote')
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/topic').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/notify').with_value('<SERVICE DEFAULT>')
end
it 'installs mistral-notifier package' do
if platform_params.has_key?(:notifier_package_name)
is_expected.to contain_package('mistral-notifier').with(
:ensure => 'present',
:name => platform_params[:notifier_package_name],
:tag => ['openstack', 'mistral-package']
)
end
end
it 'configures mistral-notifier service' do
if platform_params.has_key?(:notifier_service_name)
is_expected.to contain_service('mistral-notifier').with(
:ensure => 'running',
:name => platform_params[:notifier_service_name],
:enable => true,
:hasstatus => true,
:hasrestart => true,
:tag => 'mistral-service',
)
end
end
end
context 'with specific parameters' do
let :params do
{ :type => 'local',
:host => 'localhost',
:topic => 'mistral-event-stream',
:notify_publishers => '[{\'type\': \'noop\'}]',
}
end
it 'configure notifier params' do
is_expected.to contain_mistral_config('notifier/type').with_value('local')
is_expected.to contain_mistral_config('notifier/host').with_value('localhost')
is_expected.to contain_mistral_config('notifier/topic').with_value('mistral-event-stream')
is_expected.to contain_mistral_config('notifier/notify').with_value("[{'type': 'noop'}]")
end
it 'disables mistral-notifier service' do
if platform_params.has_key?(:notifier_service_name)
is_expected.to contain_service('mistral-notifier').with(
:ensure => 'stopped',
:name => platform_params[:notifier_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => 'mistral-service',
)
end
end
end
context 'with service disabled' do
let :params do
{ :enabled => false }
end
it 'configures mistral-notifier service' do
if platform_params.has_key?(:notifier_service_name)
is_expected.to contain_service('mistral-notifier').with(
:ensure => 'stopped',
:name => platform_params[:notifier_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => 'mistral-service',
)
end
end
end
context 'with service unmanaged' do
let :params do
{ :manage_service => false }
end
it 'does not configure mistral-notifier service' do
is_expected.to_not contain_service('mistral-notifier')
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
let (:platform_params) do
case facts[:os]['family']
when 'Debian'
{}
when 'RedHat'
{
:notifier_package_name => 'openstack-mistral-notifier',
:notifier_service_name => 'openstack-mistral-notifier'
}
end
end
it_configures 'mistral::notifier'
end
end
end
|