2016-06-07 14:57:13 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'watcher' do
|
|
|
|
|
|
|
|
shared_examples 'watcher' do
|
|
|
|
|
|
|
|
context 'with default parameters' do
|
2016-10-27 00:18:59 +08:00
|
|
|
let :params do
|
|
|
|
{ :purge_config => false }
|
|
|
|
end
|
|
|
|
|
2019-02-04 10:30:12 +01:00
|
|
|
it { should contain_class('openstacklib::openstackclient') }
|
|
|
|
|
2016-06-07 14:57:13 +00:00
|
|
|
it 'contains the db class' do
|
|
|
|
is_expected.to contain_class('watcher::db')
|
|
|
|
end
|
|
|
|
|
2016-06-28 14:41:47 +00:00
|
|
|
it 'installs packages' do
|
|
|
|
is_expected.to contain_package('watcher').with(
|
|
|
|
:name => platform_params[:watcher_common_package],
|
|
|
|
:ensure => 'present',
|
|
|
|
:tag => ['openstack', 'watcher-package']
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to contain_class('watcher::policy') }
|
2016-12-01 17:54:42 +08:00
|
|
|
it { is_expected.to contain_class('watcher::deps') }
|
2016-06-28 14:41:47 +00:00
|
|
|
|
2023-09-15 14:55:58 +09:00
|
|
|
it 'configures messaging' do
|
|
|
|
is_expected.to contain_oslo__messaging__default('watcher_config').with(
|
|
|
|
:transport_url => '<SERVICE DEFAULT>',
|
|
|
|
:rpc_response_timeout => '<SERVICE DEFAULT>',
|
|
|
|
:control_exchange => '<SERVICE DEFAULT>'
|
|
|
|
)
|
|
|
|
is_expected.to contain_oslo__messaging__rabbit('watcher_config').with(
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_use_ssl => '<SERVICE DEFAULT>',
|
|
|
|
:heartbeat_timeout_threshold => '<SERVICE DEFAULT>',
|
|
|
|
:heartbeat_rate => '<SERVICE DEFAULT>',
|
2025-02-18 11:12:28 +09:00
|
|
|
:heartbeat_in_pthread => nil,
|
2024-09-27 22:38:55 +09:00
|
|
|
:kombu_reconnect_delay => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_failover_strategy => '<SERVICE DEFAULT>',
|
|
|
|
:amqp_durable_queues => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_compression => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_version => '<SERVICE DEFAULT>',
|
|
|
|
:rabbit_ha_queues => '<SERVICE DEFAULT>',
|
|
|
|
:rabbit_quorum_queue => '<SERVICE DEFAULT>',
|
2024-09-27 22:41:34 +09:00
|
|
|
:rabbit_transient_quorum_queue => '<SERVICE DEFAULT>',
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_quorum_delivery_limit => '<SERVICE DEFAULT>',
|
|
|
|
:rabbit_quorum_max_memory_length => '<SERVICE DEFAULT>',
|
|
|
|
:rabbit_quorum_max_memory_bytes => '<SERVICE DEFAULT>',
|
2024-10-01 14:43:13 +09:00
|
|
|
:enable_cancel_on_failover => '<SERVICE DEFAULT>',
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_retry_interval => '<SERVICE DEFAULT>',
|
2023-09-15 14:55:58 +09:00
|
|
|
)
|
|
|
|
is_expected.to contain_oslo__messaging__notifications('watcher_config').with(
|
|
|
|
:transport_url => '<SERVICE DEFAULT>',
|
|
|
|
:driver => '<SERVICE DEFAULT>',
|
2024-09-30 22:57:54 +09:00
|
|
|
:topics => '<SERVICE DEFAULT>',
|
|
|
|
:retry => '<SERVICE DEFAULT>',
|
2023-09-15 14:55:58 +09:00
|
|
|
)
|
2016-06-07 14:57:13 +00:00
|
|
|
end
|
2016-10-27 00:18:59 +08:00
|
|
|
|
|
|
|
it 'passes purge to resource' do
|
|
|
|
is_expected.to contain_resources('watcher_config').with({
|
|
|
|
:purge => false
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2016-06-07 14:57:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with overridden parameters' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
|
2023-09-15 14:55:58 +09:00
|
|
|
:rpc_response_timeout => '120',
|
|
|
|
:control_exchange => 'watcher',
|
|
|
|
:rabbit_ha_queues => 'true',
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_quorum_queue => true,
|
2024-09-27 22:41:34 +09:00
|
|
|
:rabbit_transient_quorum_queue => true,
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_quorum_delivery_limit => 3,
|
|
|
|
:rabbit_quorum_max_memory_length => 5,
|
|
|
|
:rabbit_quorum_max_memory_bytes => 1073741824,
|
2024-10-01 14:43:13 +09:00
|
|
|
:rabbit_enable_cancel_on_failover => false,
|
2016-06-07 14:57:13 +00:00
|
|
|
:rabbit_heartbeat_timeout_threshold => '60',
|
|
|
|
:rabbit_heartbeat_rate => '10',
|
2019-08-21 14:21:01 +08:00
|
|
|
:rabbit_heartbeat_in_pthread => true,
|
2023-09-15 14:55:58 +09:00
|
|
|
:amqp_durable_queues => true,
|
2016-06-07 14:57:13 +00:00
|
|
|
:kombu_compression => 'gzip',
|
2023-09-15 14:55:58 +09:00
|
|
|
:kombu_failover_strategy => 'shuffle',
|
|
|
|
:kombu_reconnect_delay => '5.0',
|
2016-06-07 14:57:13 +00:00
|
|
|
:notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
|
2023-09-15 14:55:58 +09:00
|
|
|
:notification_driver => 'messaging',
|
2016-06-07 14:57:13 +00:00
|
|
|
:notification_topics => 'notifications',
|
2024-09-30 22:57:54 +09:00
|
|
|
:notification_retry => 10,
|
2016-06-07 14:57:13 +00:00
|
|
|
}
|
|
|
|
end
|
2023-09-15 14:55:58 +09:00
|
|
|
it 'configures messaging' do
|
|
|
|
is_expected.to contain_oslo__messaging__default('watcher_config').with(
|
|
|
|
:transport_url => 'rabbit://rabbit_user:password@localhost:5673',
|
|
|
|
:rpc_response_timeout => '120',
|
|
|
|
:control_exchange => 'watcher'
|
|
|
|
)
|
2017-03-13 21:37:02 +08:00
|
|
|
is_expected.to contain_oslo__messaging__rabbit('watcher_config').with(
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_use_ssl => '<SERVICE DEFAULT>',
|
|
|
|
:heartbeat_timeout_threshold => '60',
|
|
|
|
:heartbeat_rate => '10',
|
|
|
|
:heartbeat_in_pthread => true,
|
|
|
|
:kombu_reconnect_delay => '5.0',
|
|
|
|
:kombu_failover_strategy => 'shuffle',
|
|
|
|
:amqp_durable_queues => true,
|
|
|
|
:kombu_compression => 'gzip',
|
|
|
|
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_version => '<SERVICE DEFAULT>',
|
|
|
|
:rabbit_ha_queues => true,
|
|
|
|
:rabbit_quorum_queue => true,
|
2024-09-27 22:41:34 +09:00
|
|
|
:rabbit_transient_quorum_queue => true,
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_quorum_delivery_limit => 3,
|
|
|
|
:rabbit_quorum_max_memory_length => 5,
|
|
|
|
:rabbit_quorum_max_memory_bytes => 1073741824,
|
2024-10-01 14:43:13 +09:00
|
|
|
:enable_cancel_on_failover => false,
|
2024-09-27 22:38:55 +09:00
|
|
|
:rabbit_retry_interval => '<SERVICE DEFAULT>',
|
2023-09-15 14:55:58 +09:00
|
|
|
)
|
|
|
|
is_expected.to contain_oslo__messaging__notifications('watcher_config').with(
|
|
|
|
:transport_url => 'rabbit://rabbit_user:password@localhost:5673',
|
|
|
|
:driver => 'messaging',
|
2024-09-30 22:57:54 +09:00
|
|
|
:topics => 'notifications',
|
|
|
|
:retry => 10,
|
2017-03-13 21:37:02 +08:00
|
|
|
)
|
2016-06-07 14:57:13 +00:00
|
|
|
end
|
2023-09-15 14:55:58 +09:00
|
|
|
|
2016-06-07 14:57:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with rabbit ssl enabled with kombu' do
|
|
|
|
let :params do
|
2016-11-08 16:12:43 -07:00
|
|
|
{ :rabbit_use_ssl => true,
|
2016-06-07 14:57:13 +00:00
|
|
|
:kombu_ssl_ca_certs => '/etc/ca.cert',
|
|
|
|
:kombu_ssl_certfile => '/etc/certfile',
|
|
|
|
:kombu_ssl_keyfile => '/etc/key',
|
|
|
|
:kombu_ssl_version => 'TLSv1', }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures rabbit' do
|
2017-03-13 21:37:02 +08:00
|
|
|
is_expected.to contain_oslo__messaging__rabbit('watcher_config').with(
|
|
|
|
:rabbit_use_ssl => true,
|
|
|
|
:kombu_ssl_ca_certs => '/etc/ca.cert',
|
|
|
|
:kombu_ssl_certfile => '/etc/certfile',
|
|
|
|
:kombu_ssl_keyfile => '/etc/key',
|
|
|
|
:kombu_ssl_version => 'TLSv1',
|
|
|
|
)
|
2016-06-07 14:57:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with rabbit ssl enabled without kombu' do
|
|
|
|
let :params do
|
2016-11-08 16:12:43 -07:00
|
|
|
{ :rabbit_use_ssl => true, }
|
2016-06-07 14:57:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'configures rabbit' do
|
2017-03-13 21:37:02 +08:00
|
|
|
is_expected.to contain_oslo__messaging__rabbit('watcher_config').with(
|
|
|
|
:rabbit_use_ssl => true,
|
|
|
|
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
|
|
|
|
:kombu_ssl_version => '<SERVICE DEFAULT>',
|
|
|
|
)
|
2016-06-07 14:57:13 +00:00
|
|
|
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
|
2016-06-28 14:41:47 +00:00
|
|
|
let(:platform_params) do
|
2023-03-02 12:46:00 +09:00
|
|
|
case facts[:os]['family']
|
2016-06-28 14:41:47 +00:00
|
|
|
when 'Debian'
|
|
|
|
{ :watcher_common_package => 'watcher-common' }
|
|
|
|
when 'RedHat'
|
|
|
|
{ :watcher_common_package => 'openstack-watcher-common' }
|
|
|
|
end
|
|
|
|
end
|
2016-06-07 14:57:13 +00:00
|
|
|
it_behaves_like 'watcher'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|