From ed6e54bf510919ad4fca29be94b73f71ccda8a73 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 21 Jan 2022 09:01:46 +0900 Subject: [PATCH] Avoid testing details of oslo::messaging(::*) ... so that any change in puppet-oslo would not directly break unit tests. Change-Id: Ib6b2dbe5301604dac0f6790843931c6e367dcbec --- spec/classes/heat_init_spec.rb | 197 ++++++++++++++++----------------- 1 file changed, 98 insertions(+), 99 deletions(-) diff --git a/spec/classes/heat_init_spec.rb b/spec/classes/heat_init_spec.rb index bf5029e3..a5f33e81 100644 --- a/spec/classes/heat_init_spec.rb +++ b/spec/classes/heat_init_spec.rb @@ -41,7 +41,6 @@ describe 'heat' do it_configures 'with SSL enabled with kombu' it_configures 'with SSL enabled without kombu' it_configures 'with SSL disabled' - it_configures 'with SSL wrongly configured' it_configures 'with enable_stack_adopt and enable_stack_abandon set' it_configures 'with overridden transport_url parameter' it_configures 'with notification_driver set to a string' @@ -130,9 +129,11 @@ describe 'heat' do it { is_expected.to contain_heat_config('paste_deploy/flavor').with_value('keystone') } it 'configures notification_driver' do - is_expected.to contain_heat_config('oslo_messaging_notifications/transport_url').with_value('') - is_expected.to contain_heat_config('oslo_messaging_notifications/driver').with_value('') - is_expected.to contain_heat_config('oslo_messaging_notifications/topics').with_value('') + is_expected.to contain_oslo__messaging__notifications('heat_config').with( + :driver => '', + :transport_url => '', + :topics => '' + ) end it 'sets default value for http_proxy_to_wsgi middleware' do @@ -150,23 +151,22 @@ describe 'heat' do shared_examples_for 'configures default rabbitmq parameters' do it 'configures rabbit' do - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_compression').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_in_pthread').with_value('') is_expected.to contain_oslo__messaging__rabbit('heat_config').with( - :rabbit_use_ssl => '', - :kombu_ssl_ca_certs => '', - :kombu_ssl_certfile => '', - :kombu_ssl_keyfile => '', - :kombu_ssl_version => '', + :kombu_ssl_version => '', + :kombu_ssl_keyfile => '', + :kombu_ssl_certfile => '', + :kombu_ssl_ca_certs => '', + :kombu_reconnect_delay => '', + :kombu_failover_strategy => '', + :kombu_compression => '', + :heartbeat_timeout_threshold => '', + :heartbeat_rate => '', + :heartbeat_in_pthread => '', + :rabbit_use_ssl => '', + :amqp_durable_queues => '', + :rabbit_ha_queues => '', ) end - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('') } - it { is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('') } end shared_examples_for 'configures rabbit with HA and durable' do @@ -175,26 +175,43 @@ describe 'heat' do :amqp_durable_queues => true ) end - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true) } - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) } + it 'configures rabbit' do + is_expected.to contain_oslo__messaging__rabbit('heat_config').with( + :kombu_ssl_version => '', + :kombu_ssl_keyfile => '', + :kombu_ssl_certfile => '', + :kombu_ssl_ca_certs => '', + :kombu_reconnect_delay => '', + :kombu_failover_strategy => '', + :kombu_compression => '', + :heartbeat_timeout_threshold => '', + :heartbeat_rate => '', + :heartbeat_in_pthread => '', + :rabbit_use_ssl => '', + :amqp_durable_queues => true, + :rabbit_ha_queues => true, + ) + end end shared_examples_for 'rabbit with heartbeat configured' do it 'configures rabbit' do - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_compression').with_value('') is_expected.to contain_oslo__messaging__rabbit('heat_config').with( - :rabbit_use_ssl => '', - :kombu_ssl_ca_certs => '', - :kombu_ssl_certfile => '', - :kombu_ssl_keyfile => '', - :kombu_ssl_version => '', + :kombu_ssl_version => '', + :kombu_ssl_keyfile => '', + :kombu_ssl_certfile => '', + :kombu_ssl_ca_certs => '', + :kombu_reconnect_delay => '', + :kombu_failover_strategy => '', + :kombu_compression => '', + :heartbeat_timeout_threshold => '60', + :heartbeat_rate => '10', + :heartbeat_in_pthread => true, + :rabbit_use_ssl => '', + :amqp_durable_queues => '', + :rabbit_ha_queues => '', ) end - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') } - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') } - it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_in_pthread').with_value(true) } end shared_examples_for 'with SSL enabled with kombu' do @@ -209,11 +226,11 @@ describe 'heat' do end it { is_expected.to contain_oslo__messaging__rabbit('heat_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_version => 'TLSv1', :kombu_ssl_keyfile => '/path/to/ssl/keyfile', - :kombu_ssl_version => 'TLSv1' + :kombu_ssl_certfile => '/path/to/ssl/cert/file', + :kombu_ssl_ca_certs => '/path/to/ssl/ca/certs', + :rabbit_use_ssl => true, )} end @@ -241,33 +258,6 @@ describe 'heat' do )} end - shared_examples_for 'with SSL wrongly configured' do - before do - params.merge!( - :rabbit_use_ssl => false - ) - end - - context 'without required parameters' do - - context 'with rabbit_use_ssl => false and kombu_ssl_ca_certs parameter' do - before { params.merge!(:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs')} - it_raises 'a Puppet::Error', /The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true/ - end - - context 'with rabbit_use_ssl => false and kombu_ssl_certfile parameter' do - before { params.merge!(:kombu_ssl_certfile => '/path/to/ssl/cert/file')} - it_raises 'a Puppet::Error', /The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true/ - end - - context 'with rabbit_use_ssl => false and kombu_ssl_keyfile parameter' do - before { params.merge!(:kombu_ssl_keyfile => '/path/to/ssl/keyfile')} - it_raises 'a Puppet::Error', /The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true/ - end - end - - end - shared_examples_for 'with heat_clients_endpoint_type set' do before do params.merge!( @@ -344,9 +334,11 @@ describe 'heat' do end it 'configures transport_url' do - is_expected.to contain_heat_config('DEFAULT/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673') - is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('120') - is_expected.to contain_heat_config('DEFAULT/control_exchange').with_value('heat') + is_expected.to contain_oslo__messaging__default('heat_config').with( + :transport_url => 'rabbit://rabbit_user:password@localhost:5673', + :rpc_response_timeout => '120', + :control_exchange => 'heat' + ) end end @@ -354,35 +346,39 @@ describe 'heat' do before do params.merge!( :notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673', - :notification_driver => 'bar.foo.rpc_notifier', - :notification_topics => 'messagingv2', + :notification_driver => 'messagingv2', + :notification_topics => 'notifications', ) end it 'has notification_driver set when specified' do - is_expected.to contain_heat_config('oslo_messaging_notifications/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673') - is_expected.to contain_heat_config('oslo_messaging_notifications/driver').with_value('bar.foo.rpc_notifier') - is_expected.to contain_heat_config('oslo_messaging_notifications/topics').with_value('messagingv2') + is_expected.to contain_oslo__messaging__notifications('heat_config').with( + :driver => 'messagingv2', + :transport_url => 'rabbit://rabbit_user:password@localhost:5673', + :topics => 'notifications' + ) end end shared_examples_for 'amqp support' do context 'with default parameters' do - it { is_expected.to contain_heat_config('oslo_messaging_amqp/server_request_prefix').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/broadcast_prefix').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/group_request_prefix').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/container_name').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/idle_timeout').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/trace').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_ca_file').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_cert_file').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_key_file').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_key_password').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_mechanisms').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_dir').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_name').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/username').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/password').with_value('') } + it { is_expected.to contain_oslo__messaging__amqp('heat_config').with( + :server_request_prefix => '', + :broadcast_prefix => '', + :group_request_prefix => '', + :container_name => '', + :idle_timeout => '', + :trace => '', + :ssl_ca_file => '', + :ssl_cert_file => '', + :ssl_key_file => '', + :ssl_key_password => '', + :sasl_mechanisms => '', + :sasl_config_dir => '', + :sasl_config_name => '', + :username => '', + :password => '', + ) } end context 'with overridden amqp parameters' do @@ -396,20 +392,23 @@ describe 'heat' do :amqp_password => 'password', ) } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/server_request_prefix').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/broadcast_prefix').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/group_request_prefix').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/container_name').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/idle_timeout').with_value('60') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/trace').with_value('true') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_ca_file').with_value('/path/to/ca.cert') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_cert_file').with_value('/path/to/certfile') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_key_file').with_value('/path/to/key') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_mechanisms').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_dir').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_name').with_value('') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/username').with_value('amqp_user') } - it { is_expected.to contain_heat_config('oslo_messaging_amqp/password').with_value('password') } + it { is_expected.to contain_oslo__messaging__amqp('heat_config').with( + :server_request_prefix => '', + :broadcast_prefix => '', + :group_request_prefix => '', + :container_name => '', + :idle_timeout => '60', + :trace => true, + :ssl_ca_file => '/path/to/ca.cert', + :ssl_cert_file => '/path/to/certfile', + :ssl_key_file => '/path/to/key', + :ssl_key_password => '', + :sasl_mechanisms => '', + :sasl_config_dir => '', + :sasl_config_name => '', + :username => 'amqp_user', + :password => 'password', + ) } end end