From d87868123b5e5964223ae8290497379d67747f75 Mon Sep 17 00:00:00 2001 From: ZhongShengping Date: Tue, 16 May 2017 11:14:48 +0800 Subject: [PATCH] Fix the default parameter value in spec test The default parameter value is 'SERVICE DEFAULT', not 'SERVICE_DEFAULT'. Change-Id: I2e58ea9d64cc5d45750560f92812540ed5e7d213 Closes-Bug: #1690973 --- manifests/init.pp | 40 ++++++++-------- spec/classes/magnum_init_spec.rb | 78 ++++++++++++++------------------ 2 files changed, 55 insertions(+), 63 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 64ded12..71de2e9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,24 +9,24 @@ # Defaults to 'present' # # [*notification_transport_url*] -# (optional) A URL representing the messaging driver to use for notifications -# and its full configuration. Transport URLs take the form: -# transport://user:pass@host1:port[,hostN:portN]/virtual_host -# Defaults to $::os_service_default +# (Optional) A URL representing the messaging driver to use for notifications +# and its full configuration. Transport URLs take the form: +# transport://user:pass@host1:port[,hostN:portN]/virtual_host +# Defaults to $::os_service_default # # [*notification_topics*] -# (optional) AMQP topics to publish to when using the RPC notification driver. -# (list value) -# Default to $::os_service_default +# (Optional) AMQP topics to publish to when using the RPC notification driver. +# (list value) +# Default to $::os_service_default # # [*notification_driver*] # (Optional) Notification driver to use # Defaults to $::os_service_default # # [*default_transport_url*] -# (optional) A URL representing the messaging driver to use and its full +# (Optional) A URL representing the messaging driver to use and its full # configuration. Transport URLs take the form: -# transport://user:pass@host1:port[,hostN:portN]/virtual_host +# transport://user:pass@host1:port[,hostN:portN]/virtual_host # Defaults to $::os_service_default # # [*rpc_response_timeout*] @@ -34,10 +34,10 @@ # Defaults to $::os_service_default # # [*control_exchange*] -# (Optional) The default exchange under which topics are scoped. May be -# overridden by an exchange name specified in the transport_url -# option. -# Defaults to $::os_service_default +# (Optional) The default exchange under which topics are scoped. May be +# overridden by an exchange name specified in the transport_url +# option. +# Defaults to $::os_service_default # # [*rabbit_use_ssl*] # (Optional) Connect over SSL for rabbit @@ -62,15 +62,15 @@ # Defaults to $::os_service_default # # [*kombu_failover_strategy*] -# (Optional) Determines how the next RabbitMQ node is chosen in case the one -# we are currently connected to becomes unavailable. Takes effect only if -# more than one RabbitMQ node is provided in config. (string value) -# Defaults to $::os_service_default +# (Optional) Determines how the next RabbitMQ node is chosen in case the one +# we are currently connected to becomes unavailable. Takes effect only if +# more than one RabbitMQ node is provided in config. (string value) +# Defaults to $::os_service_default # # [*purge_config*] -# (optional) Whether to set only the specified config options -# in the magnum config. -# Defaults to false. +# (Optional) Whether to set only the specified config options +# in the magnum config. +# Defaults to false. # # === DEPRECATED PARAMTERS # diff --git a/spec/classes/magnum_init_spec.rb b/spec/classes/magnum_init_spec.rb index 9ae4710..3fe84fb 100644 --- a/spec/classes/magnum_init_spec.rb +++ b/spec/classes/magnum_init_spec.rb @@ -19,18 +19,12 @@ describe 'magnum' do it 'installs packages' do is_expected.to contain_package('magnum-common').with( - :name => platform_params[:magnum_common_package], :ensure => 'present', + :name => platform_params[:magnum_common_package], :tag => ['openstack', 'magnum-package'] ) end - it 'creates various files and folders' do - is_expected.to contain_file('/etc/magnum/magnum.conf').with( - :require => 'Package[magnum-common]', - ) - end - it 'passes purge to resource' do is_expected.to contain_resources('magnum_config').with({ :purge => false @@ -41,18 +35,18 @@ describe 'magnum' do is_expected.to contain_magnum_config('DEFAULT/transport_url').with_value('') is_expected.to contain_magnum_config('DEFAULT/rpc_response_timeout').with_value('') is_expected.to contain_magnum_config('DEFAULT/control_exchange').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_host').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_password').with_value('').with_secret(true) - is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_port').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_userid').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_host').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_password').with_value('').with_secret(true) + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_port').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_userid').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('') end it 'configures various things' do - is_expected.to contain_magnum_config('oslo_messaging_notifications/transport_url').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_notifications/driver').with_value('') - is_expected.to contain_magnum_config('oslo_messaging_notifications/topics').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_notifications/transport_url').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_notifications/driver').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_notifications/topics').with_value('') end end @@ -63,7 +57,7 @@ describe 'magnum' do :notification_transport_url => 'rabbit://user:pass@host:1234/virt', :notification_topics => 'openstack', :notification_driver => 'messagingv1', - :transport_url => 'rabbit://user:pass@host:1234/virt', + :default_transport_url => 'rabbit://user:pass@host:1234/virt', :rpc_response_timeout => '120', :control_exchange => 'magnum', :rabbit_host => '53.210.103.65', @@ -76,9 +70,9 @@ describe 'magnum' do end it 'installs packages' do - is_expected.to contain_package('magnum_common').with( - :name => platform_params[:magnum_common_package], + is_expected.to contain_package('magnum-common').with( :ensure => 'latest', + :name => platform_params[:magnum_common_package], :tag => ['openstack', 'magnum-package'] ) end @@ -104,12 +98,12 @@ describe 'magnum' do context 'with rabbit_hosts parameter' do let :params do - { :rabbit_hosts => ['rabbit:5673', 'rabbit:5674'] } + { :rabbit_hosts => ['rabbit:5673', 'rabbit2:5674'] } end it 'configures rabbit' do - is_expected.to_not contain_magnum_config('oslo_messaging_rabbit/rabbit_host') - is_expected.to_not contain_magnum_config('oslo_messaging_rabbit/rabbit_port') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_host').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_port').with_value('') is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673,rabbit2:5674') end end @@ -120,8 +114,8 @@ describe 'magnum' do end it 'configures rabbit' do - is_expected.to_not contain_magnum_config('oslo_messaging_rabbit/rabbit_host') - is_expected.to_not contain_magnum_config('oslo_messaging_rabbit/rabbit_port') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_host').with_value('') + is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_port').with_value('') is_expected.to contain_magnum_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673') end end @@ -140,7 +134,7 @@ describe 'magnum' do it 'configures rabbit' do is_expected.to contain_oslo__messaging__rabbit('magnum_config').with( :rabbit_use_ssl => true, - :kombu_ssl_ca_certs => '/etc/ca.cert', + :kombu_ssl_ca_certs => '/etc/ca.crt', :kombu_ssl_certfile => '/etc/certfile', :kombu_ssl_keyfile => '/etc/key', :kombu_ssl_version => 'TLSv1', @@ -170,7 +164,6 @@ describe 'magnum' do let :params do { :rabbit_password => 'pass', :rabbit_use_ssl => false, - :kombu_ssl_version => 'TLSv1', } end @@ -184,26 +177,25 @@ describe 'magnum' do ) 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 - if facts[:os_family] == 'Debian' - { :magnum_common_package => 'magnum-common' } - else - { :magnum_common_package => 'openstack-magnum-common' } - end - end - - it_behaves_like 'magnum' + 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 + if facts[:osfamily] == 'Debian' + { :magnum_common_package => 'magnum-common' } + else + { :magnum_common_package => 'openstack-magnum-common' } + end + end + + it_behaves_like 'magnum' end end