try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / spec / classes / neutron_agents_ml2_sriov_spec.rb
1 require 'spec_helper'
2
3 describe 'neutron::agents::ml2::sriov' do
4
5   let :pre_condition do
6     "class { 'neutron': rabbit_password => 'passw0rd' }"
7   end
8
9   let :default_params do
10     { :package_ensure             => 'present',
11       :enabled                    => true,
12       :physical_device_mappings   => [],
13       :exclude_devices            => [],
14       :polling_interval           => 2,
15     }
16   end
17
18   let :params do
19     {}
20   end
21
22   shared_examples_for 'neutron sriov-nic agent with ml2 plugin' do
23     let :p do
24       default_params.merge(params)
25     end
26
27     it { should contain_class('neutron::params') }
28
29     it 'configures ovs_neutron_plugin.ini' do
30       should contain_neutron_plugin_ml2('sriov_nic/polling_interval').with_value(p[:polling_interval])
31       should contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(p[:exclude_devices].join(','))
32       should contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(p[:physical_device_mappings].join(','))
33     end
34
35     it 'installs neutron sriov-nic agent package' do
36       should contain_package('neutron-sriov-nic-agent').with(
37         :name   => platform_params[:sriov_nic_agent_package],
38         :ensure => p[:package_ensure]
39       )
40       should contain_package('neutron-sriov-nic-agent').with_before(/Neutron_plugin_ml2\[.+\]/)
41     end
42
43     it 'configures neutron ovs agent service' do
44       should contain_service('neutron-sriov-nic-agent-service').with(
45         :name    => platform_params[:sriov_nic_agent_service],
46         :enable  => true,
47         :ensure  => 'running',
48         :require => 'Class[Neutron]'
49       )
50     end
51
52     context 'when supplying device mapping' do
53       before :each do
54         params.merge!(:physical_device_mappings => ['physnet1:eth1'],
55                       :exclude_devices          => ['physnet1:eth2'])
56       end
57
58       it 'configures physical device mappings with exclusion' do
59         should contain_neutron_plugin_ml2('sriov_nic/exclude_devices').with_value(['physnet1:eth2'])
60         should contain_neutron_plugin_ml2('sriov_nic/physical_device_mappings').with_value(['physnet1:eth1'])
61       end
62     end
63   end
64
65   context 'on Debian platforms' do
66     let :facts do
67       { :osfamily => 'Debian' }
68     end
69
70     let :platform_params do
71       { :sriov_nic_agent_package => 'neutron-plugin-sriov-agent',
72         :sriov_nic_agent_service => 'neutron-plugin-sriov-agent' }
73     end
74
75     it_configures 'neutron sriov-nic agent with ml2 plugin'
76   end
77
78   context 'on RedHat platforms' do
79     let :facts do
80       { :osfamily => 'RedHat' }
81     end
82
83     let :platform_params do
84       { :sriov_nic_agent_package => 'openstack-neutron-sriov-nic-agent',
85         :sriov_nic_agent_service => 'neutron-sriov-nic-agent' }
86     end
87
88     it_configures 'neutron sriov-nic agent with ml2 plugin'
89   end
90 end