try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / spec / classes / neutron_agents_n1kv_vem_spec.rb
1 require 'spec_helper'
2
3 describe 'neutron::agents::n1kv_vem' do
4
5   let :facts do
6     { :osfamily => 'RedHat' }
7   end
8
9   it 'should have a n1kv-vem config file' do
10     should contain_file('/etc/n1kv/n1kv.conf').with(
11       :ensure  => 'present',
12       :owner   => 'root',
13       :group   => 'root',
14       :mode    => '0664'
15     )
16   end
17
18   it 'install n1kv-vem' do
19     should contain_package('libnl').with_before('Package[nexus1000v]')
20     should contain_service('openvswitch').with_notify('Package[nexus1000v]')
21     should contain_package('nexus1000v').with_notify('Service[nexus1000v]')
22     should contain_service('nexus1000v').with_ensure('running')
23   end
24
25   context 'with local file vem rpm' do
26     let :params do
27       {
28         :n1kv_source => 'vem.rpm'
29       }
30     end
31
32     it 'verify dependency' do
33       should contain_package('nexus1000v').with_source('/var/n1kv/vem.rpm')
34       should contain_file('/var/n1kv/vem.rpm').that_requires('File[/var/n1kv]')
35       should contain_file('/var/n1kv/vem.rpm').with(
36         :owner   => 'root',
37         :group   => 'root',
38         :mode    => '0664'
39       )
40     end
41   end
42
43   context 'remote vem rpm' do
44     let :params do
45     {
46       :n1kv_source => 'http://www.cisco.com/repo'
47     }
48     end
49
50     it 'verify dependency' do
51       should contain_package('nexus1000v').without_source
52       should contain_yumrepo('cisco-vem-repo').with(
53         :baseurl  => 'http://www.cisco.com/repo',
54         :enabled => 1
55       )
56     end
57   end
58
59   it 'execute reread config upon config change' do
60     should contain_exec('vemcmd reread config') \
61       .that_subscribes_to('File[/etc/n1kv/n1kv.conf]')
62   end
63
64   context 'verify n1kv.conf default' do
65     let :params do
66     {
67       :n1kv_vsm_ip        => '9.0.0.1',
68       :n1kv_vsm_domain_id => 900,
69       :host_mgmt_intf     => 'eth9',
70       :portdb             => 'ovs',
71       :fastpath_flood     => 'disable'
72     }
73     end
74     it do
75       should contain_file('/etc/n1kv/n1kv.conf') \
76         .with_content(/^l3control-ipaddr 9.0.0.1/)
77       should contain_file('/etc/n1kv/n1kv.conf') \
78         .with_content(/^switch-domain 900/)
79       should contain_file('/etc/n1kv/n1kv.conf') \
80         .with_content(/^host-mgmt-intf eth9/)
81       should contain_file('/etc/n1kv/n1kv.conf') \
82         .with_content(/^portdb ovs/)
83       should contain_file('/etc/n1kv/n1kv.conf') \
84         .without_content(/^phys/)
85       should contain_file('/etc/n1kv/n1kv.conf') \
86         .without_content(/^virt/)
87       should contain_file('/etc/n1kv/n1kv.conf') \
88         .with_content(/^node-type compute/)
89       should contain_file('/etc/n1kv/n1kv.conf') \
90         .with_content(/^fastpath-flood disable/)
91     end
92   end
93
94   context 'verify node_type' do
95     let :params do
96     {
97       :node_type        => 'network',
98     }
99     end
100     it do
101       should contain_file('/etc/n1kv/n1kv.conf') \
102         .with_content(/^node-type network/)
103       should contain_file('/etc/n1kv/n1kv.conf') \
104         .without_content(/^node-type compute/)
105     end
106   end
107
108   context 'verify portdb' do
109     let :params do
110     {
111       :portdb             => 'vem',
112     }
113     end
114     it do
115       should contain_file('/etc/n1kv/n1kv.conf') \
116         .with_content(/^portdb vem/)
117       should contain_file('/etc/n1kv/n1kv.conf') \
118         .without_content(/^portdb ovs/)
119     end
120   end
121
122   context 'verify fastpath_flood' do
123     let :params do
124     {
125       :fastpath_flood     => 'enable',
126     }
127     end
128     it do
129       should contain_file('/etc/n1kv/n1kv.conf') \
130         .with_content(/^fastpath-flood enable/)
131       should contain_file('/etc/n1kv/n1kv.conf') \
132         .without_content(/^fastpath-flood disable/)
133     end
134   end
135
136   context 'verify n1kv.conf with uplinks' do
137     let :params do
138     {
139       :uplink_profile => { 'eth1' => 'prof1',
140                            'eth2' => 'prof2'
141                          }
142     }
143     end
144     it do
145       should contain_file('/etc/n1kv/n1kv.conf') \
146         .with_content(/^phys eth1 profile prof1/)
147       should contain_file('/etc/n1kv/n1kv.conf') \
148         .with_content(/^phys eth2 profile prof2/)
149     end
150
151   end
152
153   context 'verify n1kv.conf with vtep info' do
154     let :params do
155     {
156       :vtep_config => { 'vtep1' => { 'profile' => 'profint',
157                                      'ipmode'  => 'dhcp'
158                                    },
159                         'vtep2' => { 'profile'   => 'profint',
160                                      'ipmode'    => 'static',
161                                      'ipaddress' => '192.168.1.1',
162                                      'netmask'   => '255.255.255.0'
163                                    }
164                       }
165     }
166     end
167     it do
168       should contain_file('/etc/n1kv/n1kv.conf') \
169         .with_content(/^virt vtep1 profile profint mode dhcp/)
170       should contain_file('/etc/n1kv/n1kv.conf') \
171         .with_content(/^virt vtep2 profile profint mode static/)
172     end
173
174   end
175
176   context 'with manage_service as false' do
177     let :params do
178     {
179       :manage_service => false
180     }
181     end
182     it 'should not start/stop service' do
183       should contain_service('nexus1000v').without_ensure
184     end
185   end
186
187   context 'with manage_service true and enable_service false' do
188     let :params do
189     {
190       :manage_service => true,
191       :enable         => false
192     }
193     end
194     it 'should stop service' do
195       should contain_service('nexus1000v').with_ensure('stopped')
196     end
197   end
198
199   context 'verify sysctl setting with vteps_in_same_subnet true' do
200     let :params do
201     {
202       :vteps_in_same_subnet => true
203     }
204     end
205     it do
206       should contain_sysctl__value('net.ipv4.conf.default.rp_filter').with_value('2')
207       should contain_sysctl__value('net.ipv4.conf.all.rp_filter').with_value('2')
208       should contain_sysctl__value('net.ipv4.conf.default.arp_ignore').with_value('1')
209       should contain_sysctl__value('net.ipv4.conf.all.arp_ignore').with_value('1')
210       should contain_sysctl__value('net.ipv4.conf.all.arp_announce').with_value('2')
211       should contain_sysctl__value('net.ipv4.conf.default.arp_announce').with_value('2')
212     end
213   end
214
215 end