Merge "Messaging notifications should be set as a list"

This commit is contained in:
Zuul 2020-04-14 06:45:55 +00:00 committed by Gerrit Code Review
commit adc3147bcb
2 changed files with 22 additions and 7 deletions

View File

@ -10,7 +10,7 @@
# [*driver*]
# (Optional) The Driver(s) to handle sending notifications.
# Possible values are messaging, messagingv2, routing, log, test, noop.
# (list value)
# (list value or string value)
# Defaults to $::os_service_default.
#
# [*transport_url*]
@ -32,10 +32,12 @@ define oslo::messaging::notifications(
$transport_url = $::os_service_default,
$topics = $::os_service_default,
) {
if !is_service_default($driver) {
$driver_orig = join(any2array($driver), ',')
} else {
if is_service_default($driver) or is_string($driver) {
# When we have a string value for driver, we keep passing it as string
# to reduce any chance of breaking things in a backwards incompatible way
$driver_orig = $driver
} else {
$driver_orig = any2array($driver)
}
if !is_service_default($topics) {

View File

@ -17,15 +17,28 @@ describe 'oslo::messaging::notifications' do
context 'with overridden parameters' do
let :params do
{ :driver => ['messaging'],
{ :driver => ['messaging', 'messagingv2'],
:transport_url => 'some_protocol://some_url',
:topics => ['foo', 'baa'],
}
end
it 'configure oslo_messaging_notifications with overridden values' do
is_expected.to contain_keystone_config('oslo_messaging_notifications/driver').with_value(['messaging', 'messagingv2'])
is_expected.to contain_keystone_config('oslo_messaging_notifications/transport_url').with_value('some_protocol://some_url').with_secret(true)
is_expected.to contain_keystone_config('oslo_messaging_notifications/topics').with_value('foo,baa')
end
end
context 'with a single item in lists' do
let :params do
{ :driver => ['messaging'],
:topics => ['notifications'],
}
end
it 'configure oslo_messaging_notifications with overridden values' do
is_expected.to contain_keystone_config('oslo_messaging_notifications/driver').with_value('messaging')
is_expected.to contain_keystone_config('oslo_messaging_notifications/transport_url').with_value('some_protocol://some_url').with_secret(true)
is_expected.to contain_keystone_config('oslo_messaging_notifications/driver').with_value(['messaging'])
is_expected.to contain_keystone_config('oslo_messaging_notifications/topics').with_value('notifications')
end
end