puppet-neutron/spec/classes/neutron_agents_ml2_sriov_spec.rb
Cody Herriges ccac02b917 Make tests pass on Puppet 4.x
This commit makes the following changes, mostly to specs to get them
  passing on Puppet 4.x: removes redefinition of $name because it is now
  a reserved word and redundant in Puppet 3.x, cleans up the use of
  Puppet's old behavior of implicitly converting String to Integers
  since Puppet 4.x is pretty strictly typed, sets facts required for
  doing flow control and comparison, fixes implicit use of empty string
  that is assumed to be the same as false by updating tests that inject
  empty string into params to represent a value not being provide by a
  user to false instead.

Closes-bug: #1447620
Change-Id: Ibb651f26f33549dbe564dc88167b8f578a03fd77
2015-06-16 09:57:29 -07:00

98 lines
3.0 KiB
Ruby

require 'spec_helper'
describe 'neutron::agents::ml2::sriov' do
let :pre_condition do
"class { 'neutron': rabbit_password => 'passw0rd' }"
end
let :default_params do
{ :package_ensure => 'present',
:enabled => true,
:physical_device_mappings => [],
:exclude_devices => [],
:polling_interval => 2,
}
end
let :default_facts do
{ :operatingsystem => 'default',
:operatingsystemrelease => 'default'
}
end
let :params do
{}
end
shared_examples_for 'neutron sriov-nic agent with ml2 plugin' do
let :p do
default_params.merge(params)
end
it { is_expected.to contain_class('neutron::params') }
it 'configures ovs_neutron_plugin.ini' do
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
is_expected.to contain_package('neutron-sriov-nic-agent').with(
:name => platform_params[:sriov_nic_agent_package],
:ensure => p[:package_ensure],
:tag => 'openstack'
)
is_expected.to contain_package('neutron-sriov-nic-agent').with_before(/Neutron_plugin_ml2\[.+\]/)
end
it 'configures neutron ovs agent service' do
is_expected.to contain_service('neutron-sriov-nic-agent-service').with(
:name => platform_params[:sriov_nic_agent_service],
:enable => true,
:ensure => 'running',
:require => 'Class[Neutron]'
)
end
context 'when supplying device mapping' do
before :each do
params.merge!(:physical_device_mappings => ['physnet1:eth1'],
:exclude_devices => ['physnet1:eth2'])
end
it 'configures physical device mappings with exclusion' do
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
context 'on Debian platforms' do
let :facts do
default_facts.merge({ :osfamily => 'Debian' })
end
let :platform_params do
{ :sriov_nic_agent_package => 'neutron-plugin-sriov-agent',
:sriov_nic_agent_service => 'neutron-plugin-sriov-agent' }
end
it_configures 'neutron sriov-nic agent with ml2 plugin'
end
context 'on RedHat platforms' do
let :facts do
default_facts.merge({ :osfamily => 'RedHat' })
end
let :platform_params do
{ :sriov_nic_agent_package => 'openstack-neutron-sriov-nic-agent',
:sriov_nic_agent_service => 'neutron-sriov-nic-agent' }
end
it_configures 'neutron sriov-nic agent with ml2 plugin'
end
end