diff --git a/Gemfile b/Gemfile index 45f21c011..9af5bb4a1 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,9 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-puppet', '~> 2.0.0', :require => false gem 'metadata-json-lint' - gem 'puppet-lint', '~> 1.1.0' gem 'puppet-lint-absolute_classname-check' gem 'puppet-lint-absolute_template_path' gem 'puppet-lint-trailing_newline-check' @@ -15,9 +15,6 @@ group :development, :test do gem 'puppet-lint-variable_contains_upcase' gem 'puppet-lint-numericvariable' - gem 'rake', '10.1.1' - gem 'rspec-puppet', '~> 1.0.1', :require => false - gem 'rspec', '< 2.99' gem 'json' gem 'webmock' end diff --git a/spec/classes/neutron_agents_dhcp_spec.rb b/spec/classes/neutron_agents_dhcp_spec.rb index 640d9318a..ec2d007e4 100644 --- a/spec/classes/neutron_agents_dhcp_spec.rb +++ b/spec/classes/neutron_agents_dhcp_spec.rb @@ -32,39 +32,39 @@ describe 'neutron::agents::dhcp' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it_configures 'dnsmasq dhcp_driver' it 'configures dhcp_agent.ini' do - should contain_neutron_dhcp_agent_config('DEFAULT/debug').with_value(p[:debug]); - should contain_neutron_dhcp_agent_config('DEFAULT/state_path').with_value(p[:state_path]); - should contain_neutron_dhcp_agent_config('DEFAULT/resync_interval').with_value(p[:resync_interval]); - should contain_neutron_dhcp_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); - should contain_neutron_dhcp_agent_config('DEFAULT/dhcp_driver').with_value(p[:dhcp_driver]); - should contain_neutron_dhcp_agent_config('DEFAULT/root_helper').with_value(p[:root_helper]); - should contain_neutron_dhcp_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]); - should contain_neutron_dhcp_agent_config('DEFAULT/dhcp_delete_namespaces').with_value(p[:dhcp_delete_namespaces]); - should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(p[:enable_isolated_metadata]); - should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value(p[:enable_metadata_network]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/debug').with_value(p[:debug]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/state_path').with_value(p[:state_path]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/resync_interval').with_value(p[:resync_interval]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dhcp_driver').with_value(p[:dhcp_driver]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/root_helper').with_value(p[:root_helper]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dhcp_delete_namespaces').with_value(p[:dhcp_delete_namespaces]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(p[:enable_isolated_metadata]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value(p[:enable_metadata_network]); end it 'installs neutron dhcp agent package' do if platform_params.has_key?(:dhcp_agent_package) - should contain_package('neutron-dhcp-agent').with( + is_expected.to contain_package('neutron-dhcp-agent').with( :name => platform_params[:dhcp_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron').with_before(/Package\[neutron-dhcp-agent\]/) - should contain_package('neutron-dhcp-agent').with_before(/Neutron_dhcp_agent_config\[.+\]/) - should contain_package('neutron-dhcp-agent').with_before(/Neutron_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Package\[neutron-dhcp-agent\]/) + is_expected.to contain_package('neutron-dhcp-agent').with_before(/Neutron_dhcp_agent_config\[.+\]/) + is_expected.to contain_package('neutron-dhcp-agent').with_before(/Neutron_config\[.+\]/) else - should contain_package('neutron').with_before(/Neutron_dhcp_agent_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Neutron_dhcp_agent_config\[.+\]/) end end it 'configures neutron dhcp agent service' do - should contain_service('neutron-dhcp-service').with( + is_expected.to contain_service('neutron-dhcp-service').with( :name => platform_params[:dhcp_agent_service], :enable => true, :ensure => 'running', @@ -77,7 +77,7 @@ describe 'neutron::agents::dhcp' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-dhcp-service').without_ensure + is_expected.to contain_service('neutron-dhcp-service').without_ensure end end @@ -86,8 +86,8 @@ describe 'neutron::agents::dhcp' do params.merge!(:enable_isolated_metadata => true, :enable_metadata_network => false) end it 'should enable isolated_metadata only' do - should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true'); - should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('false'); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true'); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('false'); end end @@ -96,8 +96,8 @@ describe 'neutron::agents::dhcp' do params.merge!(:enable_isolated_metadata => true, :enable_metadata_network => true) end it 'should enable both isolated_metadata and metadata_network' do - should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true'); - should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('true'); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true'); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('true'); end end @@ -105,9 +105,8 @@ describe 'neutron::agents::dhcp' do before :each do params.merge!(:enable_isolated_metadata => false, :enable_metadata_network => true) end - it 'should fails to configure metadata_network without isolated_metadata' do - expect { subject }.to raise_error(Puppet::Error, /enable_metadata_network to true requires enable_isolated_metadata also enabled./) - end + + it_raises 'a Puppet::Error', /enable_metadata_network to true requires enable_isolated_metadata also enabled./ end end @@ -118,21 +117,21 @@ describe 'neutron::agents::dhcp' do ) end it 'configures dnsmasq_config_file' do - should contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_config_file').with_value(params[:dnsmasq_config_file]) + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_config_file').with_value(params[:dnsmasq_config_file]) end end shared_examples_for 'dnsmasq dhcp_driver' do it 'installs dnsmasq packages' do if platform_params.has_key?(:dhcp_agent_package) - should contain_package(platform_params[:dnsmasq_base_package]).with_before('Package[neutron-dhcp-agent]') - should contain_package(platform_params[:dnsmasq_utils_package]).with_before('Package[neutron-dhcp-agent]') + is_expected.to contain_package(platform_params[:dnsmasq_base_package]).with_before('Package[neutron-dhcp-agent]') + is_expected.to contain_package(platform_params[:dnsmasq_utils_package]).with_before('Package[neutron-dhcp-agent]') end - should contain_package(platform_params[:dnsmasq_base_package]).with( + is_expected.to contain_package(platform_params[:dnsmasq_base_package]).with( :ensure => 'present', :name => platform_params[:dnsmasq_base_package] ) - should contain_package(platform_params[:dnsmasq_utils_package]).with( + is_expected.to contain_package(platform_params[:dnsmasq_utils_package]).with( :ensure => 'present', :name => platform_params[:dnsmasq_utils_package] ) diff --git a/spec/classes/neutron_agents_l3_spec.rb b/spec/classes/neutron_agents_l3_spec.rb index 9b645e83f..2af6d46c6 100644 --- a/spec/classes/neutron_agents_l3_spec.rb +++ b/spec/classes/neutron_agents_l3_spec.rb @@ -39,40 +39,40 @@ describe 'neutron::agents::l3' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures l3_agent.ini' do - should contain_neutron_l3_agent_config('DEFAULT/debug').with_value(p[:debug]) - should contain_neutron_l3_agent_config('DEFAULT/external_network_bridge').with_value(p[:external_network_bridge]) - should contain_neutron_l3_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]) - should contain_neutron_l3_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]) - should contain_neutron_l3_agent_config('DEFAULT/router_id').with_value(p[:router_id]) - should contain_neutron_l3_agent_config('DEFAULT/gateway_external_network_id').with_value(p[:gateway_external_network_id]) - should contain_neutron_l3_agent_config('DEFAULT/handle_internal_only_routers').with_value(p[:handle_internal_only_routers]) - should contain_neutron_l3_agent_config('DEFAULT/metadata_port').with_value(p[:metadata_port]) - should contain_neutron_l3_agent_config('DEFAULT/send_arp_for_ha').with_value(p[:send_arp_for_ha]) - should contain_neutron_l3_agent_config('DEFAULT/periodic_interval').with_value(p[:periodic_interval]) - should contain_neutron_l3_agent_config('DEFAULT/periodic_fuzzy_delay').with_value(p[:periodic_fuzzy_delay]) - should contain_neutron_l3_agent_config('DEFAULT/enable_metadata_proxy').with_value(p[:enable_metadata_proxy]) - should contain_neutron_l3_agent_config('DEFAULT/network_device_mtu').with_ensure('absent') - should contain_neutron_l3_agent_config('DEFAULT/router_delete_namespaces').with_value(p[:router_delete_namespaces]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/debug').with_value(p[:debug]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/external_network_bridge').with_value(p[:external_network_bridge]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/router_id').with_value(p[:router_id]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/gateway_external_network_id').with_value(p[:gateway_external_network_id]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/handle_internal_only_routers').with_value(p[:handle_internal_only_routers]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/metadata_port').with_value(p[:metadata_port]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/send_arp_for_ha').with_value(p[:send_arp_for_ha]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/periodic_interval').with_value(p[:periodic_interval]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/periodic_fuzzy_delay').with_value(p[:periodic_fuzzy_delay]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/enable_metadata_proxy').with_value(p[:enable_metadata_proxy]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/network_device_mtu').with_ensure('absent') + is_expected.to contain_neutron_l3_agent_config('DEFAULT/router_delete_namespaces').with_value(p[:router_delete_namespaces]) end it 'installs neutron l3 agent package' do if platform_params.has_key?(:l3_agent_package) - should contain_package('neutron-l3').with( + is_expected.to contain_package('neutron-l3').with( :name => platform_params[:l3_agent_package], :ensure => p[:package_ensure], :require => 'Package[neutron]' ) - should contain_package('neutron-l3').with_before(/Neutron_l3_agent_config\[.+\]/) + is_expected.to contain_package('neutron-l3').with_before(/Neutron_l3_agent_config\[.+\]/) else - should contain_package('neutron').with_before(/Neutron_l3_agent_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Neutron_l3_agent_config\[.+\]/) end end it 'configures neutron l3 agent service' do - should contain_service('neutron-l3').with( + is_expected.to contain_service('neutron-l3').with( :name => platform_params[:l3_agent_service], :enable => true, :ensure => 'running', @@ -85,7 +85,7 @@ describe 'neutron::agents::l3' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-l3').without_ensure + is_expected.to contain_service('neutron-l3').without_ensure end end @@ -94,7 +94,7 @@ describe 'neutron::agents::l3' do params.merge!(:agent_mode => 'dvr') end it 'should enable DVR mode' do - should contain_neutron_l3_agent_config('DEFAULT/agent_mode').with_value(p[:agent_mode]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/agent_mode').with_value(p[:agent_mode]) end end @@ -104,9 +104,9 @@ describe 'neutron::agents::l3' do :ha_vrrp_auth_password => 'secrete') end it 'should configure VRRP' do - should contain_neutron_l3_agent_config('DEFAULT/ha_vrrp_auth_type').with_value(p[:ha_vrrp_auth_type]) - should contain_neutron_l3_agent_config('DEFAULT/ha_vrrp_auth_password').with_value(p[:ha_vrrp_auth_password]) - should contain_neutron_l3_agent_config('DEFAULT/ha_vrrp_advert_int').with_value(p[:ha_vrrp_advert_int]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/ha_vrrp_auth_type').with_value(p[:ha_vrrp_auth_type]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/ha_vrrp_auth_password').with_value(p[:ha_vrrp_auth_password]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/ha_vrrp_advert_int').with_value(p[:ha_vrrp_advert_int]) end end end @@ -118,7 +118,7 @@ describe 'neutron::agents::l3' do ) end it 'configures network_device_mtu' do - should contain_neutron_l3_agent_config('DEFAULT/network_device_mtu').with_value(params[:network_device_mtu]) + is_expected.to contain_neutron_l3_agent_config('DEFAULT/network_device_mtu').with_value(params[:network_device_mtu]) end end diff --git a/spec/classes/neutron_agents_lbaas_spec.rb b/spec/classes/neutron_agents_lbaas_spec.rb index 7f67953ae..b66407780 100644 --- a/spec/classes/neutron_agents_lbaas_spec.rb +++ b/spec/classes/neutron_agents_lbaas_spec.rb @@ -27,35 +27,35 @@ describe 'neutron::agents::lbaas' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it_configures 'haproxy lbaas_driver' it_configures 'haproxy lbaas_driver without package' it 'configures lbaas_agent.ini' do - should contain_neutron_lbaas_agent_config('DEFAULT/debug').with_value(p[:debug]); - should contain_neutron_lbaas_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); - should contain_neutron_lbaas_agent_config('DEFAULT/device_driver').with_value(p[:device_driver]); - should contain_neutron_lbaas_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]); - should contain_neutron_lbaas_agent_config('haproxy/user_group').with_value(platform_params[:nobody_user_group]); + is_expected.to contain_neutron_lbaas_agent_config('DEFAULT/debug').with_value(p[:debug]); + is_expected.to contain_neutron_lbaas_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); + is_expected.to contain_neutron_lbaas_agent_config('DEFAULT/device_driver').with_value(p[:device_driver]); + is_expected.to contain_neutron_lbaas_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]); + is_expected.to contain_neutron_lbaas_agent_config('haproxy/user_group').with_value(platform_params[:nobody_user_group]); end it 'installs neutron lbaas agent package' do if platform_params.has_key?(:lbaas_agent_package) - should contain_package('neutron-lbaas-agent').with( + is_expected.to contain_package('neutron-lbaas-agent').with( :name => platform_params[:lbaas_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron').with_before(/Package\[neutron-lbaas-agent\]/) - should contain_package('neutron-lbaas-agent').with_before(/Neutron_lbaas_agent_config\[.+\]/) - should contain_package('neutron-lbaas-agent').with_before(/Neutron_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Package\[neutron-lbaas-agent\]/) + is_expected.to contain_package('neutron-lbaas-agent').with_before(/Neutron_lbaas_agent_config\[.+\]/) + is_expected.to contain_package('neutron-lbaas-agent').with_before(/Neutron_config\[.+\]/) else - should contain_package('neutron').with_before(/Neutron_lbaas_agent_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Neutron_lbaas_agent_config\[.+\]/) end end it 'configures neutron lbaas agent service' do - should contain_service('neutron-lbaas-service').with( + is_expected.to contain_service('neutron-lbaas-service').with( :name => platform_params[:lbaas_agent_service], :enable => true, :ensure => 'running', @@ -68,7 +68,7 @@ describe 'neutron::agents::lbaas' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-lbaas-service').without_ensure + is_expected.to contain_service('neutron-lbaas-service').without_ensure end end end @@ -76,9 +76,9 @@ describe 'neutron::agents::lbaas' do shared_examples_for 'haproxy lbaas_driver' do it 'installs haproxy packages' do if platform_params.has_key?(:lbaas_agent_package) - should contain_package(platform_params[:haproxy_package]).with_before('Package[neutron-lbaas-agent]') + is_expected.to contain_package(platform_params[:haproxy_package]).with_before('Package[neutron-lbaas-agent]') end - should contain_package(platform_params[:haproxy_package]).with( + is_expected.to contain_package(platform_params[:haproxy_package]).with( :ensure => 'present' ) end @@ -95,7 +95,7 @@ describe 'neutron::agents::lbaas' do params.merge!(:manage_haproxy_package => false) end it 'installs haproxy package via haproxy module' do - should contain_package(platform_params[:haproxy_package]).with( + is_expected.to contain_package(platform_params[:haproxy_package]).with( :ensure => 'present' ) end diff --git a/spec/classes/neutron_agents_linuxbridge_spec.rb b/spec/classes/neutron_agents_linuxbridge_spec.rb index 53b5f9c07..26316fa1a 100644 --- a/spec/classes/neutron_agents_linuxbridge_spec.rb +++ b/spec/classes/neutron_agents_linuxbridge_spec.rb @@ -17,10 +17,10 @@ describe 'neutron::agents::linuxbridge' do shared_examples_for 'neutron linuxbridge agent' do - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures neutron linuxbridge agent service' do - should contain_service('neutron-plugin-linuxbridge-service').with( + is_expected.to contain_service('neutron-plugin-linuxbridge-service').with( :ensure => 'running', :name => platform_params[:linuxbridge_agent_service], :enable => params[:enable] @@ -32,15 +32,15 @@ describe 'neutron::agents::linuxbridge' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-plugin-linuxbridge-service').without_ensure + is_expected.to contain_service('neutron-plugin-linuxbridge-service').without_ensure end end it 'configures linuxbridge_conf.ini' do - should contain_neutron_plugin_linuxbridge('LINUX_BRIDGE/physical_interface_mappings').with( + is_expected.to contain_neutron_plugin_linuxbridge('LINUX_BRIDGE/physical_interface_mappings').with( :value => params[:physical_interface_mappings] ) - should contain_neutron_plugin_linuxbridge('SECURITYGROUP/firewall_driver').with( + is_expected.to contain_neutron_plugin_linuxbridge('SECURITYGROUP/firewall_driver').with( :value => params[:firewall_driver] ) end @@ -60,7 +60,7 @@ describe 'neutron::agents::linuxbridge' do it_configures 'neutron linuxbridge agent' it 'installs neutron linuxbridge agent package' do - should contain_package('neutron-plugin-linuxbridge-agent').with( + is_expected.to contain_package('neutron-plugin-linuxbridge-agent').with( :ensure => params[:package_ensure], :name => platform_params[:linuxbridge_agent_package] ) @@ -80,7 +80,7 @@ describe 'neutron::agents::linuxbridge' do it_configures 'neutron linuxbridge agent' it 'installs neutron linuxbridge package' do - should contain_package('neutron-plugin-linuxbridge').with( + is_expected.to contain_package('neutron-plugin-linuxbridge').with( :ensure => params[:package_ensure], :name => platform_params[:linuxbridge_server_package] ) diff --git a/spec/classes/neutron_agents_metadata_spec.rb b/spec/classes/neutron_agents_metadata_spec.rb index 57f9a839e..ec28f14ac 100644 --- a/spec/classes/neutron_agents_metadata_spec.rb +++ b/spec/classes/neutron_agents_metadata_spec.rb @@ -25,10 +25,10 @@ describe 'neutron::agents::metadata' do shared_examples_for 'neutron metadata agent' do - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures neutron metadata agent service' do - should contain_service('neutron-metadata').with( + is_expected.to contain_service('neutron-metadata').with( :name => platform_params[:metadata_agent_service], :enable => params[:enabled], :ensure => 'running', @@ -41,26 +41,26 @@ describe 'neutron::agents::metadata' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-metadata').without_ensure + is_expected.to contain_service('neutron-metadata').without_ensure end end it 'configures metadata_agent.ini' do - should contain_neutron_metadata_agent_config('DEFAULT/debug').with(:value => params[:debug]) - should contain_neutron_metadata_agent_config('DEFAULT/auth_url').with(:value => params[:auth_url]) - should contain_neutron_metadata_agent_config('DEFAULT/auth_insecure').with(:value => params[:auth_insecure]) - should contain_neutron_metadata_agent_config('DEFAULT/auth_ca_cert').with_ensure('absent') - should contain_neutron_metadata_agent_config('DEFAULT/auth_region').with(:value => params[:auth_region]) - should contain_neutron_metadata_agent_config('DEFAULT/admin_tenant_name').with(:value => params[:auth_tenant]) - should contain_neutron_metadata_agent_config('DEFAULT/admin_user').with(:value => params[:auth_user]) - should contain_neutron_metadata_agent_config('DEFAULT/admin_password').with(:value => params[:auth_password]) - should contain_neutron_metadata_agent_config('DEFAULT/admin_password').with_secret( true ) - should contain_neutron_metadata_agent_config('DEFAULT/nova_metadata_ip').with(:value => params[:metadata_ip]) - should contain_neutron_metadata_agent_config('DEFAULT/nova_metadata_port').with(:value => params[:metadata_port]) - should contain_neutron_metadata_agent_config('DEFAULT/metadata_workers').with(:value => facts[:processorcount]) - should contain_neutron_metadata_agent_config('DEFAULT/metadata_backlog').with(:value => params[:metadata_backlog]) - should contain_neutron_metadata_agent_config('DEFAULT/metadata_proxy_shared_secret').with(:value => params[:shared_secret]) - should contain_neutron_metadata_agent_config('DEFAULT/cache_url').with(:value => 'memory://?default_ttl=5') + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/debug').with(:value => params[:debug]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/auth_url').with(:value => params[:auth_url]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/auth_insecure').with(:value => params[:auth_insecure]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/auth_ca_cert').with_ensure('absent') + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/auth_region').with(:value => params[:auth_region]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/admin_tenant_name').with(:value => params[:auth_tenant]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/admin_user').with(:value => params[:auth_user]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/admin_password').with(:value => params[:auth_password]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/admin_password').with_secret( true ) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/nova_metadata_ip').with(:value => params[:metadata_ip]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/nova_metadata_port').with(:value => params[:metadata_port]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/metadata_workers').with(:value => facts[:processorcount]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/metadata_backlog').with(:value => params[:metadata_backlog]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/metadata_proxy_shared_secret').with(:value => params[:shared_secret]) + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/cache_url').with(:value => 'memory://?default_ttl=5') end end @@ -74,8 +74,8 @@ describe 'neutron::agents::metadata' do end it 'configures certificate' do - should contain_neutron_metadata_agent_config('DEFAULT/auth_ca_cert').with_value('/some/cert') - should contain_neutron_metadata_agent_config('DEFAULT/auth_insecure').with_value('true') + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/auth_ca_cert').with_value('/some/cert') + is_expected.to contain_neutron_metadata_agent_config('DEFAULT/auth_insecure').with_value('true') end end @@ -91,7 +91,7 @@ describe 'neutron::agents::metadata' do end it 'installs neutron metadata agent package' do - should contain_package('neutron-metadata').with( + is_expected.to contain_package('neutron-metadata').with( :ensure => params[:package_ensure], :name => platform_params[:metadata_agent_package] ) diff --git a/spec/classes/neutron_agents_metering_spec.rb b/spec/classes/neutron_agents_metering_spec.rb index 03300f7d6..d00d91610 100644 --- a/spec/classes/neutron_agents_metering_spec.rb +++ b/spec/classes/neutron_agents_metering_spec.rb @@ -49,32 +49,32 @@ describe 'neutron::agents::metering' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures metering_agent.ini' do - should contain_neutron_metering_agent_config('DEFAULT/debug').with_value(p[:debug]); - should contain_neutron_metering_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); - should contain_neutron_metering_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]); - should contain_neutron_metering_agent_config('DEFAULT/measure_interval').with_value(p[:measure_interval]); - should contain_neutron_metering_agent_config('DEFAULT/report_interval').with_value(p[:report_interval]); + is_expected.to contain_neutron_metering_agent_config('DEFAULT/debug').with_value(p[:debug]); + is_expected.to contain_neutron_metering_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); + is_expected.to contain_neutron_metering_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]); + is_expected.to contain_neutron_metering_agent_config('DEFAULT/measure_interval').with_value(p[:measure_interval]); + is_expected.to contain_neutron_metering_agent_config('DEFAULT/report_interval').with_value(p[:report_interval]); end it 'installs neutron metering agent package' do if platform_params.has_key?(:metering_agent_package) - should contain_package('neutron-metering-agent').with( + is_expected.to contain_package('neutron-metering-agent').with( :name => platform_params[:metering_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron').with_before(/Package\[neutron-metering-agent\]/) - should contain_package('neutron-metering-agent').with_before(/Neutron_metering_agent_config\[.+\]/) - should contain_package('neutron-metering-agent').with_before(/Neutron_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Package\[neutron-metering-agent\]/) + is_expected.to contain_package('neutron-metering-agent').with_before(/Neutron_metering_agent_config\[.+\]/) + is_expected.to contain_package('neutron-metering-agent').with_before(/Neutron_config\[.+\]/) else - should contain_package('neutron').with_before(/Neutron_metering_agent_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Neutron_metering_agent_config\[.+\]/) end end it 'configures neutron metering agent service' do - should contain_service('neutron-metering-service').with( + is_expected.to contain_service('neutron-metering-service').with( :name => platform_params[:metering_agent_service], :enable => true, :ensure => 'running', @@ -87,7 +87,7 @@ describe 'neutron::agents::metering' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-metering-service').without_ensure + is_expected.to contain_service('neutron-metering-service').without_ensure end end end diff --git a/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb b/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb index 78d533dc4..da38b74a6 100644 --- a/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb +++ b/spec/classes/neutron_agents_ml2_linuxbridge_spec.rb @@ -27,12 +27,12 @@ describe 'neutron::agents::ml2::linuxbridge' do shared_examples_for 'neutron plugin linuxbridge agent with ml2 plugin' do context 'with default parameters' do - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures ml2_conf.ini' do - should contain_neutron_plugin_linuxbridge('agent/polling_interval').with_value(default_params[:polling_interval]) - should contain_neutron_plugin_linuxbridge('linux_bridge/physical_interface_mappings').with_value(default_params[:physical_interface_mappings].join(',')) - should contain_neutron_plugin_linuxbridge('securitygroup/firewall_driver').with_value(default_params[:firewall_driver]) + is_expected.to contain_neutron_plugin_linuxbridge('agent/polling_interval').with_value(default_params[:polling_interval]) + is_expected.to contain_neutron_plugin_linuxbridge('linux_bridge/physical_interface_mappings').with_value(default_params[:physical_interface_mappings].join(',')) + is_expected.to contain_neutron_plugin_linuxbridge('securitygroup/firewall_driver').with_value(default_params[:firewall_driver]) end it 'installs neutron linuxbridge agent package' do @@ -42,16 +42,16 @@ describe 'neutron::agents::ml2::linuxbridge' do linuxbridge_agent_package = platform_params[:linuxbridge_server_package] end - should contain_package('neutron-plugin-linuxbridge-agent').with( + is_expected.to contain_package('neutron-plugin-linuxbridge-agent').with( :name => linuxbridge_agent_package, :ensure => default_params[:package_ensure] ) - should contain_package('neutron-plugin-linuxbridge-agent').with_before(/Neutron_plugin_linuxbridge\[.+\]/) + is_expected.to contain_package('neutron-plugin-linuxbridge-agent').with_before(/Neutron_plugin_linuxbridge\[.+\]/) end it 'configures neutron linuxbridge agent service' do - should contain_service('neutron-plugin-linuxbridge-agent').with( + is_expected.to contain_service('neutron-plugin-linuxbridge-agent').with( :name => platform_params[:linuxbridge_agent_service], :enable => true, :ensure => 'running', @@ -60,10 +60,10 @@ describe 'neutron::agents::ml2::linuxbridge' do end it 'does not configre VXLAN tunneling' do - should contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(false) - should contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_ensure('absent') - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_ensure('absent') - should contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_ensure('absent') + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(false) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_ensure('absent') + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_ensure('absent') + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_ensure('absent') end end @@ -77,12 +77,12 @@ describe 'neutron::agents::ml2::linuxbridge' do context 'when providing all parameters' do it 'configures ml2_conf.ini' do - should contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(true) - should contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_value(params[:local_ip]) - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_value(default_params[:vxlan_group]) - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_ttl').with_ensure('absent') - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_tos').with_ensure('absent') - should contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_value(default_params[:l2_population]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(true) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_value(params[:local_ip]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_value(default_params[:vxlan_group]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_ttl').with_ensure('absent') + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_tos').with_ensure('absent') + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_value(default_params[:l2_population]) end end @@ -97,12 +97,12 @@ describe 'neutron::agents::ml2::linuxbridge' do end it 'configures ml2_conf.ini' do - should contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(true) - should contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_value(params[:local_ip]) - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_value(params[:vxlan_group]) - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_ttl').with_value(params[:vxlan_ttl]) - should contain_neutron_plugin_linuxbridge('vxlan/vxlan_tos').with_value(params[:vxlan_tos]) - should contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_value(params[:l2_population]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(true) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_value(params[:local_ip]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_value(params[:vxlan_group]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_ttl').with_value(params[:vxlan_ttl]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_tos').with_value(params[:vxlan_tos]) + is_expected.to contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_value(params[:l2_population]) end end end @@ -113,7 +113,7 @@ describe 'neutron::agents::ml2::linuxbridge' do end it 'configures physical interface mappings' do - should contain_neutron_plugin_linuxbridge('linux_bridge/physical_interface_mappings').with_value( + is_expected.to contain_neutron_plugin_linuxbridge('linux_bridge/physical_interface_mappings').with_value( params[:physical_interface_mappings].join(',') ) end @@ -124,7 +124,7 @@ describe 'neutron::agents::ml2::linuxbridge' do params.merge!(:firewall_driver => false) end it 'removes firewall driver configuration' do - should contain_neutron_plugin_linuxbridge('securitygroup/firewall_driver').with_ensure('absent') + is_expected.to contain_neutron_plugin_linuxbridge('securitygroup/firewall_driver').with_ensure('absent') end end end diff --git a/spec/classes/neutron_agents_ml2_ovs_spec.rb b/spec/classes/neutron_agents_ml2_ovs_spec.rb index 45aec8e51..a00df9f3a 100644 --- a/spec/classes/neutron_agents_ml2_ovs_spec.rb +++ b/spec/classes/neutron_agents_ml2_ovs_spec.rb @@ -31,41 +31,41 @@ describe 'neutron::agents::ml2::ovs' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures ovs_neutron_plugin.ini' do - should contain_neutron_plugin_ml2('agent/polling_interval').with_value(p[:polling_interval]) - should contain_neutron_plugin_ml2('agent/l2_population').with_value(p[:l2_population]) - should contain_neutron_plugin_ml2('agent/arp_responder').with_value(p[:arp_responder]) - should contain_neutron_plugin_ml2('ovs/integration_bridge').with_value(p[:integration_bridge]) - should contain_neutron_plugin_ml2('securitygroup/firewall_driver').\ + is_expected.to contain_neutron_plugin_ml2('agent/polling_interval').with_value(p[:polling_interval]) + is_expected.to contain_neutron_plugin_ml2('agent/l2_population').with_value(p[:l2_population]) + is_expected.to contain_neutron_plugin_ml2('agent/arp_responder').with_value(p[:arp_responder]) + is_expected.to contain_neutron_plugin_ml2('ovs/integration_bridge').with_value(p[:integration_bridge]) + is_expected.to contain_neutron_plugin_ml2('securitygroup/firewall_driver').\ with_value(p[:firewall_driver]) - should contain_neutron_plugin_ml2('ovs/enable_tunneling').with_value(false) - should contain_neutron_plugin_ml2('ovs/tunnel_bridge').with_ensure('absent') - should contain_neutron_plugin_ml2('ovs/local_ip').with_ensure('absent') + is_expected.to contain_neutron_plugin_ml2('ovs/enable_tunneling').with_value(false) + is_expected.to contain_neutron_plugin_ml2('ovs/tunnel_bridge').with_ensure('absent') + is_expected.to contain_neutron_plugin_ml2('ovs/local_ip').with_ensure('absent') end it 'configures vs_bridge' do - should contain_vs_bridge(p[:integration_bridge]).with( + is_expected.to contain_vs_bridge(p[:integration_bridge]).with( :ensure => 'present', :before => 'Service[neutron-ovs-agent-service]' ) - should_not contain_vs_brige(p[:integration_bridge]) + is_expected.not_to contain_vs_brige(p[:integration_bridge]) end it 'installs neutron ovs agent package' do if platform_params.has_key?(:ovs_agent_package) - should contain_package('neutron-ovs-agent').with( + is_expected.to contain_package('neutron-ovs-agent').with( :name => platform_params[:ovs_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron-ovs-agent').with_before(/Neutron_plugin_ml2\[.+\]/) + is_expected.to contain_package('neutron-ovs-agent').with_before(/Neutron_plugin_ml2\[.+\]/) else end end it 'configures neutron ovs agent service' do - should contain_service('neutron-ovs-agent-service').with( + is_expected.to contain_service('neutron-ovs-agent-service').with( :name => platform_params[:ovs_agent_service], :enable => true, :ensure => 'running', @@ -78,7 +78,7 @@ describe 'neutron::agents::ml2::ovs' do params.merge!(:firewall_driver => false) end it 'should configure firewall driver' do - should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_ensure('absent') + is_expected.to contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_ensure('absent') end end @@ -87,7 +87,7 @@ describe 'neutron::agents::ml2::ovs' do params.merge!(:arp_responder => true) end it 'should enable ARP responder' do - should contain_neutron_plugin_ml2('agent/arp_responder').with_value(true) + is_expected.to contain_neutron_plugin_ml2('agent/arp_responder').with_value(true) end end @@ -97,7 +97,7 @@ describe 'neutron::agents::ml2::ovs' do :l2_population => true ) end it 'should enable DVR' do - should contain_neutron_plugin_ml2('agent/enable_distributed_routing').with_value(true) + is_expected.to contain_neutron_plugin_ml2('agent/enable_distributed_routing').with_value(true) end end @@ -107,17 +107,17 @@ describe 'neutron::agents::ml2::ovs' do end it 'configures bridge mappings' do - should contain_neutron_plugin_ml2('ovs/bridge_mappings') + is_expected.to contain_neutron_plugin_ml2('ovs/bridge_mappings') end it 'should configure bridge mappings' do - should contain_neutron__plugins__ovs__bridge(params[:bridge_mappings].join(',')).with( + is_expected.to contain_neutron__plugins__ovs__bridge(params[:bridge_mappings].join(',')).with( :before => 'Service[neutron-ovs-agent-service]' ) end it 'should configure bridge uplinks' do - should contain_neutron__plugins__ovs__port(params[:bridge_uplinks].join(',')).with( + is_expected.to contain_neutron__plugins__ovs__port(params[:bridge_uplinks].join(',')).with( :before => 'Service[neutron-ovs-agent-service]' ) end @@ -128,21 +128,18 @@ describe 'neutron::agents::ml2::ovs' do before :each do params.merge!(:enable_tunneling => true) end - it 'should fail' do - expect do - subject - end.to raise_error(Puppet::Error, /Local ip for ovs agent must be set when tunneling is enabled/) - end + + it_raises 'a Puppet::Error', /Local ip for ovs agent must be set when tunneling is enabled/ end context 'with default params' do before :each do params.merge!(:enable_tunneling => true, :local_ip => '127.0.0.1' ) end it 'should configure ovs for tunneling' do - should contain_neutron_plugin_ml2('ovs/enable_tunneling').with_value(true) - should contain_neutron_plugin_ml2('ovs/tunnel_bridge').with_value(default_params[:tunnel_bridge]) - should contain_neutron_plugin_ml2('ovs/local_ip').with_value('127.0.0.1') - should contain_vs_bridge(default_params[:tunnel_bridge]).with( + is_expected.to contain_neutron_plugin_ml2('ovs/enable_tunneling').with_value(true) + is_expected.to contain_neutron_plugin_ml2('ovs/tunnel_bridge').with_value(default_params[:tunnel_bridge]) + is_expected.to contain_neutron_plugin_ml2('ovs/local_ip').with_value('127.0.0.1') + is_expected.to contain_vs_bridge(default_params[:tunnel_bridge]).with( :ensure => 'present', :before => 'Service[neutron-ovs-agent-service]' ) @@ -158,8 +155,8 @@ describe 'neutron::agents::ml2::ovs' do end it 'should perform vxlan network configuration' do - should contain_neutron_plugin_ml2('agent/tunnel_types').with_value(params[:tunnel_types]) - should contain_neutron_plugin_ml2('agent/vxlan_udp_port').with_value(params[:vxlan_udp_port]) + is_expected.to contain_neutron_plugin_ml2('agent/tunnel_types').with_value(params[:tunnel_types]) + is_expected.to contain_neutron_plugin_ml2('agent/vxlan_udp_port').with_value(params[:vxlan_udp_port]) end end @@ -168,11 +165,8 @@ describe 'neutron::agents::ml2::ovs' do params.merge!(:enable_distributed_routing => true, :l2_population => false ) end - it 'should fail' do - expect do - subject - end.to raise_error(Puppet::Error, /L2 population must be enabled when DVR is enabled/) - end + + it_raises 'a Puppet::Error', /L2 population must be enabled when DVR is enabled/ end end end @@ -203,16 +197,16 @@ describe 'neutron::agents::ml2::ovs' do it_configures 'neutron plugin ovs agent with ml2 plugin' it 'configures neutron ovs cleanup service' do - should contain_service('ovs-cleanup-service').with( + is_expected.to contain_service('ovs-cleanup-service').with( :name => platform_params[:ovs_cleanup_service], :enable => true, :ensure => 'running' ) - should contain_package('neutron-ovs-agent').with_before(/Service\[ovs-cleanup-service\]/) + is_expected.to contain_package('neutron-ovs-agent').with_before(/Service\[ovs-cleanup-service\]/) end it 'links from ovs config to plugin config' do - should contain_file('/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini').with( + is_expected.to contain_file('/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini').with( :ensure => 'link', :target => '/etc/neutron/plugins/ml2/ml2_conf.ini' ) diff --git a/spec/classes/neutron_agents_ml2_sriov_spec.rb b/spec/classes/neutron_agents_ml2_sriov_spec.rb index d61ed0294..53cc60857 100644 --- a/spec/classes/neutron_agents_ml2_sriov_spec.rb +++ b/spec/classes/neutron_agents_ml2_sriov_spec.rb @@ -24,24 +24,24 @@ describe 'neutron::agents::ml2::sriov' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures ovs_neutron_plugin.ini' do - should contain_neutron_plugin_ml2('sriov_nic/polling_interval').with_value(p[:polling_interval]) - should contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(p[:exclude_devices].join(',')) - should contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(p[:physical_device_mappings].join(',')) + is_expected.to contain_neutron_plugin_ml2('sriov_nic/polling_interval').with_value(p[:polling_interval]) + is_expected.to contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(p[:exclude_devices].join(',')) + is_expected.to contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(p[:physical_device_mappings].join(',')) end it 'installs neutron sriov-nic agent package' do - should contain_package('neutron-sriov-nic-agent').with( + is_expected.to contain_package('neutron-sriov-nic-agent').with( :name => platform_params[:sriov_nic_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron-sriov-nic-agent').with_before(/Neutron_plugin_ml2\[.+\]/) + is_expected.to contain_package('neutron-sriov-nic-agent').with_before(/Neutron_plugin_ml2\[.+\]/) end it 'configures neutron ovs agent service' do - should contain_service('neutron-sriov-nic-agent-service').with( + is_expected.to contain_service('neutron-sriov-nic-agent-service').with( :name => platform_params[:sriov_nic_agent_service], :enable => true, :ensure => 'running', @@ -56,8 +56,8 @@ describe 'neutron::agents::ml2::sriov' do end it 'configures physical device mappings with exclusion' do - should contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(['physnet1:eth2']) - should contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(['physnet1:eth1']) + is_expected.to contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(['physnet1:eth2']) + is_expected.to contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(['physnet1:eth1']) end end end diff --git a/spec/classes/neutron_agents_n1kv_vem_spec.rb b/spec/classes/neutron_agents_n1kv_vem_spec.rb index 4eeee17e6..79aa4e889 100644 --- a/spec/classes/neutron_agents_n1kv_vem_spec.rb +++ b/spec/classes/neutron_agents_n1kv_vem_spec.rb @@ -7,7 +7,7 @@ describe 'neutron::agents::n1kv_vem' do end it 'should have a n1kv-vem config file' do - should contain_file('/etc/n1kv/n1kv.conf').with( + is_expected.to contain_file('/etc/n1kv/n1kv.conf').with( :ensure => 'present', :owner => 'root', :group => 'root', @@ -16,10 +16,10 @@ describe 'neutron::agents::n1kv_vem' do end it 'install n1kv-vem' do - should contain_package('libnl').with_before('Package[nexus1000v]') - should contain_service('openvswitch').with_notify('Package[nexus1000v]') - should contain_package('nexus1000v').with_notify('Service[nexus1000v]') - should contain_service('nexus1000v').with_ensure('running') + is_expected.to contain_package('libnl').with_before('Package[nexus1000v]') + is_expected.to contain_service('openvswitch').with_notify('Package[nexus1000v]') + is_expected.to contain_package('nexus1000v').with_notify('Service[nexus1000v]') + is_expected.to contain_service('nexus1000v').with_ensure('running') end context 'with local file vem rpm' do @@ -30,9 +30,9 @@ describe 'neutron::agents::n1kv_vem' do end it 'verify dependency' do - should contain_package('nexus1000v').with_source('/var/n1kv/vem.rpm') - should contain_file('/var/n1kv/vem.rpm').that_requires('File[/var/n1kv]') - should contain_file('/var/n1kv/vem.rpm').with( + is_expected.to contain_package('nexus1000v').with_source('/var/n1kv/vem.rpm') + is_expected.to contain_file('/var/n1kv/vem.rpm').that_requires('File[/var/n1kv]') + is_expected.to contain_file('/var/n1kv/vem.rpm').with( :owner => 'root', :group => 'root', :mode => '0664' @@ -48,8 +48,8 @@ describe 'neutron::agents::n1kv_vem' do end it 'verify dependency' do - should contain_package('nexus1000v').without_source - should contain_yumrepo('cisco-vem-repo').with( + is_expected.to contain_package('nexus1000v').without_source + is_expected.to contain_yumrepo('cisco-vem-repo').with( :baseurl => 'http://www.cisco.com/repo', :enabled => 1 ) @@ -57,7 +57,7 @@ describe 'neutron::agents::n1kv_vem' do end it 'execute reread config upon config change' do - should contain_exec('vemcmd reread config') \ + is_expected.to contain_exec('vemcmd reread config') \ .that_subscribes_to('File[/etc/n1kv/n1kv.conf]') end @@ -72,21 +72,21 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^l3control-ipaddr 9.0.0.1/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^switch-domain 900/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^host-mgmt-intf eth9/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^portdb ovs/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .without_content(/^phys/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .without_content(/^virt/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^node-type compute/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^fastpath-flood disable/) end end @@ -98,9 +98,9 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^node-type network/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .without_content(/^node-type compute/) end end @@ -112,9 +112,9 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^portdb vem/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .without_content(/^portdb ovs/) end end @@ -126,9 +126,9 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^fastpath-flood enable/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .without_content(/^fastpath-flood disable/) end end @@ -142,9 +142,9 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^phys eth1 profile prof1/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^phys eth2 profile prof2/) end @@ -165,9 +165,9 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^virt vtep1 profile profint mode dhcp/) - should contain_file('/etc/n1kv/n1kv.conf') \ + is_expected.to contain_file('/etc/n1kv/n1kv.conf') \ .with_content(/^virt vtep2 profile profint mode static/) end @@ -180,7 +180,7 @@ describe 'neutron::agents::n1kv_vem' do } end it 'should not start/stop service' do - should contain_service('nexus1000v').without_ensure + is_expected.to contain_service('nexus1000v').without_ensure end end @@ -192,7 +192,7 @@ describe 'neutron::agents::n1kv_vem' do } end it 'should stop service' do - should contain_service('nexus1000v').with_ensure('stopped') + is_expected.to contain_service('nexus1000v').with_ensure('stopped') end end @@ -203,12 +203,12 @@ describe 'neutron::agents::n1kv_vem' do } end it do - should contain_sysctl__value('net.ipv4.conf.default.rp_filter').with_value('2') - should contain_sysctl__value('net.ipv4.conf.all.rp_filter').with_value('2') - should contain_sysctl__value('net.ipv4.conf.default.arp_ignore').with_value('1') - should contain_sysctl__value('net.ipv4.conf.all.arp_ignore').with_value('1') - should contain_sysctl__value('net.ipv4.conf.all.arp_announce').with_value('2') - should contain_sysctl__value('net.ipv4.conf.default.arp_announce').with_value('2') + is_expected.to contain_sysctl__value('net.ipv4.conf.default.rp_filter').with_value('2') + is_expected.to contain_sysctl__value('net.ipv4.conf.all.rp_filter').with_value('2') + is_expected.to contain_sysctl__value('net.ipv4.conf.default.arp_ignore').with_value('1') + is_expected.to contain_sysctl__value('net.ipv4.conf.all.arp_ignore').with_value('1') + is_expected.to contain_sysctl__value('net.ipv4.conf.all.arp_announce').with_value('2') + is_expected.to contain_sysctl__value('net.ipv4.conf.default.arp_announce').with_value('2') end end diff --git a/spec/classes/neutron_agents_ovs_spec.rb b/spec/classes/neutron_agents_ovs_spec.rb index dd9090b07..7acef99ff 100644 --- a/spec/classes/neutron_agents_ovs_spec.rb +++ b/spec/classes/neutron_agents_ovs_spec.rb @@ -32,37 +32,37 @@ describe 'neutron::agents::ovs' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures ovs_neutron_plugin.ini' do - should contain_neutron_plugin_ovs('AGENT/polling_interval').with_value(p[:polling_interval]) - should contain_neutron_plugin_ovs('OVS/integration_bridge').with_value(p[:integration_bridge]) - should contain_neutron_plugin_ovs('SECURITYGROUP/firewall_driver').\ + is_expected.to contain_neutron_plugin_ovs('AGENT/polling_interval').with_value(p[:polling_interval]) + is_expected.to contain_neutron_plugin_ovs('OVS/integration_bridge').with_value(p[:integration_bridge]) + is_expected.to contain_neutron_plugin_ovs('SECURITYGROUP/firewall_driver').\ with_value(p[:firewall_driver]) - should contain_neutron_plugin_ovs('OVS/enable_tunneling').with_value(false) - should contain_neutron_plugin_ovs('OVS/tunnel_bridge').with_ensure('absent') - should contain_neutron_plugin_ovs('OVS/local_ip').with_ensure('absent') - should contain_neutron_plugin_ovs('AGENT/veth_mtu').with_ensure('absent') + is_expected.to contain_neutron_plugin_ovs('OVS/enable_tunneling').with_value(false) + is_expected.to contain_neutron_plugin_ovs('OVS/tunnel_bridge').with_ensure('absent') + is_expected.to contain_neutron_plugin_ovs('OVS/local_ip').with_ensure('absent') + is_expected.to contain_neutron_plugin_ovs('AGENT/veth_mtu').with_ensure('absent') end it 'configures vs_bridge' do - should contain_vs_bridge(p[:integration_bridge]).with_ensure('present') + is_expected.to contain_vs_bridge(p[:integration_bridge]).with_ensure('present') end it 'installs neutron ovs agent package' do if platform_params.has_key?(:ovs_agent_package) - should contain_package('neutron-plugin-ovs-agent').with( + is_expected.to contain_package('neutron-plugin-ovs-agent').with( :name => platform_params[:ovs_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron-plugin-ovs-agent').with_before(/Neutron_plugin_ovs\[.+\]/) + is_expected.to contain_package('neutron-plugin-ovs-agent').with_before(/Neutron_plugin_ovs\[.+\]/) else - should contain_package('neutron-plugin-ovs').with_before(/Neutron_plugin_ovs\[.+\]/) + is_expected.to contain_package('neutron-plugin-ovs').with_before(/Neutron_plugin_ovs\[.+\]/) end end it 'configures neutron ovs agent service' do - should contain_service('neutron-plugin-ovs-service').with( + is_expected.to contain_service('neutron-plugin-ovs-service').with( :name => platform_params[:ovs_agent_service], :enable => true, :ensure => 'running', @@ -76,7 +76,7 @@ describe 'neutron::agents::ovs' do end it 'should set the veth_mtu on the ovs agent' do - should contain_neutron_plugin_ovs('AGENT/veth_mtu').with_value(params[:veth_mtu]) + is_expected.to contain_neutron_plugin_ovs('AGENT/veth_mtu').with_value(params[:veth_mtu]) end end @@ -86,7 +86,7 @@ describe 'neutron::agents::ovs' do end it 'uninstalls neutron ovs agent package' do if platform_params.has_key?(:ovs_agent_package) - should contain_package('neutron-plugin-ovs-agent').with( + is_expected.to contain_package('neutron-plugin-ovs-agent').with( :name => platform_params[:ovs_agent_package], :ensure => p[:package_ensure] ) @@ -99,7 +99,7 @@ describe 'neutron::agents::ovs' do params.merge!(:firewall_driver => false) end it 'should configure firewall driver' do - should contain_neutron_plugin_ovs('SECURITYGROUP/firewall_driver').with_ensure('absent') + is_expected.to contain_neutron_plugin_ovs('SECURITYGROUP/firewall_driver').with_ensure('absent') end end @@ -109,17 +109,17 @@ describe 'neutron::agents::ovs' do end it 'configures bridge mappings' do - should contain_neutron_plugin_ovs('OVS/bridge_mappings') + is_expected.to contain_neutron_plugin_ovs('OVS/bridge_mappings') end it 'should configure bridge mappings' do - should contain_neutron__plugins__ovs__bridge(params[:bridge_mappings].join(',')).with( + is_expected.to contain_neutron__plugins__ovs__bridge(params[:bridge_mappings].join(',')).with( :before => 'Service[neutron-plugin-ovs-service]' ) end it 'should configure bridge uplinks' do - should contain_neutron__plugins__ovs__port(params[:bridge_uplinks].join(',')).with( + is_expected.to contain_neutron__plugins__ovs__port(params[:bridge_uplinks].join(',')).with( :before => 'Service[neutron-plugin-ovs-service]' ) end @@ -130,21 +130,19 @@ describe 'neutron::agents::ovs' do before :each do params.merge!(:enable_tunneling => true) end - it 'should fail' do - expect do - subject - end.to raise_error(Puppet::Error, /Local ip for ovs agent must be set when tunneling is enabled/) - end + + it_raises 'a Puppet::Error', /Local ip for ovs agent must be set when tunneling is enabled/ end + context 'with default params' do before :each do params.merge!(:enable_tunneling => true, :local_ip => '127.0.0.1' ) end it 'should configure ovs for tunneling' do - should contain_neutron_plugin_ovs('OVS/enable_tunneling').with_value(true) - should contain_neutron_plugin_ovs('OVS/tunnel_bridge').with_value(default_params[:tunnel_bridge]) - should contain_neutron_plugin_ovs('OVS/local_ip').with_value('127.0.0.1') - should contain_vs_bridge(default_params[:tunnel_bridge]).with_ensure('present') + is_expected.to contain_neutron_plugin_ovs('OVS/enable_tunneling').with_value(true) + is_expected.to contain_neutron_plugin_ovs('OVS/tunnel_bridge').with_value(default_params[:tunnel_bridge]) + is_expected.to contain_neutron_plugin_ovs('OVS/local_ip').with_value('127.0.0.1') + is_expected.to contain_vs_bridge(default_params[:tunnel_bridge]).with_ensure('present') end end @@ -157,8 +155,8 @@ describe 'neutron::agents::ovs' do end it 'should perform vxlan network configuration' do - should contain_neutron_plugin_ovs('agent/tunnel_types').with_value(params[:tunnel_types]) - should contain_neutron_plugin_ovs('agent/vxlan_udp_port').with_value(params[:vxlan_udp_port]) + is_expected.to contain_neutron_plugin_ovs('agent/tunnel_types').with_value(params[:tunnel_types]) + is_expected.to contain_neutron_plugin_ovs('agent/vxlan_udp_port').with_value(params[:vxlan_udp_port]) end end end @@ -189,11 +187,11 @@ describe 'neutron::agents::ovs' do it_configures 'neutron plugin ovs agent' it 'configures neutron ovs cleanup service' do - should contain_service('ovs-cleanup-service').with( + is_expected.to contain_service('ovs-cleanup-service').with( :name => platform_params[:ovs_cleanup_service], :enable => true ) - should contain_package('neutron-plugin-ovs').with_before(/Service\[ovs-cleanup-service\]/) + is_expected.to contain_package('neutron-plugin-ovs').with_before(/Service\[ovs-cleanup-service\]/) end end diff --git a/spec/classes/neutron_agents_vpnaas_spec.rb b/spec/classes/neutron_agents_vpnaas_spec.rb index 8ecf1ff60..40db3d9a0 100644 --- a/spec/classes/neutron_agents_vpnaas_spec.rb +++ b/spec/classes/neutron_agents_vpnaas_spec.rb @@ -45,15 +45,15 @@ describe 'neutron::agents::vpnaas' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it_configures 'openswan vpnaas_driver' it 'configures vpnaas_agent.ini' do - should contain_neutron_vpnaas_agent_config('vpnagent/vpn_device_driver').with_value(p[:vpn_device_driver]); - should contain_neutron_vpnaas_agent_config('ipsec/ipsec_status_check_interval').with_value(p[:ipsec_status_check_interval]); - should contain_neutron_vpnaas_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); - should contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_ensure('absent'); + is_expected.to contain_neutron_vpnaas_agent_config('vpnagent/vpn_device_driver').with_value(p[:vpn_device_driver]); + is_expected.to contain_neutron_vpnaas_agent_config('ipsec/ipsec_status_check_interval').with_value(p[:ipsec_status_check_interval]); + is_expected.to contain_neutron_vpnaas_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]); + is_expected.to contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_ensure('absent'); end context 'with external_network_bridge as br-ex' do @@ -64,25 +64,25 @@ describe 'neutron::agents::vpnaas' do end it 'configures vpnaas_agent.ini' do - should contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_value(p[:external_network_bridge]); + is_expected.to contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_value(p[:external_network_bridge]); end end it 'installs neutron vpnaas agent package' do if platform_params.has_key?(:vpnaas_agent_package) - should contain_package('neutron-vpnaas-agent').with( + is_expected.to contain_package('neutron-vpnaas-agent').with( :name => platform_params[:vpnaas_agent_package], :ensure => p[:package_ensure] ) - should contain_package('neutron').with_before(/Package\[neutron-vpnaas-agent\]/) - should contain_package('neutron-vpnaas-agent').with_before(/Neutron_vpnaas_agent_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Package\[neutron-vpnaas-agent\]/) + is_expected.to contain_package('neutron-vpnaas-agent').with_before(/Neutron_vpnaas_agent_config\[.+\]/) else - should contain_package('neutron').with_before(/Neutron_vpnaas_agent_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Neutron_vpnaas_agent_config\[.+\]/) end end it 'configures neutron vpnaas agent service' do - should contain_service('neutron-vpnaas-service').with( + is_expected.to contain_service('neutron-vpnaas-service').with( :name => platform_params[:vpnaas_agent_service], :enable => true, :ensure => 'running', @@ -95,7 +95,7 @@ describe 'neutron::agents::vpnaas' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-vpnaas-service').without_ensure + is_expected.to contain_service('neutron-vpnaas-service').without_ensure end end end @@ -103,9 +103,9 @@ describe 'neutron::agents::vpnaas' do shared_examples_for 'openswan vpnaas_driver' do it 'installs openswan packages' do if platform_params.has_key?(:vpnaas_agent_package) - should contain_package('openswan').with_before('Package[neutron-vpnaas-agent]') + is_expected.to contain_package('openswan').with_before('Package[neutron-vpnaas-agent]') end - should contain_package('openswan').with( + is_expected.to contain_package('openswan').with( :ensure => 'present', :name => platform_params[:openswan_package] ) diff --git a/spec/classes/neutron_client_spec.rb b/spec/classes/neutron_client_spec.rb index 8d6239f95..9da10a2a8 100644 --- a/spec/classes/neutron_client_spec.rb +++ b/spec/classes/neutron_client_spec.rb @@ -7,7 +7,7 @@ describe 'neutron::client' do { :osfamily => 'Debian' } end - it { should contain_class('neutron::client') } + it { is_expected.to contain_class('neutron::client') } end context 'on RedHat platforms' do @@ -15,6 +15,6 @@ describe 'neutron::client' do { :osfamily => 'RedHat' } end - it { should contain_class('neutron::client') } + it { is_expected.to contain_class('neutron::client') } end end diff --git a/spec/classes/neutron_db_mysql_spec.rb b/spec/classes/neutron_db_mysql_spec.rb index a129d38f3..466c4f500 100644 --- a/spec/classes/neutron_db_mysql_spec.rb +++ b/spec/classes/neutron_db_mysql_spec.rb @@ -20,7 +20,7 @@ describe 'neutron::db::mysql' do { :osfamily => 'Debian' } end - it { should contain_openstacklib__db__mysql('neutron').with( + it { is_expected.to contain_openstacklib__db__mysql('neutron').with( :user => 'neutron', :password_hash => '*74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3', :host => '127.0.0.1', @@ -33,7 +33,7 @@ describe 'neutron::db::mysql' do { :osfamily => 'RedHat' } end - it { should contain_openstacklib__db__mysql('neutron').with( + it { is_expected.to contain_openstacklib__db__mysql('neutron').with( :user => 'neutron', :password_hash => '*74B1C21ACE0C2D6B0678A5E503D2A60E8F9651A3', :host => '127.0.0.1', diff --git a/spec/classes/neutron_db_postgresql_spec.rb b/spec/classes/neutron_db_postgresql_spec.rb index 7e8613a07..b6f14dfc0 100644 --- a/spec/classes/neutron_db_postgresql_spec.rb +++ b/spec/classes/neutron_db_postgresql_spec.rb @@ -24,7 +24,7 @@ describe 'neutron::db::postgresql' do req_params end - it { should contain_postgresql__server__db('neutron').with( + it { is_expected.to contain_postgresql__server__db('neutron').with( :user => 'neutron', :password => 'md5696acd1dd66513a556a18a1beccd03d1' )} @@ -47,7 +47,7 @@ describe 'neutron::db::postgresql' do req_params end - it { should contain_postgresql__server__db('neutron').with( + it { is_expected.to contain_postgresql__server__db('neutron').with( :user => 'neutron', :password => 'md5696acd1dd66513a556a18a1beccd03d1' )} diff --git a/spec/classes/neutron_init_spec.rb b/spec/classes/neutron_init_spec.rb index d06f46254..e09fd9e48 100644 --- a/spec/classes/neutron_init_spec.rb +++ b/spec/classes/neutron_init_spec.rb @@ -44,8 +44,8 @@ describe 'neutron' do end it 'configures logging' do - should contain_neutron_config('DEFAULT/log_file').with_ensure('absent') - should contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir]) + is_expected.to contain_neutron_config('DEFAULT/log_file').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir]) end end @@ -71,10 +71,10 @@ describe 'neutron' do shared_examples_for 'a neutron base installation' do - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures neutron configuration folder' do - should contain_file('/etc/neutron/').with( + is_expected.to contain_file('/etc/neutron/').with( :ensure => 'directory', :owner => 'root', :group => 'neutron', @@ -84,7 +84,7 @@ describe 'neutron' do end it 'configures neutron configuration file' do - should contain_file('/etc/neutron/neutron.conf').with( + is_expected.to contain_file('/etc/neutron/neutron.conf').with( :owner => 'root', :group => 'neutron', :mode => '0640', @@ -93,60 +93,60 @@ describe 'neutron' do end it 'installs neutron package' do - should contain_package('neutron').with( + is_expected.to contain_package('neutron').with( :ensure => 'present', :name => platform_params[:common_package_name] ) end it 'configures credentials for rabbit' do - should contain_neutron_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_user] ) - should contain_neutron_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ) - should contain_neutron_config('DEFAULT/rabbit_password').with_secret( true ) - should contain_neutron_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] ) - should contain_neutron_config('DEFAULT/kombu_reconnect_delay').with_value( params[:kombu_reconnect_delay] ) + is_expected.to contain_neutron_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_user] ) + is_expected.to contain_neutron_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ) + is_expected.to contain_neutron_config('DEFAULT/rabbit_password').with_secret( true ) + is_expected.to contain_neutron_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] ) + is_expected.to contain_neutron_config('DEFAULT/kombu_reconnect_delay').with_value( params[:kombu_reconnect_delay] ) end it 'configures neutron.conf' do - should contain_neutron_config('DEFAULT/verbose').with_value( params[:verbose] ) - should contain_neutron_config('DEFAULT/bind_host').with_value('0.0.0.0') - should contain_neutron_config('DEFAULT/bind_port').with_value('9696') - should contain_neutron_config('DEFAULT/auth_strategy').with_value('keystone') - should contain_neutron_config('DEFAULT/core_plugin').with_value( params[:core_plugin] ) - should contain_neutron_config('DEFAULT/base_mac').with_value('fa:16:3e:00:00:00') - should contain_neutron_config('DEFAULT/mac_generation_retries').with_value(16) - should contain_neutron_config('DEFAULT/dhcp_lease_duration').with_value(86400) - should contain_neutron_config('DEFAULT/dhcp_agents_per_network').with_value(1) - should contain_neutron_config('DEFAULT/network_device_mtu').with_ensure('absent') - should contain_neutron_config('DEFAULT/dhcp_agent_notification').with_value(true) - should contain_neutron_config('DEFAULT/allow_bulk').with_value(true) - should contain_neutron_config('DEFAULT/allow_pagination').with_value(false) - should contain_neutron_config('DEFAULT/allow_sorting').with_value(false) - should contain_neutron_config('DEFAULT/allow_overlapping_ips').with_value(false) - should contain_neutron_config('DEFAULT/api_extensions_path').with_value(nil) - should contain_neutron_config('DEFAULT/control_exchange').with_value('neutron') - should contain_neutron_config('DEFAULT/state_path').with_value('/var/lib/neutron') - should contain_neutron_config('DEFAULT/lock_path').with_value('/var/lib/neutron/lock') - should contain_neutron_config('agent/root_helper').with_value('sudo neutron-rootwrap /etc/neutron/rootwrap.conf') - should contain_neutron_config('agent/report_interval').with_value('30') + is_expected.to contain_neutron_config('DEFAULT/verbose').with_value( params[:verbose] ) + is_expected.to contain_neutron_config('DEFAULT/bind_host').with_value('0.0.0.0') + is_expected.to contain_neutron_config('DEFAULT/bind_port').with_value('9696') + is_expected.to contain_neutron_config('DEFAULT/auth_strategy').with_value('keystone') + is_expected.to contain_neutron_config('DEFAULT/core_plugin').with_value( params[:core_plugin] ) + is_expected.to contain_neutron_config('DEFAULT/base_mac').with_value('fa:16:3e:00:00:00') + is_expected.to contain_neutron_config('DEFAULT/mac_generation_retries').with_value(16) + is_expected.to contain_neutron_config('DEFAULT/dhcp_lease_duration').with_value(86400) + is_expected.to contain_neutron_config('DEFAULT/dhcp_agents_per_network').with_value(1) + is_expected.to contain_neutron_config('DEFAULT/network_device_mtu').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/dhcp_agent_notification').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/allow_bulk').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/allow_pagination').with_value(false) + is_expected.to contain_neutron_config('DEFAULT/allow_sorting').with_value(false) + is_expected.to contain_neutron_config('DEFAULT/allow_overlapping_ips').with_value(false) + is_expected.to contain_neutron_config('DEFAULT/api_extensions_path').with_value(nil) + is_expected.to contain_neutron_config('DEFAULT/control_exchange').with_value('neutron') + is_expected.to contain_neutron_config('DEFAULT/state_path').with_value('/var/lib/neutron') + is_expected.to contain_neutron_config('DEFAULT/lock_path').with_value('/var/lib/neutron/lock') + is_expected.to contain_neutron_config('agent/root_helper').with_value('sudo neutron-rootwrap /etc/neutron/rootwrap.conf') + is_expected.to contain_neutron_config('agent/report_interval').with_value('30') end end shared_examples_for 'rabbit HA with a single virtual host' do it 'in neutron.conf' do - should_not contain_neutron_config('DEFAULT/rabbit_host') - should_not contain_neutron_config('DEFAULT/rabbit_port') - should contain_neutron_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts] ) - should contain_neutron_config('DEFAULT/rabbit_ha_queues').with_value(true) + is_expected.not_to contain_neutron_config('DEFAULT/rabbit_host') + is_expected.not_to contain_neutron_config('DEFAULT/rabbit_port') + is_expected.to contain_neutron_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts] ) + is_expected.to contain_neutron_config('DEFAULT/rabbit_ha_queues').with_value(true) end end shared_examples_for 'rabbit HA with multiple hosts' do it 'in neutron.conf' do - should_not contain_neutron_config('DEFAULT/rabbit_host') - should_not contain_neutron_config('DEFAULT/rabbit_port') - should contain_neutron_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) - should contain_neutron_config('DEFAULT/rabbit_ha_queues').with_value(true) + is_expected.not_to contain_neutron_config('DEFAULT/rabbit_host') + is_expected.not_to contain_neutron_config('DEFAULT/rabbit_port') + is_expected.to contain_neutron_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) + is_expected.to contain_neutron_config('DEFAULT/rabbit_ha_queues').with_value(true) end end @@ -160,10 +160,10 @@ describe 'neutron' do ) end - it { should contain_neutron_config('DEFAULT/use_ssl').with_value('true') } - it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') } - it { should contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') } - it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') } + it { is_expected.to contain_neutron_config('DEFAULT/use_ssl').with_value('true') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') } end shared_examples_for 'with SSL socket options set with wrong parameters' do @@ -188,10 +188,10 @@ describe 'neutron' do ) end - it { should contain_neutron_config('DEFAULT/use_ssl').with_value('false') } - it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_ensure('absent') } - it { should contain_neutron_config('DEFAULT/ssl_key_file').with_ensure('absent') } - it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') } + it { is_expected.to contain_neutron_config('DEFAULT/use_ssl').with_value('false') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_cert_file').with_ensure('absent') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_key_file').with_ensure('absent') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') } end shared_examples_for 'with SSL socket options set and no ca_file' do @@ -203,10 +203,10 @@ describe 'neutron' do ) end - it { should contain_neutron_config('DEFAULT/use_ssl').with_value('true') } - it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') } - it { should contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') } - it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') } + it { is_expected.to contain_neutron_config('DEFAULT/use_ssl').with_value('true') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') } + it { is_expected.to contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') } end shared_examples_for 'with SSL socket options disabled with ca_file' do @@ -221,7 +221,7 @@ describe 'neutron' do end shared_examples_for 'with syslog disabled' do - it { should contain_neutron_config('DEFAULT/use_syslog').with_value(false) } + it { is_expected.to contain_neutron_config('DEFAULT/use_syslog').with_value(false) } end shared_examples_for 'with SSL enabled with kombu' do @@ -236,11 +236,11 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true') - should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ssl/ca/certs') - should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/ssl/cert/file') - should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/ssl/keyfile') - should contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') + is_expected.to contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ssl/ca/certs') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/ssl/cert/file') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/ssl/keyfile') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') end end @@ -252,11 +252,11 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true') - should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') - should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') - should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') - should contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') + is_expected.to contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') end end @@ -269,11 +269,11 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('false') - should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') - should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') - should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') - should contain_neutron_config('DEFAULT/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('false') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/kombu_ssl_version').with_ensure('absent') end end @@ -331,8 +331,8 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/use_syslog').with_value(true) - should contain_neutron_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') + is_expected.to contain_neutron_config('DEFAULT/use_syslog').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') end end @@ -345,8 +345,8 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/use_syslog').with_value(true) - should contain_neutron_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') + is_expected.to contain_neutron_config('DEFAULT/use_syslog').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') end end @@ -358,8 +358,8 @@ describe 'neutron' do ) end it 'configures logging' do - should contain_neutron_config('DEFAULT/log_file').with_value(params[:log_file]) - should contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir]) + is_expected.to contain_neutron_config('DEFAULT/log_file').with_value(params[:log_file]) + is_expected.to contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir]) end end @@ -369,8 +369,8 @@ describe 'neutron' do :log_dir => false )} it { - should contain_neutron_config('DEFAULT/log_file').with_ensure('absent') - should contain_neutron_config('DEFAULT/log_dir').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/log_file').with_ensure('absent') + is_expected.to contain_neutron_config('DEFAULT/log_dir').with_ensure('absent') } end @@ -380,13 +380,13 @@ describe 'neutron' do :lock_path => 'lock_path' )} it { - should contain_neutron_config('DEFAULT/state_path').with_value('state_path') - should contain_neutron_config('DEFAULT/lock_path').with_value('lock_path') + is_expected.to contain_neutron_config('DEFAULT/state_path').with_value('state_path') + is_expected.to contain_neutron_config('DEFAULT/lock_path').with_value('lock_path') } end shared_examples_for 'without service_plugins' do - it { should_not contain_neutron_config('DEFAULT/service_plugins') } + it { is_expected.not_to contain_neutron_config('DEFAULT/service_plugins') } end shared_examples_for 'with service_plugins' do @@ -397,13 +397,13 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/service_plugins').with_value('router,firewall,lbaas,vpnaas,metering') + is_expected.to contain_neutron_config('DEFAULT/service_plugins').with_value('router,firewall,lbaas,vpnaas,metering') end end shared_examples_for 'without memcache_servers' do - it { should contain_neutron_config('DEFAULT/memcached_servers').with_ensure('absent') } + it { is_expected.to contain_neutron_config('DEFAULT/memcached_servers').with_ensure('absent') } end shared_examples_for 'with memcache_servers' do @@ -414,7 +414,7 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/memcached_servers').with_value('memcache1,memcache2,memcache3') + is_expected.to contain_neutron_config('DEFAULT/memcached_servers').with_value('memcache1,memcache2,memcache3') end end @@ -427,7 +427,7 @@ describe 'neutron' do end it do - should contain_neutron_config('DEFAULT/network_device_mtu').with_value(params[:network_device_mtu]) + is_expected.to contain_neutron_config('DEFAULT/network_device_mtu').with_value(params[:network_device_mtu]) end end diff --git a/spec/classes/neutron_keystone_auth_spec.rb b/spec/classes/neutron_keystone_auth_spec.rb index db2ed2bea..f7d3e4159 100644 --- a/spec/classes/neutron_keystone_auth_spec.rb +++ b/spec/classes/neutron_keystone_auth_spec.rb @@ -10,24 +10,24 @@ describe 'neutron::keystone::auth' do } end - it { should contain_keystone_user('neutron').with( + it { is_expected.to contain_keystone_user('neutron').with( :ensure => 'present', :password => 'neutron_password', :tenant => 'foobar' ) } - it { should contain_keystone_user_role('neutron@foobar').with( + it { is_expected.to contain_keystone_user_role('neutron@foobar').with( :ensure => 'present', :roles => 'admin' )} - it { should contain_keystone_service('neutron').with( + it { is_expected.to contain_keystone_service('neutron').with( :ensure => 'present', :type => 'network', :description => 'Neutron Networking Service' ) } - it { should contain_keystone_endpoint('RegionOne/neutron').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/neutron').with( :ensure => 'present', :public_url => "http://127.0.0.1:9696/", :admin_url => "http://127.0.0.1:9696/", @@ -52,7 +52,7 @@ describe 'neutron::keystone::auth' do } end - it { should contain_keystone_endpoint('RegionOne/neutron').with_notify('Service[neutron-server]') } + it { is_expected.to contain_keystone_endpoint('RegionOne/neutron').with_notify('Service[neutron-server]') } end describe 'when overriding public_protocol, public_port and public address' do @@ -69,7 +69,7 @@ describe 'neutron::keystone::auth' do } end - it { should contain_keystone_endpoint('RegionOne/neutron').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/neutron').with( :ensure => 'present', :public_url => "https://10.10.10.10:80/", :internal_url => "http://10.10.10.11:81/", @@ -88,7 +88,7 @@ describe 'neutron::keystone::auth' do } end - it { should contain_keystone_endpoint('RegionOne/neutron').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/neutron').with( :ensure => 'present', :public_url => "http://127.0.0.1:9696/", :admin_url => "https://127.0.0.1:9696/", @@ -106,13 +106,13 @@ describe 'neutron::keystone::auth' do } end - it { should contain_keystone_user('neutrony') } + it { is_expected.to contain_keystone_user('neutrony') } - it { should contain_keystone_user_role('neutrony@services') } + it { is_expected.to contain_keystone_user_role('neutrony@services') } - it { should contain_keystone_service('neutrony') } + it { is_expected.to contain_keystone_service('neutrony') } - it { should contain_keystone_endpoint('RegionOne/neutrony') } + it { is_expected.to contain_keystone_endpoint('RegionOne/neutrony') } end @@ -125,10 +125,10 @@ describe 'neutron::keystone::auth' do } end - it { should contain_keystone_user('neutron') } - it { should contain_keystone_user_role('neutron@services') } - it { should contain_keystone_service('neutron_service') } - it { should contain_keystone_endpoint('RegionOne/neutron_service') } + it { is_expected.to contain_keystone_user('neutron') } + it { is_expected.to contain_keystone_user_role('neutron@services') } + it { is_expected.to contain_keystone_service('neutron_service') } + it { is_expected.to contain_keystone_endpoint('RegionOne/neutron_service') } end @@ -141,11 +141,11 @@ describe 'neutron::keystone::auth' do } end - it { should_not contain_keystone_user('neutron') } + it { is_expected.not_to contain_keystone_user('neutron') } - it { should contain_keystone_user_role('neutron@services') } + it { is_expected.to contain_keystone_user_role('neutron@services') } - it { should contain_keystone_service('neutron').with( + it { is_expected.to contain_keystone_service('neutron').with( :ensure => 'present', :type => 'network', :description => 'Neutron Networking Service' @@ -163,11 +163,11 @@ describe 'neutron::keystone::auth' do } end - it { should_not contain_keystone_user('neutron') } + it { is_expected.not_to contain_keystone_user('neutron') } - it { should_not contain_keystone_user_role('neutron@services') } + it { is_expected.not_to contain_keystone_user_role('neutron@services') } - it { should contain_keystone_service('neutron').with( + it { is_expected.to contain_keystone_service('neutron').with( :ensure => 'present', :type => 'network', :description => 'Neutron Networking Service' diff --git a/spec/classes/neutron_plugins_cisco_ml2_spec.rb b/spec/classes/neutron_plugins_cisco_ml2_spec.rb index 7fd3d4a12..c43a6b6d9 100644 --- a/spec/classes/neutron_plugins_cisco_ml2_spec.rb +++ b/spec/classes/neutron_plugins_cisco_ml2_spec.rb @@ -28,9 +28,7 @@ describe 'neutron::plugins::ml2::cisco::nexus' do end context 'fail when missing nexus_config' do - it 'should fails to configure cisco nexus driver' do - expect { subject }.to raise_error(Puppet::Error, /No nexus config specified/) - end + it_raises 'a Puppet::Error', /No nexus config specified/ end context 'when using cisco' do @@ -52,7 +50,7 @@ describe 'neutron::plugins::ml2::cisco::nexus' do end it 'installs ncclient package' do - should contain_package('python-ncclient').with( + is_expected.to contain_package('python-ncclient').with( :ensure => 'installed' ) end diff --git a/spec/classes/neutron_plugins_cisco_spec.rb b/spec/classes/neutron_plugins_cisco_spec.rb index 2e8ac5ff1..dccc2c60b 100644 --- a/spec/classes/neutron_plugins_cisco_spec.rb +++ b/spec/classes/neutron_plugins_cisco_spec.rb @@ -40,7 +40,7 @@ describe 'neutron::plugins::cisco' do end it 'should create plugin symbolic link' do - should contain_file('/etc/neutron/plugin.ini').with( + is_expected.to contain_file('/etc/neutron/plugin.ini').with( :ensure => 'link', :target => '/etc/neutron/plugins/cisco/cisco_plugins.ini', :require => 'Package[neutron-plugin-cisco]' @@ -48,7 +48,7 @@ describe 'neutron::plugins::cisco' do end it 'should have a plugin config folder' do - should contain_file('/etc/neutron/plugins').with( + is_expected.to contain_file('/etc/neutron/plugins').with( :ensure => 'directory', :owner => 'root', :group => 'neutron', @@ -57,7 +57,7 @@ describe 'neutron::plugins::cisco' do end it 'should have a cisco plugin config folder' do - should contain_file('/etc/neutron/plugins/cisco').with( + is_expected.to contain_file('/etc/neutron/plugins/cisco').with( :ensure => 'directory', :owner => 'root', :group => 'neutron', @@ -66,54 +66,54 @@ describe 'neutron::plugins::cisco' do end it 'should perform default l2 configuration' do - should contain_neutron_plugin_cisco_l2network('VLANS/vlan_start').\ + is_expected.to contain_neutron_plugin_cisco_l2network('VLANS/vlan_start').\ with_value(params[:vlan_start]) - should contain_neutron_plugin_cisco_l2network('VLANS/vlan_end').\ + is_expected.to contain_neutron_plugin_cisco_l2network('VLANS/vlan_end').\ with_value(params[:vlan_end]) - should contain_neutron_plugin_cisco_l2network('VLANS/vlan_name_prefix').\ + is_expected.to contain_neutron_plugin_cisco_l2network('VLANS/vlan_name_prefix').\ with_value(params[:vlan_name_prefix]) - should contain_neutron_plugin_cisco_l2network('MODEL/model_class').\ + is_expected.to contain_neutron_plugin_cisco_l2network('MODEL/model_class').\ with_value(params[:model_class]) - should contain_neutron_plugin_cisco_l2network('PORTS/max_ports').\ + is_expected.to contain_neutron_plugin_cisco_l2network('PORTS/max_ports').\ with_value(params[:max_ports]) - should contain_neutron_plugin_cisco_l2network('PORTPROFILES/max_port_profiles').\ + is_expected.to contain_neutron_plugin_cisco_l2network('PORTPROFILES/max_port_profiles').\ with_value(params[:max_port_profiles]) - should contain_neutron_plugin_cisco_l2network('NETWORKS/max_networks').\ + is_expected.to contain_neutron_plugin_cisco_l2network('NETWORKS/max_networks').\ with_value(params[:max_networks]) - should contain_neutron_plugin_cisco_l2network('SEGMENTATION/manager_class').\ + is_expected.to contain_neutron_plugin_cisco_l2network('SEGMENTATION/manager_class').\ with_value(params[:manager_class]) end it 'should create a dummy inventory item' do - should contain_neutron_plugin_cisco('INVENTORY/dummy').\ + is_expected.to contain_neutron_plugin_cisco('INVENTORY/dummy').\ with_value('dummy') end it 'should configure the db connection' do - should contain_neutron_plugin_cisco_db_conn('DATABASE/name').\ + is_expected.to contain_neutron_plugin_cisco_db_conn('DATABASE/name').\ with_value(params[:database_name]) - should contain_neutron_plugin_cisco_db_conn('DATABASE/user').\ + is_expected.to contain_neutron_plugin_cisco_db_conn('DATABASE/user').\ with_value(params[:database_user]) - should contain_neutron_plugin_cisco_db_conn('DATABASE/pass').\ + is_expected.to contain_neutron_plugin_cisco_db_conn('DATABASE/pass').\ with_value(params[:database_pass]) - should contain_neutron_plugin_cisco_db_conn('DATABASE/host').\ + is_expected.to contain_neutron_plugin_cisco_db_conn('DATABASE/host').\ with_value(params[:database_host]) end it 'should configure the admin credentials' do - should contain_neutron_plugin_cisco_credentials('keystone/username').\ + is_expected.to contain_neutron_plugin_cisco_credentials('keystone/username').\ with_value(params[:keystone_username]) - should contain_neutron_plugin_cisco_credentials('keystone/password').\ + is_expected.to contain_neutron_plugin_cisco_credentials('keystone/password').\ with_value(params[:keystone_password]) - should contain_neutron_plugin_cisco_credentials('keystone/password').with_secret( true ) - should contain_neutron_plugin_cisco_credentials('keystone/auth_url').\ + is_expected.to contain_neutron_plugin_cisco_credentials('keystone/password').with_secret( true ) + is_expected.to contain_neutron_plugin_cisco_credentials('keystone/auth_url').\ with_value(params[:keystone_auth_url]) - should contain_neutron_plugin_cisco_credentials('keystone/tenant').\ + is_expected.to contain_neutron_plugin_cisco_credentials('keystone/tenant').\ with_value(params[:keystone_tenant]) end it 'should perform vswitch plugin configuration' do - should contain_neutron_plugin_cisco('PLUGINS/vswitch_plugin').\ + is_expected.to contain_neutron_plugin_cisco('PLUGINS/vswitch_plugin').\ with_value('neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2') end @@ -123,7 +123,7 @@ describe 'neutron::plugins::cisco' do end it 'should perform nexus plugin configuration' do - should contain_neutron_plugin_cisco('PLUGINS/nexus_plugin').\ + is_expected.to contain_neutron_plugin_cisco('PLUGINS/nexus_plugin').\ with_value('neutron.plugins.cisco.nexus.cisco_nexus_plugin_v2.NexusPlugin') end end @@ -140,7 +140,7 @@ describe 'neutron::plugins::cisco' do end it 'configures /etc/default/neutron-server' do - should contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( + is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( :path => '/etc/default/neutron-server', :match => '^NEUTRON_PLUGIN_CONFIG=(.*)$', :line => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugins/cisco/cisco_plugins.ini', diff --git a/spec/classes/neutron_plugins_linuxbridge_spec.rb b/spec/classes/neutron_plugins_linuxbridge_spec.rb index c27aab8c0..54eae25d9 100644 --- a/spec/classes/neutron_plugins_linuxbridge_spec.rb +++ b/spec/classes/neutron_plugins_linuxbridge_spec.rb @@ -16,26 +16,26 @@ describe 'neutron::plugins::linuxbridge' do shared_examples_for 'neutron linuxbridge plugin' do - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'installs neutron linuxbridge plugin package' do - should contain_package('neutron-plugin-linuxbridge').with( + is_expected.to contain_package('neutron-plugin-linuxbridge').with( :ensure => params[:package_ensure], :name => platform_params[:linuxbridge_plugin_package] ) end it 'configures linuxbridge_conf.ini' do - should contain_neutron_plugin_linuxbridge('VLANS/tenant_network_type').with( + is_expected.to contain_neutron_plugin_linuxbridge('VLANS/tenant_network_type').with( :value => params[:tenant_network_type] ) - should contain_neutron_plugin_linuxbridge('VLANS/network_vlan_ranges').with( + is_expected.to contain_neutron_plugin_linuxbridge('VLANS/network_vlan_ranges').with( :value => params[:network_vlan_ranges] ) end it 'should create plugin symbolic link' do - should contain_file('/etc/neutron/plugin.ini').with( + is_expected.to contain_file('/etc/neutron/plugin.ini').with( :ensure => 'link', :target => '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini', :require => 'Package[neutron-plugin-linuxbridge]' @@ -58,7 +58,7 @@ describe 'neutron::plugins::linuxbridge' do end it 'configures /etc/default/neutron-server' do - should contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( + is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( :path => '/etc/default/neutron-server', :match => '^NEUTRON_PLUGIN_CONFIG=(.*)$', :line => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini', diff --git a/spec/classes/neutron_plugins_ml2_spec.rb b/spec/classes/neutron_plugins_ml2_spec.rb index daa87392d..dd43e411c 100644 --- a/spec/classes/neutron_plugins_ml2_spec.rb +++ b/spec/classes/neutron_plugins_ml2_spec.rb @@ -49,20 +49,20 @@ describe 'neutron::plugins::ml2' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'configures neutron.conf' do - should contain_neutron_config('DEFAULT/core_plugin').with_value('neutron.plugins.ml2.plugin.Ml2Plugin') + is_expected.to contain_neutron_config('DEFAULT/core_plugin').with_value('neutron.plugins.ml2.plugin.Ml2Plugin') end it 'configures ml2_conf.ini' do - should contain_neutron_plugin_ml2('ml2/type_drivers').with_value(p[:type_drivers].join(',')) - should contain_neutron_plugin_ml2('ml2/tenant_network_types').with_value(p[:tenant_network_types].join(',')) - should contain_neutron_plugin_ml2('ml2/mechanism_drivers').with_value(p[:mechanism_drivers].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2/type_drivers').with_value(p[:type_drivers].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2/tenant_network_types').with_value(p[:tenant_network_types].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2/mechanism_drivers').with_value(p[:mechanism_drivers].join(',')) end it 'creates plugin symbolic link' do - should contain_file('/etc/neutron/plugin.ini').with( + is_expected.to contain_file('/etc/neutron/plugin.ini').with( :ensure => 'link', :target => '/etc/neutron/plugins/ml2/ml2_conf.ini' ) @@ -70,11 +70,11 @@ describe 'neutron::plugins::ml2' do it 'installs ml2 package (if any)' do if platform_params.has_key?(:ml2_server_package) - should contain_package('neutron-plugin-ml2').with( + is_expected.to contain_package('neutron-plugin-ml2').with( :name => platform_params[:ml2_server_package], :ensure => p[:package_ensure] ) - should contain_package('neutron-plugin-ml2').with_before(/Neutron_plugin_ml2\[.+\]/) + is_expected.to contain_package('neutron-plugin-ml2').with_before(/Neutron_plugin_ml2\[.+\]/) end end @@ -82,9 +82,8 @@ describe 'neutron::plugins::ml2' do before :each do params.merge!(:type_drivers => ['foobar']) end - it 'fails to configure ml2 because foobar is not a valid driver' do - expect { subject }.to raise_error(Puppet::Error, /type_driver unknown./) - end + + it_raises 'a Puppet::Error', /type_driver unknown./ end context 'when using flat driver' do @@ -92,7 +91,7 @@ describe 'neutron::plugins::ml2' do params.merge!(:flat_networks => ['eth1', 'eth2']) end it 'configures flat_networks' do - should contain_neutron_plugin_ml2('ml2_type_flat/flat_networks').with_value(p[:flat_networks].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2_type_flat/flat_networks').with_value(p[:flat_networks].join(',')) end end @@ -101,7 +100,7 @@ describe 'neutron::plugins::ml2' do params.merge!(:tunnel_id_ranges => ['0:20', '40:60']) end it 'configures gre_networks with valid ranges' do - should contain_neutron_plugin_ml2('ml2_type_gre/tunnel_id_ranges').with_value(p[:tunnel_id_ranges].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2_type_gre/tunnel_id_ranges').with_value(p[:tunnel_id_ranges].join(',')) end end @@ -109,9 +108,8 @@ describe 'neutron::plugins::ml2' do before :each do params.merge!(:tunnel_id_ranges => ['0:20', '40:100000000']) end - it 'fails to configure gre_networks because of too big range' do - expect { subject }.to raise_error(Puppet::Error, /tunnel id ranges are to large./) - end + + it_raises 'a Puppet::Error', /tunnel id ranges are to large./ end context 'when using vlan driver with valid values' do @@ -119,7 +117,7 @@ describe 'neutron::plugins::ml2' do params.merge!(:network_vlan_ranges => ['1:20', '400:4094']) end it 'configures vlan_networks with 1:20 and 400:4094 VLAN ranges' do - should contain_neutron_plugin_ml2('ml2_type_vlan/network_vlan_ranges').with_value(p[:network_vlan_ranges].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2_type_vlan/network_vlan_ranges').with_value(p[:network_vlan_ranges].join(',')) end end @@ -127,18 +125,16 @@ describe 'neutron::plugins::ml2' do before :each do params.merge!(:network_vlan_ranges => ['1:20', '400:4099']) end - it 'fails to configure vlan_networks because of 400:4099 VLAN range' do - expect { subject }.to raise_error(Puppet::Error, /vlan id are invalid./) - end + + it_raises 'a Puppet::Error', /vlan id are invalid./ end context 'when using vlan driver with invalid vlan range' do before :each do params.merge!(:network_vlan_ranges => ['2938:1']) end - it 'fails to configure network_vlan_ranges with 2938:1 range' do - expect { subject }.to raise_error(Puppet::Error, /vlan ranges are invalid./) - end + + it_raises 'a Puppet::Error', /vlan ranges are invalid./ end context 'when using vxlan driver with valid values' do @@ -146,8 +142,8 @@ describe 'neutron::plugins::ml2' do params.merge!(:vni_ranges => ['40:300', '500:1000'], :vxlan_group => '224.1.1.1') end it 'configures vxlan_networks with 224.1.1.1 vxlan group' do - should contain_neutron_plugin_ml2('ml2_type_vxlan/vni_ranges').with_value(p[:vni_ranges].join(',')) - should contain_neutron_plugin_ml2('ml2_type_vxlan/vxlan_group').with_value(p[:vxlan_group]) + is_expected.to contain_neutron_plugin_ml2('ml2_type_vxlan/vni_ranges').with_value(p[:vni_ranges].join(',')) + is_expected.to contain_neutron_plugin_ml2('ml2_type_vxlan/vxlan_group').with_value(p[:vxlan_group]) end end @@ -155,18 +151,16 @@ describe 'neutron::plugins::ml2' do before :each do params.merge!(:vxlan_group => '192.1.1.1') end - it 'fails to configure vxlan_group with 192.1.1.1 vxlan group' do - expect { subject }.to raise_error(Puppet::Error, /is not valid for vxlan_group./) - end + + it_raises 'a Puppet::Error', /is not valid for vxlan_group./ end context 'when using vxlan driver with invalid vni_range' do before :each do params.merge!(:vni_ranges => ['2938:1']) end - it 'fails to configure vni_ranges with 2938:1 range' do - expect { subject }.to raise_error(Puppet::Error, /vni ranges are invalid./) - end + + it_raises 'a Puppet::Error', /vni ranges are invalid./ end context 'when overriding package ensure state' do @@ -175,7 +169,7 @@ describe 'neutron::plugins::ml2' do end it 'overrides package ensure state (if possible)' do if platform_params.has_key?(:ml2_server_package) - should contain_package('neutron-plugin-ml2').with( + is_expected.to contain_package('neutron-plugin-ml2').with( :name => platform_params[:ml2_server_package], :ensure => params[:package_ensure] ) @@ -191,8 +185,8 @@ describe 'neutron::plugins::ml2' do ) end it 'configures sriov mechanism driver with agent_enabled' do - should contain_neutron_plugin_ml2('ml2_sriov/supported_pci_vendor_dev').with_value(['15b3:1004,8086:10ca']) - should contain_neutron_plugin_ml2('ml2_sriov/agent_required').with_value('true') + is_expected.to contain_neutron_plugin_ml2('ml2_sriov/supported_pci_vendor_dev').with_value(['15b3:1004,8086:10ca']) + is_expected.to contain_neutron_plugin_ml2('ml2_sriov/agent_required').with_value('true') end end @@ -202,11 +196,11 @@ describe 'neutron::plugins::ml2' do end it 'configures /etc/default/neutron-server' do - should contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( + is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with( :path => '/etc/default/neutron-server', :match => '^NEUTRON_PLUGIN_CONFIG=(.*)$', :line => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugin.ini', - :require => ['File[/etc/neutron/plugin.ini]'] + :require => 'File[/etc/neutron/plugin.ini]' ) end end diff --git a/spec/classes/neutron_plugins_nvp_spec.rb b/spec/classes/neutron_plugins_nvp_spec.rb index 444d1ff65..3f50e3183 100644 --- a/spec/classes/neutron_plugins_nvp_spec.rb +++ b/spec/classes/neutron_plugins_nvp_spec.rb @@ -31,21 +31,21 @@ describe 'neutron::plugins::nvp' do default_params.merge(params) end - it { should contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::params') } it 'should have' do - should contain_package('neutron-plugin-nvp').with( + is_expected.to contain_package('neutron-plugin-nvp').with( :name => platform_params[:nvp_server_package], :ensure => p[:package_ensure] ) end it 'should configure neutron.conf' do - should contain_neutron_config('DEFAULT/core_plugin').with_value('neutron.plugins.nicira.NeutronPlugin.NvpPluginV2') + is_expected.to contain_neutron_config('DEFAULT/core_plugin').with_value('neutron.plugins.nicira.NeutronPlugin.NvpPluginV2') end it 'should create plugin symbolic link' do - should contain_file('/etc/neutron/plugin.ini').with( + is_expected.to contain_file('/etc/neutron/plugin.ini').with( :ensure => 'link', :target => '/etc/neutron/plugins/nicira/nvp.ini', :require => 'Package[neutron-plugin-nvp]' @@ -53,13 +53,13 @@ describe 'neutron::plugins::nvp' do end it 'should configure nvp.ini' do - should contain_neutron_plugin_nvp('DEFAULT/default_tz_uuid').with_value(p[:default_tz_uuid]) - should contain_neutron_plugin_nvp('nvp/metadata_mode').with_value(p[:metadata_mode]) - should contain_neutron_plugin_nvp('DEFAULT/nvp_controllers').with_value(p[:nvp_controllers].join(',')) - should contain_neutron_plugin_nvp('DEFAULT/nvp_user').with_value(p[:nvp_user]) - should contain_neutron_plugin_nvp('DEFAULT/nvp_password').with_value(p[:nvp_password]) - should contain_neutron_plugin_nvp('DEFAULT/nvp_password').with_secret( true ) - should_not contain_neutron_plugin_nvp('DEFAULT/default_l3_gw_service_uuid').with_value(p[:default_l3_gw_service_uuid]) + is_expected.to contain_neutron_plugin_nvp('DEFAULT/default_tz_uuid').with_value(p[:default_tz_uuid]) + is_expected.to contain_neutron_plugin_nvp('nvp/metadata_mode').with_value(p[:metadata_mode]) + is_expected.to contain_neutron_plugin_nvp('DEFAULT/nvp_controllers').with_value(p[:nvp_controllers].join(',')) + is_expected.to contain_neutron_plugin_nvp('DEFAULT/nvp_user').with_value(p[:nvp_user]) + is_expected.to contain_neutron_plugin_nvp('DEFAULT/nvp_password').with_value(p[:nvp_password]) + is_expected.to contain_neutron_plugin_nvp('DEFAULT/nvp_password').with_secret( true ) + is_expected.not_to contain_neutron_plugin_nvp('DEFAULT/default_l3_gw_service_uuid').with_value(p[:default_l3_gw_service_uuid]) end context 'configure nvp with optional params' do @@ -68,7 +68,7 @@ describe 'neutron::plugins::nvp' do end it 'should configure nvp.ini' do - should contain_neutron_plugin_nvp('DEFAULT/default_l3_gw_service_uuid').with_value(params[:default_l3_gw_service_uuid]) + is_expected.to contain_neutron_plugin_nvp('DEFAULT/default_l3_gw_service_uuid').with_value(params[:default_l3_gw_service_uuid]) end end @@ -78,9 +78,8 @@ describe 'neutron::plugins::nvp' do rabbit_password => 'passw0rd', core_plugin => 'foo' }" end - it 'should fail to configure nvp because core_plugin should contain NvpPluginV2 class' do - expect { subject }.to raise_error(Puppet::Error, /nvp plugin should be the core_plugin in neutron.conf/) - end + + it_raises 'a Puppet::Error', /nvp plugin should be the core_plugin in neutron.conf/ end end diff --git a/spec/classes/neutron_plugins_ovs_spec.rb b/spec/classes/neutron_plugins_ovs_spec.rb index 66ee21e0d..578189e6e 100644 --- a/spec/classes/neutron_plugins_ovs_spec.rb +++ b/spec/classes/neutron_plugins_ovs_spec.rb @@ -28,7 +28,7 @@ describe 'neutron::plugins::ovs' do end it 'should create plugin symbolic link' do - should contain_file('/etc/neutron/plugin.ini').with( + is_expected.to contain_file('/etc/neutron/plugin.ini').with( :ensure => 'link', :target => '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini', :require => 'Package[neutron-plugin-ovs]' @@ -36,12 +36,12 @@ describe 'neutron::plugins::ovs' do end it 'should perform default configuration of' do - should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) - should contain_package('neutron-plugin-ovs').with( + is_expected.to contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) + is_expected.to contain_package('neutron-plugin-ovs').with( :name => platform_params[:ovs_server_package], :ensure => params[:package_ensure] ) - should_not contain_class('vswitch::ovs') + is_expected.not_to contain_class('vswitch::ovs') end context 'with vlan mode' do @@ -50,8 +50,8 @@ describe 'neutron::plugins::ovs' do end it 'should perform vlan network configuration' do - should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) - should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) + is_expected.to contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) + is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) end end @@ -65,9 +65,9 @@ describe 'neutron::plugins::ovs' do end it 'should perform gre network configuration' do - should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) - should contain_neutron_plugin_ovs('OVS/tunnel_id_ranges').with_value(params[:tunnel_id_ranges]) - should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_ensure('absent') + is_expected.to contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) + is_expected.to contain_neutron_plugin_ovs('OVS/tunnel_id_ranges').with_value(params[:tunnel_id_ranges]) + is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_ensure('absent') end end @@ -79,9 +79,9 @@ describe 'neutron::plugins::ovs' do end it 'should perform gre network configuration' do - should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) - should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) - should contain_neutron_plugin_ovs('OVS/tunnel_id_ranges').with_value(params[:tunnel_id_ranges]) + is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) + is_expected.to contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) + is_expected.to contain_neutron_plugin_ovs('OVS/tunnel_id_ranges').with_value(params[:tunnel_id_ranges]) end end @@ -96,9 +96,9 @@ describe 'neutron::plugins::ovs' do end it 'should perform vxlan network configuration' do - should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) - should contain_neutron_plugin_ovs('OVS/vxlan_udp_port').with_value(params[:vxlan_udp_port]) - should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_ensure('absent') + is_expected.to contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) + is_expected.to contain_neutron_plugin_ovs('OVS/vxlan_udp_port').with_value(params[:vxlan_udp_port]) + is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_ensure('absent') end end @@ -108,9 +108,7 @@ describe 'neutron::plugins::ovs' do :vxlan_udp_port => '1',} end - it 'should fail if invalid port is passed' do - expect { subject }.to raise_error(Puppet::Error, /vxlan udp port is invalid./) - end + it_raises 'a Puppet::Error', /vxlan udp port is invalid./ end context 'with vxlan tunnelling using bad tunnel_id_ranges' do @@ -119,9 +117,7 @@ describe 'neutron::plugins::ovs' do :tunnel_id_ranges => '100:9',} end - it 'should fail if invalid id range is passed' do - expect { subject }.to raise_error(Puppet::Error, /tunnel id ranges are invalid./) - end + it_raises 'a Puppet::Error', /tunnel id ranges are invalid./ end context 'with vxlan tunneling and provider networks using bad network_vlan_ranges' do @@ -130,9 +126,7 @@ describe 'neutron::plugins::ovs' do :network_vlan_ranges => 'physnet1:200:1'} end - it 'should fail if invalid vlan range is passed' do - expect { subject }.to raise_error(Puppet::Error, /network vlan ranges are invalid./) - end + it_raises 'a Puppet::Error', /network vlan ranges are invalid./ end context 'with vxlan tunneling using bad multiple network_vlan_ranges' do @@ -141,9 +135,7 @@ describe 'neutron::plugins::ovs' do :network_vlan_ranges => ['physnet1:0:100', 'physnet2:1000:1']} end - it 'should fail if invalid network vlan range is passed' do - expect { subject }.to raise_error(Puppet::Error, /network vlan ranges are invalid/) - end + it_raises 'a Puppet::Error', /network vlan ranges are invalid/ end context 'with vxlan tunneling and provider networks' do @@ -153,8 +145,8 @@ describe 'neutron::plugins::ovs' do end it 'should perform vxlan network configuration' do - should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) - should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) + is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) + is_expected.to contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type]) end end @@ -162,21 +154,21 @@ describe 'neutron::plugins::ovs' do let :params do { :tenant_network_type => 'flat'} end - it { should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) } + it { is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) } end context 'with comma separated vlan ranges' do let :params do { :network_vlan_ranges => 'physint1:1000:2000,physext1:100:200' } end - it { should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) } + it { is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges]) } end context 'with vlan ranges in array' do let :params do { :network_vlan_ranges => ['physint1:1000:2000', 'physext1:100:200'] } end - it { should contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges].join(',')) } + it { is_expected.to contain_neutron_plugin_ovs('OVS/network_vlan_ranges').with_value(params[:network_vlan_ranges].join(',')) } end end diff --git a/spec/classes/neutron_policy_spec.rb b/spec/classes/neutron_policy_spec.rb index b485a9e55..682c303af 100644 --- a/spec/classes/neutron_policy_spec.rb +++ b/spec/classes/neutron_policy_spec.rb @@ -16,7 +16,7 @@ describe 'neutron::policy' do end it 'set up the policies' do - should contain_openstacklib__policy__base('context_is_admin').with({ + is_expected.to contain_openstacklib__policy__base('context_is_admin').with({ :key => 'context_is_admin', :value => 'foo:bar' }) diff --git a/spec/classes/neutron_quota_spec.rb b/spec/classes/neutron_quota_spec.rb index ce2829b4a..e5dce11fe 100644 --- a/spec/classes/neutron_quota_spec.rb +++ b/spec/classes/neutron_quota_spec.rb @@ -35,7 +35,7 @@ describe 'neutron::quota' do it 'configures quota in neutron.conf' do params_hash.each_pair do |config,value| - should contain_neutron_config("quotas/#{config}").with_value( value ) + is_expected.to contain_neutron_config("quotas/#{config}").with_value( value ) end end end diff --git a/spec/classes/neutron_server_notifications_spec.rb b/spec/classes/neutron_server_notifications_spec.rb index 3bc4768e7..9a7820e78 100644 --- a/spec/classes/neutron_server_notifications_spec.rb +++ b/spec/classes/neutron_server_notifications_spec.rb @@ -46,16 +46,16 @@ describe 'neutron::server::notifications' do end it 'configure neutron.conf' do - should contain_neutron_config('DEFAULT/notify_nova_on_port_status_changes').with_value(true) - should contain_neutron_config('DEFAULT/notify_nova_on_port_data_changes').with_value(true) - should contain_neutron_config('DEFAULT/send_events_interval').with_value('2') - should contain_neutron_config('DEFAULT/nova_url').with_value('http://127.0.0.1:8774/v2') - should contain_neutron_config('DEFAULT/nova_admin_auth_url').with_value('http://127.0.0.1:35357/v2.0') - should contain_neutron_config('DEFAULT/nova_admin_username').with_value('nova') - should contain_neutron_config('DEFAULT/nova_admin_password').with_value('secrete') - should contain_neutron_config('DEFAULT/nova_admin_password').with_secret( true ) - should contain_neutron_config('DEFAULT/nova_region_name').with_value('RegionOne') - should contain_neutron_config('DEFAULT/nova_admin_tenant_id').with_value('UUID') + is_expected.to contain_neutron_config('DEFAULT/notify_nova_on_port_status_changes').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/notify_nova_on_port_data_changes').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/send_events_interval').with_value('2') + is_expected.to contain_neutron_config('DEFAULT/nova_url').with_value('http://127.0.0.1:8774/v2') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_auth_url').with_value('http://127.0.0.1:35357/v2.0') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_username').with_value('nova') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_password').with_value('secrete') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_password').with_secret( true ) + is_expected.to contain_neutron_config('DEFAULT/nova_region_name').with_value('RegionOne') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_tenant_id').with_value('UUID') end context 'when overriding parameters' do @@ -72,16 +72,16 @@ describe 'neutron::server::notifications' do ) end it 'should configure neutron server with overrided parameters' do - should contain_neutron_config('DEFAULT/notify_nova_on_port_status_changes').with_value(false) - should contain_neutron_config('DEFAULT/notify_nova_on_port_data_changes').with_value(false) - should contain_neutron_config('DEFAULT/send_events_interval').with_value('10') - should contain_neutron_config('DEFAULT/nova_url').with_value('http://nova:8774/v3') - should contain_neutron_config('DEFAULT/nova_admin_auth_url').with_value('http://keystone:35357/v2.0') - should contain_neutron_config('DEFAULT/nova_admin_username').with_value('joe') - should contain_neutron_config('DEFAULT/nova_admin_password').with_value('secrete') - should contain_neutron_config('DEFAULT/nova_admin_password').with_secret( true ) - should contain_neutron_config('DEFAULT/nova_region_name').with_value('MyRegion') - should contain_neutron_config('DEFAULT/nova_admin_tenant_id').with_value('UUID2') + is_expected.to contain_neutron_config('DEFAULT/notify_nova_on_port_status_changes').with_value(false) + is_expected.to contain_neutron_config('DEFAULT/notify_nova_on_port_data_changes').with_value(false) + is_expected.to contain_neutron_config('DEFAULT/send_events_interval').with_value('10') + is_expected.to contain_neutron_config('DEFAULT/nova_url').with_value('http://nova:8774/v3') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_auth_url').with_value('http://keystone:35357/v2.0') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_username').with_value('joe') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_password').with_value('secrete') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_password').with_secret( true ) + is_expected.to contain_neutron_config('DEFAULT/nova_region_name').with_value('MyRegion') + is_expected.to contain_neutron_config('DEFAULT/nova_admin_tenant_id').with_value('UUID2') end end @@ -89,9 +89,8 @@ describe 'neutron::server::notifications' do before :each do params.merge!(:nova_admin_password => '') end - it 'should fail to configure neutron server' do - expect { subject }.to raise_error(Puppet::Error, /nova_admin_password must be set./) - end + + it_raises 'a Puppet::Error', /nova_admin_password must be set./ end context 'when no nova_admin_tenant_id and nova_admin_tenant_name specified' do @@ -101,9 +100,8 @@ describe 'neutron::server::notifications' do :nova_admin_tenant_name => '' ) end - it 'should fail to configure neutron server' do - expect { subject }.to raise_error(Puppet::Error, /You must provide either nova_admin_tenant_name or nova_admin_tenant_id./) - end + + it_raises 'a Puppet::Error', /You must provide either nova_admin_tenant_name or nova_admin_tenant_id./ end context 'when providing a tenant name' do @@ -114,7 +112,7 @@ describe 'neutron::server::notifications' do ) end it 'should configure nova admin tenant id' do - should contain_nova_admin_tenant_id_setter('nova_admin_tenant_id').with( + is_expected.to contain_nova_admin_tenant_id_setter('nova_admin_tenant_id').with( :ensure => 'present', :tenant_name => 'services', :auth_url => 'http://127.0.0.1:35357/v2.0', diff --git a/spec/classes/neutron_server_spec.rb b/spec/classes/neutron_server_spec.rb index f4ce8c986..ddf87c675 100644 --- a/spec/classes/neutron_server_spec.rb +++ b/spec/classes/neutron_server_spec.rb @@ -44,60 +44,60 @@ describe 'neutron::server' do end it 'should perform default database configuration of' do - should contain_neutron_config('database/connection').with_value(p[:database_connection]) - should contain_neutron_config('database/connection').with_secret( true ) - should contain_neutron_config('database/max_retries').with_value(p[:database_max_retries]) - should contain_neutron_config('database/idle_timeout').with_value(p[:database_idle_timeout]) - should contain_neutron_config('database/retry_interval').with_value(p[:database_retry_interval]) - should contain_neutron_config('database/min_pool_size').with_value(p[:database_min_pool_size]) - should contain_neutron_config('database/max_pool_size').with_value(p[:database_max_pool_size]) - should contain_neutron_config('database/max_overflow').with_value(p[:database_max_overflow]) + is_expected.to contain_neutron_config('database/connection').with_value(p[:database_connection]) + is_expected.to contain_neutron_config('database/connection').with_secret( true ) + is_expected.to contain_neutron_config('database/max_retries').with_value(p[:database_max_retries]) + is_expected.to contain_neutron_config('database/idle_timeout').with_value(p[:database_idle_timeout]) + is_expected.to contain_neutron_config('database/retry_interval').with_value(p[:database_retry_interval]) + is_expected.to contain_neutron_config('database/min_pool_size').with_value(p[:database_min_pool_size]) + is_expected.to contain_neutron_config('database/max_pool_size').with_value(p[:database_max_pool_size]) + is_expected.to contain_neutron_config('database/max_overflow').with_value(p[:database_max_overflow]) end - it { should contain_class('neutron::params') } - it { should contain_class('neutron::policy') } + it { is_expected.to contain_class('neutron::params') } + it { is_expected.to contain_class('neutron::policy') } it 'configures authentication middleware' do - should contain_neutron_api_config('filter:authtoken/auth_host').with_value(p[:auth_host]); - should contain_neutron_api_config('filter:authtoken/auth_port').with_value(p[:auth_port]); - should contain_neutron_api_config('filter:authtoken/admin_tenant_name').with_value(p[:auth_tenant]); - should contain_neutron_api_config('filter:authtoken/admin_user').with_value(p[:auth_user]); - should contain_neutron_api_config('filter:authtoken/admin_password').with_value(p[:auth_password]); - should contain_neutron_api_config('filter:authtoken/admin_password').with_secret( true ) - should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with(:ensure => 'absent') - should contain_neutron_api_config('filter:authtoken/auth_uri').with_value("http://localhost:5000/"); + is_expected.to contain_neutron_api_config('filter:authtoken/auth_host').with_value(p[:auth_host]); + is_expected.to contain_neutron_api_config('filter:authtoken/auth_port').with_value(p[:auth_port]); + is_expected.to contain_neutron_api_config('filter:authtoken/admin_tenant_name').with_value(p[:auth_tenant]); + is_expected.to contain_neutron_api_config('filter:authtoken/admin_user').with_value(p[:auth_user]); + is_expected.to contain_neutron_api_config('filter:authtoken/admin_password').with_value(p[:auth_password]); + is_expected.to contain_neutron_api_config('filter:authtoken/admin_password').with_secret( true ) + is_expected.to contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with(:ensure => 'absent') + is_expected.to contain_neutron_api_config('filter:authtoken/auth_uri').with_value("http://localhost:5000/"); end it 'installs neutron server package' do if platform_params.has_key?(:server_package) - should contain_package('neutron-server').with( + is_expected.to contain_package('neutron-server').with( :name => platform_params[:server_package], :ensure => p[:package_ensure] ) - should contain_package('neutron-server').with_before(/Neutron_api_config\[.+\]/) - should contain_package('neutron-server').with_before(/Neutron_config\[.+\]/) - should contain_package('neutron-server').with_before(/Service\[neutron-server\]/) + is_expected.to contain_package('neutron-server').with_before(/Neutron_api_config\[.+\]/) + is_expected.to contain_package('neutron-server').with_before(/Neutron_config\[.+\]/) + is_expected.to contain_package('neutron-server').with_before(/Service\[neutron-server\]/) else - should contain_package('neutron').with_before(/Neutron_api_config\[.+\]/) + is_expected.to contain_package('neutron').with_before(/Neutron_api_config\[.+\]/) end end it 'configures neutron server service' do - should contain_service('neutron-server').with( + is_expected.to contain_service('neutron-server').with( :name => platform_params[:server_service], :enable => true, :ensure => 'running', :require => 'Class[Neutron]' ) - should_not contain_exec('neutron-db-sync') - should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with( + is_expected.not_to contain_exec('neutron-db-sync') + is_expected.to contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with( :ensure => 'absent' ) - should contain_service('neutron-server').with_name('neutron-server') - should contain_neutron_config('DEFAULT/api_workers').with_value(facts[:processorcount]) - should contain_neutron_config('DEFAULT/rpc_workers').with_value(facts[:processorcount]) - should contain_neutron_config('DEFAULT/agent_down_time').with_value(p[:agent_down_time]) - should contain_neutron_config('DEFAULT/router_scheduler_driver').with_value(p[:router_scheduler_driver]) + is_expected.to contain_service('neutron-server').with_name('neutron-server') + is_expected.to contain_neutron_config('DEFAULT/api_workers').with_value(facts[:processorcount]) + is_expected.to contain_neutron_config('DEFAULT/rpc_workers').with_value(facts[:processorcount]) + is_expected.to contain_neutron_config('DEFAULT/agent_down_time').with_value(p[:agent_down_time]) + is_expected.to contain_neutron_config('DEFAULT/router_scheduler_driver').with_value(p[:router_scheduler_driver]) end context 'with manage_service as false' do @@ -105,7 +105,7 @@ describe 'neutron::server' do params.merge!(:manage_service => false) end it 'should not start/stop service' do - should contain_service('neutron-server').without_ensure + is_expected.to contain_service('neutron-server').without_ensure end end @@ -114,7 +114,7 @@ describe 'neutron::server' do params.merge!(:router_distributed => true) end it 'should enable DVR' do - should contain_neutron_config('DEFAULT/router_distributed').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/router_distributed').with_value(true) end end @@ -123,10 +123,10 @@ describe 'neutron::server' do params.merge!(:l3_ha => true) end it 'should enable HA routers' do - should contain_neutron_config('DEFAULT/l3_ha').with_value(true) - should contain_neutron_config('DEFAULT/max_l3_agents_per_router').with_value('3') - should contain_neutron_config('DEFAULT/min_l3_agents_per_router').with_value('2') - should contain_neutron_config('DEFAULT/l3_ha_net_cidr').with_value('169.254.192.0/18') + is_expected.to contain_neutron_config('DEFAULT/l3_ha').with_value(true) + is_expected.to contain_neutron_config('DEFAULT/max_l3_agents_per_router').with_value('3') + is_expected.to contain_neutron_config('DEFAULT/min_l3_agents_per_router').with_value('2') + is_expected.to contain_neutron_config('DEFAULT/l3_ha_net_cidr').with_value('169.254.192.0/18') end end @@ -136,7 +136,7 @@ describe 'neutron::server' do :max_l3_agents_per_router => '0' ) end it 'should enable HA routers' do - should contain_neutron_config('DEFAULT/max_l3_agents_per_router').with_value('0') + is_expected.to contain_neutron_config('DEFAULT/max_l3_agents_per_router').with_value('0') end end @@ -146,9 +146,8 @@ describe 'neutron::server' do :max_l3_agents_per_router => '2', :min_l3_agents_per_router => '3' ) end - it 'should fail to configure HA routerd' do - expect { subject }.to raise_error(Puppet::Error, /min_l3_agents_per_router should be less than or equal to max_l3_agents_per_router./) - end + + it_raises 'a Puppet::Error', /min_l3_agents_per_router should be less than or equal to max_l3_agents_per_router./ end context 'with custom service name' do @@ -156,7 +155,7 @@ describe 'neutron::server' do params.merge!(:service_name => 'custom-service-name') end it 'should configure proper service name' do - should contain_service('neutron-server').with_name('custom-service-name') + is_expected.to contain_service('neutron-server').with_name('custom-service-name') end end @@ -166,20 +165,20 @@ describe 'neutron::server' do :lock_path => 'lock_path' ) end it 'should override state_path and lock_path from base class' do - should contain_neutron_config('DEFAULT/state_path').with_value(p[:state_path]) - should contain_neutron_config('DEFAULT/lock_path').with_value(p[:lock_path]) + is_expected.to contain_neutron_config('DEFAULT/state_path').with_value(p[:state_path]) + is_expected.to contain_neutron_config('DEFAULT/lock_path').with_value(p[:lock_path]) end end context 'with allow_automatic_l3agent_failover in neutron.conf' do it 'should configure allow_automatic_l3agent_failover' do - should contain_neutron_config('DEFAULT/allow_automatic_l3agent_failover').with_value(p[:allow_automatic_l3agent_failover]) + is_expected.to contain_neutron_config('DEFAULT/allow_automatic_l3agent_failover').with_value(p[:allow_automatic_l3agent_failover]) end end end shared_examples_for 'a neutron server with auth_admin_prefix set' do - [ '/keystone', '/keystone/admin', '' ].each do |auth_admin_prefix| + [ '/keystone', '/keystone/admin' ].each do |auth_admin_prefix| describe "with keystone_auth_admin_prefix containing incorrect value #{auth_admin_prefix}" do before do params.merge!({ @@ -187,7 +186,7 @@ describe 'neutron::server' do }) end it do - should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with( + is_expected.to contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with( :value => params[:auth_admin_prefix] ) end @@ -203,11 +202,7 @@ describe 'neutron::server' do :auth_admin_prefix => auth_admin_prefix, }) end - it do - expect { - should contain_neutron_api_config('filter:authtoken/auth_admin_prefix') - }.to raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) - end + it_raises 'a Puppet::Error', /validate_re\(\): "#{auth_admin_prefix}" does not match/ end end end @@ -226,7 +221,7 @@ describe 'neutron::server' do ) end it 'should exec neutron-db-sync' do - should contain_exec('neutron-db-sync').with( + is_expected.to contain_exec('neutron-db-sync').with( :command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head', :path => '/usr/bin', :before => 'Service[neutron-server]', @@ -243,7 +238,7 @@ describe 'neutron::server' do ) end it 'configures database connection' do - should contain_neutron_config('database/connection').with_value(params[:database_connection]) + is_expected.to contain_neutron_config('database/connection').with_value(params[:database_connection]) end end @@ -257,12 +252,12 @@ describe 'neutron::server' do }) end it 'configures auth_uri' do - should contain_neutron_config('keystone_authtoken/auth_uri').with_value("https://foo.bar:1234/"); + is_expected.to contain_neutron_config('keystone_authtoken/auth_uri').with_value("https://foo.bar:1234/"); # since only auth_uri is set the deprecated auth parameters should # still get set in case they are still in use - should contain_neutron_config('keystone_authtoken/auth_host').with_value('localhost'); - should contain_neutron_config('keystone_authtoken/auth_port').with_value('35357'); - should contain_neutron_config('keystone_authtoken/auth_protocol').with_value('http'); + is_expected.to contain_neutron_config('keystone_authtoken/auth_host').with_value('localhost'); + is_expected.to contain_neutron_config('keystone_authtoken/auth_port').with_value('35357'); + is_expected.to contain_neutron_config('keystone_authtoken/auth_protocol').with_value('http'); end end @@ -276,12 +271,12 @@ describe 'neutron::server' do }) end it 'configures identity_uri' do - should contain_neutron_config('keystone_authtoken/identity_uri').with_value("https://foo.bar:1234/"); + is_expected.to contain_neutron_config('keystone_authtoken/identity_uri').with_value("https://foo.bar:1234/"); # since only auth_uri is set the deprecated auth parameters should # still get set in case they are still in use - should contain_neutron_config('keystone_authtoken/auth_host').with_value('localhost'); - should contain_neutron_config('keystone_authtoken/auth_port').with_value('35357'); - should contain_neutron_config('keystone_authtoken/auth_protocol').with_value('http'); + is_expected.to contain_neutron_config('keystone_authtoken/auth_host').with_value('localhost'); + is_expected.to contain_neutron_config('keystone_authtoken/auth_port').with_value('35357'); + is_expected.to contain_neutron_config('keystone_authtoken/auth_protocol').with_value('http'); end end @@ -296,12 +291,12 @@ describe 'neutron::server' do }) end it 'configures identity_uri and auth_uri but deprecates old auth settings' do - should contain_neutron_config('keystone_authtoken/identity_uri').with_value("https://foo.bar:35357/"); - should contain_neutron_config('keystone_authtoken/auth_uri').with_value("https://foo.bar:5000/v2.0/"); - should contain_neutron_config('keystone_authtoken/auth_admin_prefix').with(:ensure => 'absent') - should contain_neutron_config('keystone_authtoken/auth_port').with(:ensure => 'absent') - should contain_neutron_config('keystone_authtoken/auth_protocol').with(:ensure => 'absent') - should contain_neutron_config('keystone_authtoken/auth_host').with(:ensure => 'absent') + is_expected.to contain_neutron_config('keystone_authtoken/identity_uri').with_value("https://foo.bar:35357/"); + is_expected.to contain_neutron_config('keystone_authtoken/auth_uri').with_value("https://foo.bar:5000/v2.0/"); + is_expected.to contain_neutron_config('keystone_authtoken/auth_admin_prefix').with(:ensure => 'absent') + is_expected.to contain_neutron_config('keystone_authtoken/auth_port').with(:ensure => 'absent') + is_expected.to contain_neutron_config('keystone_authtoken/auth_protocol').with(:ensure => 'absent') + is_expected.to contain_neutron_config('keystone_authtoken/auth_host').with(:ensure => 'absent') end end diff --git a/spec/classes/neutron_services_fwaas_spec.rb b/spec/classes/neutron_services_fwaas_spec.rb index 5a5e32a20..60ad58338 100644 --- a/spec/classes/neutron_services_fwaas_spec.rb +++ b/spec/classes/neutron_services_fwaas_spec.rb @@ -41,8 +41,8 @@ describe 'neutron::services::fwaas' do end it 'configures driver in fwaas_driver.ini' do - should contain_neutron_fwaas_service_config('fwaas/driver').with_value('neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver') - should contain_neutron_fwaas_service_config('fwaas/enabled').with_value('true') + is_expected.to contain_neutron_fwaas_service_config('fwaas/driver').with_value('neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver') + is_expected.to contain_neutron_fwaas_service_config('fwaas/enabled').with_value('true') end end @@ -59,7 +59,7 @@ describe 'neutron::services::fwaas' do it_configures 'neutron fwaas service plugin' it 'installs neutron l3 agent package' do - should contain_package('neutron-l3-agent').with_ensure('present') + is_expected.to contain_package('neutron-l3-agent').with_ensure('present') end end @@ -80,7 +80,7 @@ describe 'neutron::services::fwaas' do it_configures 'neutron fwaas service plugin' it 'installs neutron vpnaas agent package' do - should contain_package('neutron-vpn-agent').with_ensure('present') + is_expected.to contain_package('neutron-vpn-agent').with_ensure('present') end end @@ -96,7 +96,7 @@ describe 'neutron::services::fwaas' do it_configures 'neutron fwaas service plugin' it 'installs neutron fwaas service package' do - should contain_package('openstack-neutron-fwaas').with_ensure('present') + is_expected.to contain_package('openstack-neutron-fwaas').with_ensure('present') end end diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index d92156a36..fec0eacc9 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -1,5 +1,5 @@ shared_examples_for "a Puppet::Error" do |description| it "with message matching #{description.inspect}" do - expect { should have_class_count(1) }.to raise_error(Puppet::Error, description) + expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description) end end diff --git a/spec/unit/provider/neutron_l3_ovs_bridge/neutron_spec.rb b/spec/unit/provider/neutron_l3_ovs_bridge/neutron_spec.rb index e2f3ef27a..dc7018d0d 100644 --- a/spec/unit/provider/neutron_l3_ovs_bridge/neutron_spec.rb +++ b/spec/unit/provider/neutron_l3_ovs_bridge/neutron_spec.rb @@ -22,7 +22,7 @@ describe provider_class do it 'should return an empty array for no matches' do provider.expects(:ip).returns('') - provider.bridge_ip_addresses.should eql [] + expect(provider.bridge_ip_addresses).to eql [] end it 'should return an array of addresses if matches are found' do @@ -34,7 +34,7 @@ describe provider_class do valid_lft forever preferred_lft forever EOT provider.expects(:ip).returns(output) - provider.bridge_ip_addresses.should eql ['172.24.4.225/28'] + expect(provider.bridge_ip_addresses).to eql ['172.24.4.225/28'] end end @@ -44,7 +44,7 @@ EOT it 'should return true if the gateway ip is present' do provider.expects(:bridge_ip_addresses).returns(['a']) provider.expects(:gateway_ip).returns('a') - provider.exists?.should eql true + expect(provider.exists?).to eql true end end diff --git a/spec/unit/provider/neutron_router_interface/neutron_spec.rb b/spec/unit/provider/neutron_router_interface/neutron_spec.rb index 1678e19bc..a53f81cec 100644 --- a/spec/unit/provider/neutron_router_interface/neutron_spec.rb +++ b/spec/unit/provider/neutron_router_interface/neutron_spec.rb @@ -24,11 +24,11 @@ describe provider_class do end it 'should return the correct router name' do - provider.router_name.should eql('router') + expect(provider.router_name).to eql('router') end it 'should return the correct subnet name' do - provider.subnet_name.should eql('subnet') + expect(provider.subnet_name).to eql('subnet') end end diff --git a/spec/unit/provider/neutron_spec.rb b/spec/unit/provider/neutron_spec.rb index fed14ece2..fa10d9683 100644 --- a/spec/unit/provider/neutron_spec.rb +++ b/spec/unit/provider/neutron_spec.rb @@ -65,7 +65,7 @@ describe Puppet::Provider::Neutron do it 'should use specified host/port/protocol in the auth endpoint' do conf = {'keystone_authtoken' => credential_hash} klass.expects(:neutron_conf).returns(conf) - klass.get_auth_endpoint.should == auth_endpoint + expect(klass.get_auth_endpoint).to eq(auth_endpoint) end it 'should find region_name if specified' do @@ -137,7 +137,7 @@ describe Puppet::Provider::Neutron do EOT klass.expects(:auth_neutron).returns(output) result = klass.list_neutron_resources('foo') - result.should eql(['net1', 'net2']) + expect(result).to eql(['net1', 'net2']) end it 'should return empty list when there are no neutron resources' do @@ -145,7 +145,7 @@ describe Puppet::Provider::Neutron do EOT klass.stubs(:auth_neutron).returns(output) result = klass.list_neutron_resources('foo') - result.should eql([]) + expect(result).to eql([]) end it 'should fail if resources list is nil' do @@ -162,7 +162,7 @@ describe Puppet::Provider::Neutron do it 'should parse single-valued attributes into a key-value pair' do klass.expects(:auth_neutron).returns('admin_state_up="True"') result = klass.get_neutron_resource_attrs('foo', 'id') - result.should eql({"admin_state_up" => 'True'}) + expect(result).to eql({"admin_state_up" => 'True'}) end it 'should parse multi-valued attributes into a key-list pair' do @@ -173,7 +173,7 @@ subnet3" EOT klass.expects(:auth_neutron).returns(output) result = klass.get_neutron_resource_attrs('foo', 'id') - result.should eql({"subnets" => ['subnet1', 'subnet2', 'subnet3']}) + expect(result).to eql({"subnets" => ['subnet1', 'subnet2', 'subnet3']}) end end @@ -189,7 +189,7 @@ subnet3" '--format=csv', router) result = klass.list_router_ports(router) - result.should eql([]) + expect(result).to eql([]) end it 'should handle several ports' do @@ -217,7 +217,7 @@ subnet3" with('router-port-list', '--format=csv', router). returns(output) result = klass.list_router_ports(router) - result.should eql(expected) + expect(result).to eql(expected) end end @@ -238,7 +238,7 @@ tenant_id="3056a91768d948d399f1d79051a7f221" 'name' => 'foo', 'tenant_id' => '3056a91768d948d399f1d79051a7f221', } - klass.parse_creation_output(data).should == expected + expect(klass.parse_creation_output(data)).to eq(expected) end end diff --git a/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb b/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb index feb6c1864..2dd22a988 100644 --- a/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb +++ b/spec/unit/provider/nova_admin_tenant_id_setter/neutron_spec.rb @@ -74,7 +74,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should create a resource' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect(provider.create).to be_nil end @@ -86,7 +86,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_true + expect(provider.exists?).to be_truthy expect(provider.create).to be_nil end end @@ -111,7 +111,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should receive an api error' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect { provider.create }.to raise_error KeystoneAPIError, /Unable to find matching tenant/ end end @@ -136,7 +136,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should receive an api error' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect { provider.create }.to raise_error KeystoneAPIError, /Found multiple matches for tenant name/ end end @@ -153,7 +153,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should receive an authentication error' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect { provider.create }.to raise_error KeystoneAPIError end end @@ -167,7 +167,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should receive a connection error' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect { provider.create }.to raise_error KeystoneConnectionError end end @@ -181,7 +181,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should receive a connection error' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect { provider.create }.to raise_error KeystoneConnectionError end end @@ -203,7 +203,7 @@ describe 'Puppet::Type.type(:nova_admin_tenant_id_setter)' do it 'should create a resource' do resource = Puppet::Type::Nova_admin_tenant_id_setter.new(params) provider = provider_class.new(resource) - expect(provider.exists?).to be_false + expect(provider.exists?).to be_falsey expect(provider.create).to be_nil end end