Fix values for rabbit_hosts

When rabbit_hosts parameter isn't set (service_default is used)
we are forming its value in that way: "$rabbit_host:$rabbit_port".
But when host or port or both aren't set (they are also service_default)
we can get rabbit_hosts set to "$rabbit_host:<SERVICE DEFAULT>"
or "<SERVICE DEFAULT>:$rabbit_port" or "<SERVICE DEFAULT>:<SERVICE DEFAULT>".
This patch fixes the issue. rabbit_hosts parameter will be set only if it's passed.

Change-Id: I9aed2b8a8718e0b0cfca3e25ef93fcff2ad8444a
changes/64/293964/7
iberezovskiy 7 years ago
parent 14b9a2d9f6
commit 5b4a439df1

@ -189,13 +189,14 @@ define oslo::messaging_rabbit(
$rabbit_ha_queues_orig = $rabbit_ha_queues
}
# Do not set rabbit_port and rabbit_host
$rabbit_port_orig = $::os_service_default
$rabbit_host_orig = $::os_service_default
$rabbit_port_orig = $::os_service_default
$rabbit_host_orig = $::os_service_default
} else {
$rabbit_hosts_orig = "${rabbit_host}:${rabbit_port}"
$rabbit_port_orig = $rabbit_port
$rabbit_host_orig = $rabbit_host
$rabbit_ha_queues_orig = $rabbit_ha_queues
# Do not set rabbit_hosts if host or port or both are set
$rabbit_hosts_orig = $::os_service_default
}
$rabbit_options = { 'oslo_messaging_rabbit/amqp_durable_queues' => { value => $amqp_durable_queues },

@ -15,6 +15,7 @@ describe 'oslo::messaging_rabbit' do
is_expected.to contain_keystone_config('oslo_messaging_rabbit/kombu_compression').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_hosts').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_userid').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_password').with_value('<SERVICE DEFAULT>')
@ -128,6 +129,33 @@ describe 'oslo::messaging_rabbit' do
end
end
context 'with rabbit host set without rabbit port' do
let :params do
{ :rabbit_host => 'rabbit1' }
end
it 'configures rabbit' do
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('rabbit1')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_hosts').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
end
end
context 'with rabbit host and port' do
let :params do
{ :rabbit_host => 'rabbit1',
:rabbit_port => '5673' }
end
it 'configures rabbit' do
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_host').with_value('rabbit1')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_port').with_value('5673')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_hosts').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
end
end
context 'with incorrect rabbit hosts' do
let :params do
{ :rabbit_hosts => 'rabbit1:5672,rabbit2:5673' }

Loading…
Cancel
Save