e1ecd08be2c13cbafc6a8c0ad56a5a04adedcf7b
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / spec / classes / nova_compute_spec.rb
1 require 'spec_helper'
2
3 describe 'nova::compute' do
4
5   let :pre_condition do
6     'include nova'
7   end
8
9   shared_examples 'nova-compute' do
10
11     context 'with default parameters' do
12
13       it 'installs nova-compute package and service' do
14         should contain_service('nova-compute').with({
15           :name      => platform_params[:nova_compute_service],
16           :ensure    => 'stopped',
17           :hasstatus => true,
18           :enable    => false
19         })
20         should contain_package('nova-compute').with({
21           :name => platform_params[:nova_compute_package],
22           :tag  => ['openstack', 'nova']
23         })
24       end
25
26       it { should contain_nova_config('DEFAULT/network_device_mtu').with(:ensure => 'absent') }
27       it { should_not contain_nova_config('DEFAULT/novncproxy_base_url') }
28
29       it { should_not contain_package('bridge-utils').with(
30         :ensure => 'present',
31         :before => 'Nova::Generic_service[compute]'
32       ) }
33
34       it { should contain_package('pm-utils').with(
35         :ensure => 'present'
36       ) }
37
38       it { should contain_nova_config('DEFAULT/force_raw_images').with(:value => true) }
39
40       it 'configures availability zones' do
41         should contain_nova_config('DEFAULT/default_availability_zone').with_value('nova')
42         should contain_nova_config('DEFAULT/internal_service_availability_zone').with_value('internal')
43       end
44
45     end
46
47     context 'with overridden parameters' do
48       let :params do
49         { :enabled                            => true,
50           :ensure_package                     => '2012.1-2',
51           :vncproxy_host                      => '127.0.0.1',
52           :network_device_mtu                 => 9999,
53           :force_raw_images                   => false,
54           :reserved_host_memory               => '0',
55           :compute_manager                    => 'ironic.nova.compute.manager.ClusteredComputeManager',
56           :pci_passthrough                    => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"physical_network\":\"physnet1\"}]",
57           :default_availability_zone          => 'az1',
58           :default_schedule_zone              => 'az2',
59           :internal_service_availability_zone => 'az_int1',
60         }
61       end
62
63       it 'installs nova-compute package and service' do
64         should contain_service('nova-compute').with({
65           :name      => platform_params[:nova_compute_service],
66           :ensure    => 'running',
67           :hasstatus => true,
68           :enable    => true
69         })
70         should contain_package('nova-compute').with({
71           :name   => platform_params[:nova_compute_package],
72           :ensure => '2012.1-2',
73           :tag    => ['openstack', 'nova']
74         })
75       end
76
77       it 'configures ironic in nova.conf' do
78         should contain_nova_config('DEFAULT/reserved_host_memory_mb').with_value('0')
79         should contain_nova_config('DEFAULT/compute_manager').with_value('ironic.nova.compute.manager.ClusteredComputeManager')
80       end
81
82       it 'configures network_device_mtu' do
83         should contain_nova_config('DEFAULT/network_device_mtu').with_value('9999')
84       end
85
86       it 'configures vnc in nova.conf' do
87         should contain_nova_config('DEFAULT/vnc_enabled').with_value(true)
88         should contain_nova_config('DEFAULT/vncserver_proxyclient_address').with_value('127.0.0.1')
89         should contain_nova_config('DEFAULT/novncproxy_base_url').with_value(
90           'http://127.0.0.1:6080/vnc_auto.html'
91         )
92       end
93
94       it 'configures availability zones' do
95         should contain_nova_config('DEFAULT/default_availability_zone').with_value('az1')
96         should contain_nova_config('DEFAULT/default_schedule_zone').with_value('az2')
97         should contain_nova_config('DEFAULT/internal_service_availability_zone').with_value('az_int1')
98       end
99
100       it { should contain_nova_config('DEFAULT/force_raw_images').with(:value => false) }
101
102       it 'configures nova pci_passthrough_whitelist entries' do
103         should contain_nova_config('DEFAULT/pci_passthrough_whitelist').with(
104           'value' => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"physical_network\":\"physnet1\"}]"
105         )
106       end
107     end
108
109     context 'with neutron_enabled set to false' do
110       let :params do
111         { :neutron_enabled => false }
112       end
113
114       it 'installs bridge-utils package for nova-network' do
115         should contain_package('bridge-utils').with(
116           :ensure => 'present',
117           :before => 'Nova::Generic_service[compute]'
118         )
119       end
120     end
121
122     context 'with vnc_enabled set to false' do
123       let :params do
124         { :vnc_enabled => false }
125       end
126
127       it 'disables vnc in nova.conf' do
128         should contain_nova_config('DEFAULT/vnc_enabled').with_value(false)
129         should contain_nova_config('DEFAULT/vncserver_proxyclient_address').with_value('127.0.0.1')
130         should_not contain_nova_config('DEFAULT/novncproxy_base_url')
131       end
132     end
133
134     context 'with force_config_drive parameter set to true' do
135       let :params do
136         { :force_config_drive => true }
137       end
138
139       it { should contain_nova_config('DEFAULT/force_config_drive').with_value(true) }
140     end
141
142     context 'while not managing service state' do
143       let :params do
144         { :enabled           => false,
145           :manage_service    => false,
146         }
147       end
148
149       it { should contain_service('nova-compute').without_ensure }
150     end
151
152     context 'with instance_usage_audit parameter set to false' do
153       let :params do
154         { :instance_usage_audit => false, }
155       end
156
157       it { should contain_nova_config('DEFAULT/instance_usage_audit').with_ensure('absent') }
158       it { should contain_nova_config('DEFAULT/instance_usage_audit_period').with_ensure('absent') }
159     end
160
161     context 'with instance_usage_audit parameter and wrong period' do
162       let :params do
163         { :instance_usage_audit        => true,
164           :instance_usage_audit_period => 'fake', }
165       end
166
167       it { should contain_nova_config('DEFAULT/instance_usage_audit').with_ensure('absent') }
168       it { should contain_nova_config('DEFAULT/instance_usage_audit_period').with_ensure('absent') }
169     end
170
171     context 'with instance_usage_audit parameter and period' do
172       let :params do
173         { :instance_usage_audit        => true,
174           :instance_usage_audit_period => 'year', }
175       end
176
177       it { should contain_nova_config('DEFAULT/instance_usage_audit').with_value(true) }
178       it { should contain_nova_config('DEFAULT/instance_usage_audit_period').with_value('year') }
179     end
180     context 'with vnc_keymap set to fr' do
181       let :params do
182         { :vnc_keymap => 'fr', }
183       end
184
185       it { should contain_nova_config('DEFAULT/vnc_keymap').with_value('fr') }
186     end
187   end
188
189
190   context 'on Debian platforms' do
191     let :facts do
192       { :osfamily => 'Debian' }
193     end
194
195     let :platform_params do
196       { :nova_compute_package => 'nova-compute',
197         :nova_compute_service => 'nova-compute' }
198     end
199
200     it_behaves_like 'nova-compute'
201   end
202
203   context 'on RedHat platforms' do
204     let :facts do
205       { :osfamily => 'RedHat' }
206     end
207
208     let :platform_params do
209       { :nova_compute_package => 'openstack-nova-compute',
210         :nova_compute_service => 'openstack-nova-compute' }
211     end
212
213     it_behaves_like 'nova-compute'
214   end
215 end