| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'nova' do |
| 4 |
|
| 5 |
shared_examples 'nova' do |
| 6 |
|
| 7 |
context 'with default parameters' do |
| 8 |
|
| 9 |
it { is_expected.to contain_class('nova::deps') } |
| 10 |
it { is_expected.to contain_class('nova::workarounds') } |
| 11 |
|
| 12 |
it 'installs packages' do |
| 13 |
is_expected.to contain_package('python-nova').with( |
| 14 |
:ensure => 'present', |
| 15 |
:tag => ['openstack', 'nova-package'] |
| 16 |
) |
| 17 |
is_expected.to contain_package('nova-common').with( |
| 18 |
:name => platform_params[:nova_common_package], |
| 19 |
:ensure => 'present', |
| 20 |
:tag => ['openstack', 'nova-package'] |
| 21 |
) |
| 22 |
end |
| 23 |
|
| 24 |
it 'configures rootwrap' do |
| 25 |
is_expected.to contain_nova_config('DEFAULT/rootwrap_config').with_value('/etc/nova/rootwrap.conf') |
| 26 |
end |
| 27 |
|
| 28 |
it 'configures rabbit' do |
| 29 |
is_expected.to contain_oslo__messaging__default('nova_config').with( |
| 30 |
:executor_thread_pool_size => '<SERVICE DEFAULT>', |
| 31 |
:transport_url => '<SERVICE DEFAULT>', |
| 32 |
:rpc_response_timeout => '<SERVICE DEFAULT>', |
| 33 |
:control_exchange => '<SERVICE DEFAULT>', |
| 34 |
) |
| 35 |
is_expected.to contain_oslo__messaging__rabbit('nova_config').with( |
| 36 |
:rabbit_use_ssl => '<SERVICE DEFAULT>', |
| 37 |
:heartbeat_timeout_threshold => '<SERVICE DEFAULT>', |
| 38 |
:heartbeat_rate => '<SERVICE DEFAULT>', |
| 39 |
:rabbit_qos_prefetch_count => '<SERVICE DEFAULT>', |
| 40 |
:kombu_reconnect_delay => '<SERVICE DEFAULT>', |
| 41 |
:kombu_failover_strategy => '<SERVICE DEFAULT>', |
| 42 |
:amqp_durable_queues => '<SERVICE DEFAULT>', |
| 43 |
:amqp_auto_delete => '<SERVICE DEFAULT>', |
| 44 |
:kombu_compression => '<SERVICE DEFAULT>', |
| 45 |
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>', |
| 46 |
:kombu_ssl_certfile => '<SERVICE DEFAULT>', |
| 47 |
:kombu_ssl_keyfile => '<SERVICE DEFAULT>', |
| 48 |
:kombu_ssl_version => '<SERVICE DEFAULT>', |
| 49 |
:rabbit_ha_queues => '<SERVICE DEFAULT>', |
| 50 |
:rabbit_quorum_queue => '<SERVICE DEFAULT>', |
| 51 |
:rabbit_transient_quorum_queue => '<SERVICE DEFAULT>', |
| 52 |
:rabbit_transient_queues_ttl => '<SERVICE DEFAULT>', |
| 53 |
:rabbit_quorum_delivery_limit => '<SERVICE DEFAULT>', |
| 54 |
:rabbit_quorum_max_memory_length => '<SERVICE DEFAULT>', |
| 55 |
:rabbit_quorum_max_memory_bytes => '<SERVICE DEFAULT>', |
| 56 |
:use_queue_manager => '<SERVICE DEFAULT>', |
| 57 |
:rabbit_stream_fanout => '<SERVICE DEFAULT>', |
| 58 |
:enable_cancel_on_failover => '<SERVICE DEFAULT>', |
| 59 |
:rabbit_retry_interval => '<SERVICE DEFAULT>', |
| 60 |
) |
| 61 |
is_expected.to contain_oslo__messaging__notifications('nova_config').with( |
| 62 |
:transport_url => '<SERVICE DEFAULT>', |
| 63 |
:driver => '<SERVICE DEFAULT>', |
| 64 |
:topics => '<SERVICE DEFAULT>', |
| 65 |
:retry => '<SERVICE DEFAULT>', |
| 66 |
) |
| 67 |
end |
| 68 |
|
| 69 |
it 'configures various things' do |
| 70 |
is_expected.to contain_nova_config('DEFAULT/state_path').with_value('/var/lib/nova') |
| 71 |
is_expected.to contain_oslo__concurrency('nova_config').with( |
| 72 |
:lock_path => platform_params[:lock_path] |
| 73 |
) |
| 74 |
is_expected.to contain_nova_config('DEFAULT/service_down_time').with_value('<SERVICE DEFAULT>') |
| 75 |
is_expected.to contain_nova_config('notifications/notification_format').with_value('<SERVICE DEFAULT>') |
| 76 |
is_expected.to contain_nova_config('notifications/notify_on_state_change').with_value('<SERVICE DEFAULT>') |
| 77 |
is_expected.to contain_nova_config('DEFAULT/rootwrap_config').with_value('/etc/nova/rootwrap.conf') |
| 78 |
is_expected.to contain_nova_config('DEFAULT/report_interval').with_value('<SERVICE DEFAULT>') |
| 79 |
is_expected.to contain_nova_config('DEFAULT/periodic_fuzzy_delay').with_value('<SERVICE DEFAULT>') |
| 80 |
is_expected.to contain_nova_config('vif_plug_ovs/ovsdb_connection').with_value('<SERVICE DEFAULT>') |
| 81 |
is_expected.to contain_nova_config('DEFAULT/long_rpc_timeout').with_value('<SERVICE DEFAULT>') |
| 82 |
is_expected.to contain_nova_config('DEFAULT/cpu_allocation_ratio').with_value('<SERVICE DEFAULT>') |
| 83 |
is_expected.to contain_nova_config('DEFAULT/ram_allocation_ratio').with_value('<SERVICE DEFAULT>') |
| 84 |
is_expected.to contain_nova_config('DEFAULT/disk_allocation_ratio').with_value('<SERVICE DEFAULT>') |
| 85 |
is_expected.to contain_nova_config('DEFAULT/initial_cpu_allocation_ratio').with_value('<SERVICE DEFAULT>') |
| 86 |
is_expected.to contain_nova_config('DEFAULT/initial_ram_allocation_ratio').with_value('<SERVICE DEFAULT>') |
| 87 |
is_expected.to contain_nova_config('DEFAULT/initial_disk_allocation_ratio').with_value('<SERVICE DEFAULT>') |
| 88 |
is_expected.to contain_nova_config('DEFAULT/record').with_value('<SERVICE DEFAULT>') |
| 89 |
is_expected.to contain_nova_config('DEFAULT/ssl_only').with_value('<SERVICE DEFAULT>') |
| 90 |
is_expected.to contain_nova_config('DEFAULT/source_is_ipv6').with_value('<SERVICE DEFAULT>') |
| 91 |
is_expected.to contain_nova_config('DEFAULT/cert').with_value('<SERVICE DEFAULT>') |
| 92 |
is_expected.to contain_nova_config('DEFAULT/key').with_value('<SERVICE DEFAULT>') |
| 93 |
is_expected.to contain_nova_config('console/allowed_origins').with_value('<SERVICE DEFAULT>') |
| 94 |
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('<SERVICE DEFAULT>') |
| 95 |
is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('<SERVICE DEFAULT>') |
| 96 |
is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('<SERVICE DEFAULT>') |
| 97 |
is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('<SERVICE DEFAULT>') |
| 98 |
is_expected.to contain_nova_config('DEFAULT/cell_worker_thread_pool_size').with_value('<SERVICE DEFAULT>') |
| 99 |
end |
| 100 |
|
| 101 |
end |
| 102 |
|
| 103 |
context 'with overridden parameters' do |
| 104 |
|
| 105 |
let :params do |
| 106 |
{ |
| 107 |
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 108 |
:rpc_response_timeout => '30', |
| 109 |
:long_rpc_timeout => '1800', |
| 110 |
:control_exchange => 'nova', |
| 111 |
:executor_thread_pool_size => 64, |
| 112 |
:rabbit_use_ssl => true, |
| 113 |
:rabbit_heartbeat_timeout_threshold => '60', |
| 114 |
:rabbit_heartbeat_rate => '10', |
| 115 |
:rabbit_qos_prefetch_count => 0, |
| 116 |
:kombu_reconnect_delay => '5.0', |
| 117 |
:amqp_durable_queues => true, |
| 118 |
:amqp_auto_delete => true, |
| 119 |
:kombu_compression => 'gzip', |
| 120 |
:kombu_ssl_ca_certs => '/etc/ca.cert', |
| 121 |
:kombu_ssl_certfile => '/etc/certfile', |
| 122 |
:kombu_ssl_keyfile => '/etc/key', |
| 123 |
:kombu_ssl_version => 'TLSv1', |
| 124 |
:rabbit_ha_queues => true, |
| 125 |
:rabbit_quorum_queue => true, |
| 126 |
:rabbit_transient_quorum_queue => true, |
| 127 |
:rabbit_transient_queues_ttl => 60, |
| 128 |
:rabbit_quorum_delivery_limit => 3, |
| 129 |
:rabbit_quorum_max_memory_length => 5, |
| 130 |
:rabbit_quorum_max_memory_bytes => 1073741824, |
| 131 |
:rabbit_use_queue_manager => true, |
| 132 |
:rabbit_stream_fanout => true, |
| 133 |
:rabbit_enable_cancel_on_failover => false, |
| 134 |
:rabbit_retry_interval => '1', |
| 135 |
:lock_path => '/var/locky/path', |
| 136 |
:state_path => '/var/lib/nova2', |
| 137 |
:service_down_time => '60', |
| 138 |
:ensure_package => '2012.1.1-15.el6', |
| 139 |
:host => 'test-001.example.org', |
| 140 |
:notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 141 |
:notification_driver => 'ceilometer.compute.nova_notifier', |
| 142 |
:notification_topics => 'openstack', |
| 143 |
:notification_retry => 10, |
| 144 |
:notification_format => 'unversioned', |
| 145 |
:report_interval => '10', |
| 146 |
:periodic_fuzzy_delay => '61', |
| 147 |
:ovsdb_connection => 'tcp:127.0.0.1:6640', |
| 148 |
:upgrade_level_compute => '1.0.0', |
| 149 |
:upgrade_level_conductor => '1.0.0', |
| 150 |
:upgrade_level_scheduler => '1.0.0', |
| 151 |
:purge_config => false, |
| 152 |
:my_ip => '192.0.2.1', |
| 153 |
:record => '/var/lib/nova/novnc.log', |
| 154 |
:ssl_only => true, |
| 155 |
:source_is_ipv6 => false, |
| 156 |
:cert => '/etc/ssl/private/snakeoil.pem', |
| 157 |
:key => '/etc/ssl/certs/snakeoil.pem', |
| 158 |
:console_allowed_origins => 'http://example.com', |
| 159 |
:console_ssl_ciphers => 'kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES', |
| 160 |
:console_ssl_minimum_version => 'tlsv1_2', |
| 161 |
:dhcp_domain => 'foo', |
| 162 |
:instance_name_template => 'instance-%08x', |
| 163 |
:cell_worker_thread_pool_size => 5, |
| 164 |
} |
| 165 |
end |
| 166 |
|
| 167 |
it { is_expected.to contain_class('nova::deps') } |
| 168 |
it { is_expected.to contain_class('nova::workarounds') } |
| 169 |
|
| 170 |
it 'installs packages' do |
| 171 |
is_expected.to contain_package('nova-common').with('ensure' => '2012.1.1-15.el6') |
| 172 |
is_expected.to contain_package('python-nova').with('ensure' => '2012.1.1-15.el6') |
| 173 |
end |
| 174 |
|
| 175 |
it 'passes purge to resource' do |
| 176 |
is_expected.to contain_resources('nova_config').with({ |
| 177 |
:purge => false |
| 178 |
}) |
| 179 |
end |
| 180 |
|
| 181 |
it 'configures rabbit' do |
| 182 |
is_expected.to contain_oslo__messaging__default('nova_config').with( |
| 183 |
:executor_thread_pool_size => 64, |
| 184 |
:transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 185 |
:rpc_response_timeout => '30', |
| 186 |
:control_exchange => 'nova', |
| 187 |
) |
| 188 |
is_expected.to contain_oslo__messaging__rabbit('nova_config').with( |
| 189 |
:rabbit_use_ssl => true, |
| 190 |
:heartbeat_timeout_threshold => '60', |
| 191 |
:heartbeat_rate => '10', |
| 192 |
:rabbit_qos_prefetch_count => 0, |
| 193 |
:kombu_reconnect_delay => '5.0', |
| 194 |
:amqp_durable_queues => true, |
| 195 |
:amqp_auto_delete => true, |
| 196 |
:kombu_compression => 'gzip', |
| 197 |
:kombu_ssl_ca_certs => '/etc/ca.cert', |
| 198 |
:kombu_ssl_certfile => '/etc/certfile', |
| 199 |
:kombu_ssl_keyfile => '/etc/key', |
| 200 |
:kombu_ssl_version => 'TLSv1', |
| 201 |
:rabbit_ha_queues => true, |
| 202 |
:rabbit_quorum_queue => true, |
| 203 |
:rabbit_transient_quorum_queue => true, |
| 204 |
:rabbit_transient_queues_ttl => 60, |
| 205 |
:rabbit_quorum_delivery_limit => 3, |
| 206 |
:rabbit_quorum_max_memory_length => 5, |
| 207 |
:rabbit_quorum_max_memory_bytes => 1073741824, |
| 208 |
:use_queue_manager => true, |
| 209 |
:rabbit_stream_fanout => true, |
| 210 |
:enable_cancel_on_failover => false, |
| 211 |
:rabbit_retry_interval => '1', |
| 212 |
) |
| 213 |
is_expected.to contain_oslo__messaging__notifications('nova_config').with( |
| 214 |
:transport_url => 'rabbit://rabbit_user:password@localhost:5673', |
| 215 |
:driver => 'ceilometer.compute.nova_notifier', |
| 216 |
:topics => 'openstack', |
| 217 |
:retry => 10, |
| 218 |
) |
| 219 |
end |
| 220 |
|
| 221 |
it 'configures host' do |
| 222 |
is_expected.to contain_nova_config('DEFAULT/host').with_value('test-001.example.org') |
| 223 |
end |
| 224 |
|
| 225 |
it 'configures my_ip' do |
| 226 |
is_expected.to contain_nova_config('DEFAULT/my_ip').with_value('192.0.2.1') |
| 227 |
end |
| 228 |
|
| 229 |
it 'configures upgrade_levels' do |
| 230 |
is_expected.to contain_nova_config('upgrade_levels/compute').with_value('1.0.0') |
| 231 |
is_expected.to contain_nova_config('upgrade_levels/conductor').with_value('1.0.0') |
| 232 |
is_expected.to contain_nova_config('upgrade_levels/scheduler').with_value('1.0.0') |
| 233 |
end |
| 234 |
|
| 235 |
it 'configures various things' do |
| 236 |
is_expected.to contain_nova_config('DEFAULT/state_path').with_value('/var/lib/nova2') |
| 237 |
is_expected.to contain_oslo__concurrency('nova_config').with( |
| 238 |
:lock_path => '/var/locky/path' |
| 239 |
) |
| 240 |
is_expected.to contain_nova_config('DEFAULT/service_down_time').with_value('60') |
| 241 |
is_expected.to contain_nova_config('notifications/notification_format').with_value('unversioned') |
| 242 |
is_expected.to contain_nova_config('DEFAULT/report_interval').with_value('10') |
| 243 |
is_expected.to contain_nova_config('DEFAULT/periodic_fuzzy_delay').with_value('61') |
| 244 |
is_expected.to contain_nova_config('vif_plug_ovs/ovsdb_connection').with_value('tcp:127.0.0.1:6640') |
| 245 |
is_expected.to contain_nova_config('DEFAULT/long_rpc_timeout').with_value('1800') |
| 246 |
is_expected.to contain_nova_config('DEFAULT/record').with_value('/var/lib/nova/novnc.log') |
| 247 |
is_expected.to contain_nova_config('DEFAULT/ssl_only').with_value(true) |
| 248 |
is_expected.to contain_nova_config('DEFAULT/source_is_ipv6').with_value(false) |
| 249 |
is_expected.to contain_nova_config('DEFAULT/cert').with_value('/etc/ssl/private/snakeoil.pem') |
| 250 |
is_expected.to contain_nova_config('DEFAULT/key').with_value('/etc/ssl/certs/snakeoil.pem') |
| 251 |
is_expected.to contain_nova_config('console/allowed_origins').with_value('http://example.com') |
| 252 |
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES') |
| 253 |
is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('tlsv1_2') |
| 254 |
is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('foo') |
| 255 |
is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('instance-%08x'); |
| 256 |
is_expected.to contain_nova_config('DEFAULT/cell_worker_thread_pool_size').with_value(5); |
| 257 |
end |
| 258 |
|
| 259 |
context 'with multiple notification_driver' do |
| 260 |
before do |
| 261 |
params.merge!( :notification_driver => [ |
| 262 |
'ceilometer.compute.nova_notifier', |
| 263 |
'nova.openstack.common.notifier.rpc_notifier' |
| 264 |
]) |
| 265 |
end |
| 266 |
|
| 267 |
it { is_expected.to contain_oslo__messaging__notifications('nova_config').with( |
| 268 |
:driver => ['ceilometer.compute.nova_notifier', 'nova.openstack.common.notifier.rpc_notifier'], |
| 269 |
) } |
| 270 |
end |
| 271 |
end |
| 272 |
|
| 273 |
context 'with notify_on_state_change parameter' do |
| 274 |
let :params do |
| 275 |
{ :notify_on_state_change => 'vm_state' } |
| 276 |
end |
| 277 |
|
| 278 |
it 'configures database' do |
| 279 |
is_expected.to contain_nova_config('notifications/notify_on_state_change').with_value('vm_state') |
| 280 |
end |
| 281 |
end |
| 282 |
|
| 283 |
context 'with ssh public key' do |
| 284 |
let :params do |
| 285 |
{ |
| 286 |
:nova_public_key => {'type' => 'ssh-rsa', |
| 287 |
'key' => 'keydata'} |
| 288 |
} |
| 289 |
end |
| 290 |
|
| 291 |
it 'should install ssh public key' do |
| 292 |
is_expected.to contain_ssh_authorized_key('nova-migration-public-key').with( |
| 293 |
:ensure => 'present', |
| 294 |
:key => 'keydata', |
| 295 |
:type => 'ssh-rsa' |
| 296 |
) |
| 297 |
end |
| 298 |
end |
| 299 |
|
| 300 |
{ |
| 301 |
'ssh-rsa' => 'id_rsa', |
| 302 |
'ssh-dsa' => 'id_dsa', |
| 303 |
'ssh-ecdsa' => 'id_ecdsa', |
| 304 |
'ssh-ed25519' => 'id_ed25519' |
| 305 |
}.each do |keytype, keyname| |
| 306 |
context "with ssh private key(#{keytype})" do |
| 307 |
let :params do |
| 308 |
{ |
| 309 |
:nova_private_key => {'type' => keytype, |
| 310 |
'key' => 'keydata'} |
| 311 |
} |
| 312 |
end |
| 313 |
|
| 314 |
it 'should install ssh private key' do |
| 315 |
is_expected.to contain_file("/var/lib/nova/.ssh/#{keyname}").with( |
| 316 |
:content => 'keydata', |
| 317 |
:mode => '0600', |
| 318 |
:owner => 'nova', |
| 319 |
:group => 'nova', |
| 320 |
:show_diff => false, |
| 321 |
) |
| 322 |
end |
| 323 |
end |
| 324 |
end |
| 325 |
|
| 326 |
context 'with allocation ratios set' do |
| 327 |
let :params do |
| 328 |
{ |
| 329 |
:cpu_allocation_ratio => 32.0, |
| 330 |
:ram_allocation_ratio => 2.0, |
| 331 |
:disk_allocation_ratio => 1.5, |
| 332 |
:initial_cpu_allocation_ratio => 64.0, |
| 333 |
:initial_ram_allocation_ratio => 4.0, |
| 334 |
:initial_disk_allocation_ratio => 3.0, |
| 335 |
} |
| 336 |
end |
| 337 |
|
| 338 |
it { is_expected.to contain_nova_config('DEFAULT/cpu_allocation_ratio').with_value(32.0) } |
| 339 |
it { is_expected.to contain_nova_config('DEFAULT/ram_allocation_ratio').with_value(2.0) } |
| 340 |
it { is_expected.to contain_nova_config('DEFAULT/disk_allocation_ratio').with_value(1.5) } |
| 341 |
it { is_expected.to contain_nova_config('DEFAULT/initial_cpu_allocation_ratio').with_value(64.0) } |
| 342 |
it { is_expected.to contain_nova_config('DEFAULT/initial_ram_allocation_ratio').with_value(4.0) } |
| 343 |
it { is_expected.to contain_nova_config('DEFAULT/initial_disk_allocation_ratio').with_value(3.0) } |
| 344 |
end |
| 345 |
|
| 346 |
context 'with array used for console parameters' do |
| 347 |
let :params do |
| 348 |
{ |
| 349 |
:console_allowed_origins => ['http://192.0.2.1', 'http://192.0.2.2'], |
| 350 |
:console_ssl_ciphers => ['kEECDH+aECDSA+AES', 'kEECDH+AES+aRSA', 'kEDH+aRSA+AES'] |
| 351 |
} |
| 352 |
end |
| 353 |
it { |
| 354 |
is_expected.to contain_nova_config('console/allowed_origins').with_value('http://192.0.2.1,http://192.0.2.2') |
| 355 |
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES') |
| 356 |
} |
| 357 |
end |
| 358 |
end |
| 359 |
|
| 360 |
|
| 361 |
on_supported_os({ |
| 362 |
:supported_os => OSDefaults.get_supported_os |
| 363 |
}).each do |os,facts| |
| 364 |
context "on #{os}" do |
| 365 |
let (:facts) do |
| 366 |
facts.merge!(OSDefaults.get_facts()) |
| 367 |
end |
| 368 |
|
| 369 |
case facts[:os]['family'] |
| 370 |
when 'Debian' |
| 371 |
let (:platform_params) do |
| 372 |
{ :nova_common_package => 'nova-common', |
| 373 |
:lock_path => '/var/lock/nova' } |
| 374 |
end |
| 375 |
when 'RedHat' |
| 376 |
let (:platform_params) do |
| 377 |
{ :nova_common_package => 'openstack-nova-common', |
| 378 |
:lock_path => '/var/lib/nova/tmp' } |
| 379 |
end |
| 380 |
end |
| 381 |
|
| 382 |
it_behaves_like 'nova' |
| 383 |
|
| 384 |
end |
| 385 |
end |
| 386 |
|
| 387 |
end |