| 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 |
is_expected.to contain_service('nova-compute').with({ |
| 15 |
:name => platform_params[:nova_compute_service], |
| 16 |
:ensure => 'running', |
| 17 |
:hasstatus => true, |
| 18 |
:enable => true, |
| 19 |
:tag => 'nova-service' |
| 20 |
}) |
| 21 |
is_expected.to contain_package('nova-compute').with({ |
| 22 |
:name => platform_params[:nova_compute_package], |
| 23 |
:tag => ['openstack', 'nova-package'] |
| 24 |
}) |
| 25 |
end |
| 26 |
|
| 27 |
it 'does not configure vncproxy base url in nova.conf' do |
| 28 |
is_expected.to contain_nova_config('vnc/enabled').with_value(true) |
| 29 |
is_expected.to contain_nova_config('vnc/server_proxyclient_address').with_value('<SERVICE DEFAULT>') |
| 30 |
is_expected.to contain_nova_config('vnc/novncproxy_base_url').with_value('<SERVICE DEFAULT>') |
| 31 |
end |
| 32 |
|
| 33 |
it 'should have spice disabled' do |
| 34 |
is_expected.to contain_nova_config('spice/enabled').with_value(false) |
| 35 |
end |
| 36 |
|
| 37 |
it { is_expected.to contain_nova_config('DEFAULT/use_cow_images').with_value('<SERVICE DEFAULT>') } |
| 38 |
it { is_expected.to contain_nova_config('DEFAULT/mkisofs_cmd').with_value('<SERVICE DEFAULT>') } |
| 39 |
it { is_expected.to contain_nova_config('DEFAULT/force_raw_images').with_value('<SERVICE DEFAULT>') } |
| 40 |
it { is_expected.to contain_nova_config('DEFAULT/virt_mkfs').with_value('<SERVICE DEFAULT>') } |
| 41 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_host_cpus').with_value('<SERVICE DEFAULT>') } |
| 42 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_host_memory_mb').with_value('<SERVICE DEFAULT>') } |
| 43 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_host_disk_mb').with_value('<SERVICE DEFAULT>') } |
| 44 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_huge_pages').with_value('<SERVICE DEFAULT>') } |
| 45 |
it { is_expected.to contain_nova_config('DEFAULT/heal_instance_info_cache_interval').with_value('<SERVICE DEFAULT>') } |
| 46 |
it { is_expected.to contain_nova_config('DEFAULT/update_resources_interval').with_value('<SERVICE DEFAULT>') } |
| 47 |
it { is_expected.to contain_nova_config('DEFAULT/reboot_timeout').with_value('<SERVICE DEFAULT>') } |
| 48 |
it { is_expected.to contain_nova_config('DEFAULT/instance_build_timeout').with_value('<SERVICE DEFAULT>') } |
| 49 |
it { is_expected.to contain_nova_config('DEFAULT/rescue_timeout').with_value('<SERVICE DEFAULT>') } |
| 50 |
it { is_expected.to contain_nova_config('DEFAULT/resize_confirm_window').with_value('<SERVICE DEFAULT>') } |
| 51 |
it { is_expected.to contain_nova_config('DEFAULT/shutdown_timeout').with_value('<SERVICE DEFAULT>') } |
| 52 |
it { is_expected.to contain_nova_config('DEFAULT/resume_guests_state_on_host_boot').with_value('<SERVICE DEFAULT>') } |
| 53 |
it { is_expected.to contain_nova_config('DEFAULT/max_concurrent_builds').with_value('<SERVICE DEFAULT>') } |
| 54 |
it { is_expected.to contain_nova_config('DEFAULT/max_concurrent_live_migrations').with_value('<SERVICE DEFAULT>') } |
| 55 |
it { is_expected.to contain_nova_config('DEFAULT/sync_power_state_pool_size').with_value('<SERVICE DEFAULT>') } |
| 56 |
it { is_expected.to contain_nova_config('DEFAULT/sync_power_state_interval').with_value('<SERVICE DEFAULT>') } |
| 57 |
it { is_expected.to contain_nova_config('compute/consecutive_build_service_disable_threshold').with_value('<SERVICE DEFAULT>') } |
| 58 |
it { is_expected.to contain_nova_config('compute/live_migration_wait_for_vif_plug').with_value('<SERVICE DEFAULT>') } |
| 59 |
it { is_expected.to contain_nova_config('compute/max_disk_devices_to_attach').with_value('<SERVICE DEFAULT>') } |
| 60 |
it { is_expected.to contain_nova_config('DEFAULT/default_access_ip_network_name').with_value('<SERVICE DEFAULT>') } |
| 61 |
it { is_expected.to contain_nova_config('DEFAULT/running_deleted_instance_action').with_value('<SERVICE DEFAULT>') } |
| 62 |
it { is_expected.to contain_nova_config('DEFAULT/running_deleted_instance_poll_interval').with_value('<SERVICE DEFAULT>') } |
| 63 |
it { is_expected.to contain_nova_config('DEFAULT/running_deleted_instance_timeout').with_value('<SERVICE DEFAULT>') } |
| 64 |
it { is_expected.to contain_nova_config('DEFAULT/compute_monitors').with_value('<SERVICE DEFAULT>') } |
| 65 |
it { is_expected.to contain_nova_config('DEFAULT/default_ephemeral_format').with_value('<SERVICE DEFAULT>') } |
| 66 |
it { is_expected.to contain_nova_config('compute/image_type_exclude_list').with_value('<SERVICE DEFAULT>') } |
| 67 |
it { is_expected.to contain_nova_config('DEFAULT/block_device_allocate_retries').with_value('<SERVICE DEFAULT>') } |
| 68 |
it { is_expected.to contain_nova_config('DEFAULT/block_device_allocate_retries_interval').with_value('<SERVICE DEFAULT>') } |
| 69 |
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit').with_value('<SERVICE DEFAULT>') } |
| 70 |
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit_period').with_value('<SERVICE DEFAULT>') } |
| 71 |
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value('<SERVICE DEFAULT>') } |
| 72 |
it { is_expected.to contain_nova_config('DEFAULT/config_drive_format').with_value('<SERVICE DEFAULT>') } |
| 73 |
|
| 74 |
it { is_expected.to_not contain_package('bridge-utils').with( |
| 75 |
:ensure => 'present', |
| 76 |
) } |
| 77 |
|
| 78 |
it { is_expected.to contain_class('nova::policy') } |
| 79 |
it { is_expected.to contain_class('nova::availability_zone') } |
| 80 |
end |
| 81 |
|
| 82 |
context 'with overridden parameters' do |
| 83 |
let :params do |
| 84 |
{ :enabled => false, |
| 85 |
:ensure_package => '2012.1-2', |
| 86 |
:vncproxy_host => '127.0.0.1', |
| 87 |
:vncproxy_port => 16080, |
| 88 |
:use_cow_images => false, |
| 89 |
:mkisofs_cmd => 'mkisofs', |
| 90 |
:force_raw_images => false, |
| 91 |
:virt_mkfs => 'windows=mkfs.ntfs --force --fast %(target)s', |
| 92 |
:reserved_host_cpus => 2, |
| 93 |
:reserved_host_memory => 0, |
| 94 |
:reserved_host_disk => 20, |
| 95 |
:heal_instance_info_cache_interval => '120', |
| 96 |
:config_drive_format => 'vfat', |
| 97 |
:update_resources_interval => '300', |
| 98 |
:reboot_timeout => '180', |
| 99 |
:instance_build_timeout => '300', |
| 100 |
:rescue_timeout => '120', |
| 101 |
:resize_confirm_window => '3', |
| 102 |
:shutdown_timeout => '100', |
| 103 |
:resume_guests_state_on_host_boot => true, |
| 104 |
:max_concurrent_builds => 15, |
| 105 |
:max_concurrent_live_migrations => '4', |
| 106 |
:sync_power_state_pool_size => '10', |
| 107 |
:sync_power_state_interval => '0', |
| 108 |
:consecutive_build_service_disable_threshold => '9', |
| 109 |
:live_migration_wait_for_vif_plug => true, |
| 110 |
:max_disk_devices_to_attach => 20, |
| 111 |
:default_access_ip_network_name => 'public', |
| 112 |
:running_deleted_instance_action => 'shutdown', |
| 113 |
:running_deleted_instance_poll_interval => '900', |
| 114 |
:running_deleted_instance_timeout => '200', |
| 115 |
:compute_monitors => ['cpu.virt_driver','fake'], |
| 116 |
:default_ephemeral_format => 'ext4', |
| 117 |
:image_type_exclude_list => ['raw','ami'], |
| 118 |
:block_device_allocate_retries => 60, |
| 119 |
:block_device_allocate_retries_interval => 3, |
| 120 |
} |
| 121 |
end |
| 122 |
|
| 123 |
it 'installs nova-compute package and service' do |
| 124 |
is_expected.to contain_service('nova-compute').with({ |
| 125 |
:name => platform_params[:nova_compute_service], |
| 126 |
:ensure => 'stopped', |
| 127 |
:hasstatus => true, |
| 128 |
:enable => false, |
| 129 |
:tag => 'nova-service' |
| 130 |
}) |
| 131 |
is_expected.to contain_package('nova-compute').with({ |
| 132 |
:name => platform_params[:nova_compute_package], |
| 133 |
:ensure => '2012.1-2', |
| 134 |
:tag => ['openstack', 'nova-package'] |
| 135 |
}) |
| 136 |
end |
| 137 |
|
| 138 |
it 'configures vnc in nova.conf' do |
| 139 |
is_expected.to contain_nova_config('vnc/enabled').with_value(true) |
| 140 |
is_expected.to contain_nova_config('vnc/server_proxyclient_address').with_value('<SERVICE DEFAULT>') |
| 141 |
is_expected.to contain_nova_config('vnc/novncproxy_base_url').with_value( |
| 142 |
'http://127.0.0.1:16080/vnc_auto.html' |
| 143 |
) |
| 144 |
end |
| 145 |
|
| 146 |
it 'should have spice disabled' do |
| 147 |
is_expected.to contain_nova_config('spice/enabled').with_value(false) |
| 148 |
end |
| 149 |
|
| 150 |
it { is_expected.to contain_nova_config('DEFAULT/use_cow_images').with_value(false) } |
| 151 |
it { is_expected.to contain_nova_config('DEFAULT/mkisofs_cmd').with_value('mkisofs') } |
| 152 |
it { is_expected.to contain_nova_config('DEFAULT/force_raw_images').with_value(false) } |
| 153 |
it { is_expected.to contain_nova_config('DEFAULT/virt_mkfs').with_value('windows=mkfs.ntfs --force --fast %(target)s') } |
| 154 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_host_cpus').with_value(2) } |
| 155 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_host_memory_mb').with_value(0) } |
| 156 |
it { is_expected.to contain_nova_config('DEFAULT/reserved_host_disk_mb').with_value(20) } |
| 157 |
it { is_expected.to contain_nova_config('DEFAULT/heal_instance_info_cache_interval').with_value('120') } |
| 158 |
it { is_expected.to contain_nova_config('DEFAULT/update_resources_interval').with_value('300') } |
| 159 |
it { is_expected.to contain_nova_config('DEFAULT/reboot_timeout').with_value('180') } |
| 160 |
it { is_expected.to contain_nova_config('DEFAULT/instance_build_timeout').with_value('300') } |
| 161 |
it { is_expected.to contain_nova_config('DEFAULT/rescue_timeout').with_value('120') } |
| 162 |
it { is_expected.to contain_nova_config('DEFAULT/resize_confirm_window').with_value('3') } |
| 163 |
it { is_expected.to contain_nova_config('DEFAULT/shutdown_timeout').with_value('100') } |
| 164 |
it { is_expected.to contain_nova_config('DEFAULT/resume_guests_state_on_host_boot').with_value(true) } |
| 165 |
it { is_expected.to contain_nova_config('DEFAULT/max_concurrent_builds').with_value('15') } |
| 166 |
it { is_expected.to contain_nova_config('DEFAULT/max_concurrent_live_migrations').with_value('4') } |
| 167 |
it { is_expected.to contain_nova_config('DEFAULT/sync_power_state_pool_size').with_value('10') } |
| 168 |
it { is_expected.to contain_nova_config('DEFAULT/sync_power_state_interval').with_value('0') } |
| 169 |
it { is_expected.to contain_nova_config('compute/consecutive_build_service_disable_threshold').with_value('9') } |
| 170 |
it { is_expected.to contain_nova_config('compute/live_migration_wait_for_vif_plug').with_value(true) } |
| 171 |
it { is_expected.to contain_nova_config('compute/max_disk_devices_to_attach').with_value(20) } |
| 172 |
it { is_expected.to contain_nova_config('DEFAULT/default_access_ip_network_name').with_value('public') } |
| 173 |
it { is_expected.to contain_nova_config('DEFAULT/running_deleted_instance_action').with_value('shutdown') } |
| 174 |
it { is_expected.to contain_nova_config('DEFAULT/running_deleted_instance_poll_interval').with_value('900') } |
| 175 |
it { is_expected.to contain_nova_config('DEFAULT/running_deleted_instance_timeout').with_value('200') } |
| 176 |
it { is_expected.to contain_nova_config('DEFAULT/compute_monitors').with_value('cpu.virt_driver,fake') } |
| 177 |
it { is_expected.to contain_nova_config('DEFAULT/default_ephemeral_format').with_value('ext4') } |
| 178 |
it { is_expected.to contain_nova_config('compute/image_type_exclude_list').with_value('raw,ami') } |
| 179 |
it { is_expected.to contain_nova_config('DEFAULT/block_device_allocate_retries').with_value(60) } |
| 180 |
it { is_expected.to contain_nova_config('DEFAULT/block_device_allocate_retries_interval').with_value(3) } |
| 181 |
it { is_expected.to contain_nova_config('DEFAULT/config_drive_format').with_value('vfat') } |
| 182 |
end |
| 183 |
|
| 184 |
context 'with image_type_exclude_list set to empty list' do |
| 185 |
let :params do |
| 186 |
{ |
| 187 |
:image_type_exclude_list => [] |
| 188 |
} |
| 189 |
end |
| 190 |
it { is_expected.to contain_nova_config('compute/image_type_exclude_list').with_value('<SERVICE DEFAULT>') } |
| 191 |
end |
| 192 |
|
| 193 |
context 'with reserved_huge_pages string' do |
| 194 |
let :params do |
| 195 |
{ |
| 196 |
:reserved_huge_pages => "foo" |
| 197 |
} |
| 198 |
end |
| 199 |
it 'configures nova reserved_huge_pages entries' do |
| 200 |
is_expected.to contain_nova_config('DEFAULT/reserved_huge_pages').with( |
| 201 |
'value' => 'foo' |
| 202 |
) |
| 203 |
end |
| 204 |
end |
| 205 |
|
| 206 |
context 'with reserved_huge_pages array' do |
| 207 |
let :params do |
| 208 |
{ |
| 209 |
:reserved_huge_pages => ["foo", "bar"] |
| 210 |
} |
| 211 |
end |
| 212 |
it 'configures nova reserved_huge_pages entries' do |
| 213 |
is_expected.to contain_nova_config('DEFAULT/reserved_huge_pages').with( |
| 214 |
'value' => ['foo','bar'] |
| 215 |
) |
| 216 |
end |
| 217 |
end |
| 218 |
|
| 219 |
context 'when cpu_shared_set and cpu_dedicated_set both are set' do |
| 220 |
let :params do |
| 221 |
{ :cpu_shared_set => ['4-12','^8','15'], |
| 222 |
:cpu_dedicated_set => ['2-10','^5','14'], } |
| 223 |
end |
| 224 |
|
| 225 |
it { is_expected.to contain_nova_config('compute/cpu_shared_set').with_value('4-12,^8,15') } |
| 226 |
it { is_expected.to contain_nova_config('compute/cpu_dedicated_set').with_value('2-10,^5,14') } |
| 227 |
end |
| 228 |
|
| 229 |
context 'when cpu_dedicated_set is defined but cpu_shared_set is not' do |
| 230 |
let :params do |
| 231 |
{ :cpu_dedicated_set => ['4-12','^8','15'] } |
| 232 |
end |
| 233 |
|
| 234 |
it { is_expected.to contain_nova_config('compute/cpu_dedicated_set').with_value('4-12,^8,15') } |
| 235 |
it { is_expected.to contain_nova_config('compute/cpu_shared_set').with_value('<SERVICE DEFAULT>') } |
| 236 |
end |
| 237 |
|
| 238 |
context 'when cpu_shared_set is defined, but cpu_dedicated_set is not' do |
| 239 |
let :params do |
| 240 |
{ :cpu_shared_set => ['4-12', '^8', '15'] } |
| 241 |
end |
| 242 |
|
| 243 |
it { is_expected.to contain_nova_config('compute/cpu_shared_set').with_value('4-12,^8,15') } |
| 244 |
it { is_expected.to contain_nova_config('compute/cpu_dedicated_set').with_value('<SERVICE DEFAULT>') } |
| 245 |
end |
| 246 |
|
| 247 |
context 'when neutron_physnets_numa_nodes_mapping and neutron_tunnel_numa_nodes are empty' do |
| 248 |
let :params do |
| 249 |
{ :neutron_physnets_numa_nodes_mapping => {}, |
| 250 |
:neutron_tunnel_numa_nodes => [], } |
| 251 |
end |
| 252 |
|
| 253 |
it { is_expected.to contain_nova_config('neutron/physnets').with_ensure('absent') } |
| 254 |
it { is_expected.to contain_nova_config('neutron_tunnel/numa_nodes').with_ensure('absent') } |
| 255 |
end |
| 256 |
|
| 257 |
context 'when neutron_physnets_numa_nodes_mapping and neutron_tunnel_numa_nodes are set to valid values' do |
| 258 |
let :params do |
| 259 |
{ :neutron_physnets_numa_nodes_mapping => { 'foo' => [0, 1], 'bar' => [0] }, |
| 260 |
:neutron_tunnel_numa_nodes => 1, } |
| 261 |
end |
| 262 |
|
| 263 |
it { is_expected.to contain_nova_config('neutron/physnets').with_value('foo,bar') } |
| 264 |
it { is_expected.to contain_nova_config('neutron_physnet_foo/numa_nodes').with_value('0,1') } |
| 265 |
it { is_expected.to contain_nova_config('neutron_physnet_bar/numa_nodes').with_value('0') } |
| 266 |
it { is_expected.to contain_nova_config('neutron_tunnel/numa_nodes').with_value('1') } |
| 267 |
end |
| 268 |
|
| 269 |
context 'with vnc_enabled set to false and spice_enabled set to true' do |
| 270 |
let :params do |
| 271 |
{ :vnc_enabled => false, |
| 272 |
:spice_enabled => true, } |
| 273 |
end |
| 274 |
|
| 275 |
it 'disables vnc in nova.conf' do |
| 276 |
is_expected.to contain_nova_config('vnc/enabled').with_value(false) |
| 277 |
is_expected.to contain_nova_config('vnc/server_proxyclient_address').with_ensure('absent') |
| 278 |
is_expected.to_not contain_nova_config('vnc/novncproxy_base_url') |
| 279 |
end |
| 280 |
|
| 281 |
it 'enables spice' do |
| 282 |
is_expected.to contain_nova_config('spice/enabled').with_value(true) |
| 283 |
end |
| 284 |
end |
| 285 |
|
| 286 |
context 'with vnc_enabled and spice_enabled set to true' do |
| 287 |
let :params do |
| 288 |
{ :vnc_enabled => true, |
| 289 |
:spice_enabled => true, } |
| 290 |
end |
| 291 |
|
| 292 |
it { should raise_error(Puppet::Error, /vnc_enabled and spice_enabled is mutually exclusive/) } |
| 293 |
end |
| 294 |
|
| 295 |
context 'while not managing service state' do |
| 296 |
let :params do |
| 297 |
{ |
| 298 |
:manage_service => false, |
| 299 |
} |
| 300 |
end |
| 301 |
|
| 302 |
it { is_expected.to_not contain_service('nova-compute') } |
| 303 |
end |
| 304 |
|
| 305 |
context 'with instance_usage_audit parameter and period' do |
| 306 |
let :params do |
| 307 |
{ :instance_usage_audit => true, |
| 308 |
:instance_usage_audit_period => 'year', } |
| 309 |
end |
| 310 |
|
| 311 |
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit').with_value(true) } |
| 312 |
it { is_expected.to contain_nova_config('DEFAULT/instance_usage_audit_period').with_value('year') } |
| 313 |
end |
| 314 |
|
| 315 |
context 'with flat_injected parameter set to true' do |
| 316 |
let :params do |
| 317 |
{ :flat_injected => true } |
| 318 |
end |
| 319 |
|
| 320 |
it { is_expected.to contain_nova_config('DEFAULT/flat_injected').with_value(true) } |
| 321 |
end |
| 322 |
|
| 323 |
context 'with force_config_drive parameter set to true' do |
| 324 |
let :params do |
| 325 |
{ :force_config_drive => true } |
| 326 |
end |
| 327 |
|
| 328 |
it { is_expected.to contain_nova_config('DEFAULT/force_config_drive').with_value(true) } |
| 329 |
end |
| 330 |
end |
| 331 |
|
| 332 |
on_supported_os({ |
| 333 |
:supported_os => OSDefaults.get_supported_os |
| 334 |
}).each do |os,facts| |
| 335 |
context "on #{os}" do |
| 336 |
let (:facts) do |
| 337 |
facts.merge!(OSDefaults.get_facts()) |
| 338 |
end |
| 339 |
case facts[:os]['family'] |
| 340 |
when 'Debian' |
| 341 |
let (:platform_params) do |
| 342 |
{ |
| 343 |
:nova_compute_package => 'nova-compute', |
| 344 |
:nova_compute_service => 'nova-compute', |
| 345 |
} |
| 346 |
end |
| 347 |
when 'RedHat' |
| 348 |
let (:platform_params) do |
| 349 |
{ |
| 350 |
:nova_compute_package => 'openstack-nova-compute', |
| 351 |
:nova_compute_service => 'openstack-nova-compute', |
| 352 |
} |
| 353 |
end |
| 354 |
end |
| 355 |
it_behaves_like 'nova-compute' |
| 356 |
end |
| 357 |
end |
| 358 |
|
| 359 |
end |