| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'nova::compute::libvirt::qemu' do |
| 4 |
|
| 5 |
shared_examples_for 'nova compute libvirt with qemu' do |
| 6 |
|
| 7 |
context 'when not configuring qemu' do |
| 8 |
it 'should remove all configuations' do |
| 9 |
is_expected.to contain_qemu_config('max_files').with_ensure('absent') |
| 10 |
is_expected.to contain_qemu_config('max_processes').with_ensure('absent') |
| 11 |
is_expected.to contain_qemu_config('vnc_tls').with_ensure('absent') |
| 12 |
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_ensure('absent') |
| 13 |
is_expected.to contain_qemu_config('default_tls_x509_verify').with_ensure('absent') |
| 14 |
is_expected.to contain_qemu_config('user').with_ensure('absent') |
| 15 |
is_expected.to contain_qemu_config('group').with_ensure('absent') |
| 16 |
is_expected.to contain_qemu_config('memory_backing_dir').with_ensure('absent') |
| 17 |
is_expected.to contain_qemu_config('nbd_tls').with_ensure('absent') |
| 18 |
end |
| 19 |
end |
| 20 |
|
| 21 |
context 'when configuring qemu with defaults' do |
| 22 |
let :params do |
| 23 |
{ |
| 24 |
:configure_qemu => true, |
| 25 |
} |
| 26 |
end |
| 27 |
it 'should configure the default values' do |
| 28 |
is_expected.to contain_qemu_config('max_files').with_value(1024) |
| 29 |
is_expected.to contain_qemu_config('max_processes').with_value(4096) |
| 30 |
is_expected.to contain_qemu_config('vnc_tls').with_value(false) |
| 31 |
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(false) |
| 32 |
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(true) |
| 33 |
is_expected.to contain_qemu_config('user').with_ensure('absent') |
| 34 |
is_expected.to contain_qemu_config('group').with_ensure('absent') |
| 35 |
is_expected.to contain_qemu_config('memory_backing_dir').with_ensure('absent') |
| 36 |
is_expected.to contain_qemu_config('nbd_tls').with_value(false) |
| 37 |
end |
| 38 |
end |
| 39 |
|
| 40 |
context 'when configuring qemu with overridden parameters' do |
| 41 |
let :params do |
| 42 |
{ |
| 43 |
:configure_qemu => true, |
| 44 |
:max_files => 32768, |
| 45 |
:max_processes => 131072, |
| 46 |
:user => 'qemu-user', |
| 47 |
:group => 'qemu-group', |
| 48 |
:memory_backing_dir => '/tmp', |
| 49 |
} |
| 50 |
end |
| 51 |
it 'should configure the given values' do |
| 52 |
is_expected.to contain_qemu_config('max_files').with_value(32768) |
| 53 |
is_expected.to contain_qemu_config('max_processes').with_value(131072) |
| 54 |
is_expected.to contain_qemu_config('user').with_value('qemu-user').with_quote(true) |
| 55 |
is_expected.to contain_qemu_config('group').with_value('qemu-group').with_quote(true) |
| 56 |
is_expected.to contain_qemu_config('memory_backing_dir').with_value('/tmp').with_quote(true) |
| 57 |
end |
| 58 |
end |
| 59 |
|
| 60 |
context 'when configuring qemu with vnc_tls' do |
| 61 |
let :params do |
| 62 |
{ |
| 63 |
:configure_qemu => true, |
| 64 |
:vnc_tls => true, |
| 65 |
} |
| 66 |
end |
| 67 |
it 'should configure vnc tls' do |
| 68 |
is_expected.to contain_qemu_config('vnc_tls').with_value(true) |
| 69 |
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(true) |
| 70 |
end |
| 71 |
end |
| 72 |
|
| 73 |
context 'when configuring qemu with default_tls_verify enabled' do |
| 74 |
let :params do |
| 75 |
{ |
| 76 |
:configure_qemu => true, |
| 77 |
:default_tls_verify => true, |
| 78 |
} |
| 79 |
end |
| 80 |
it 'should enable default_tls_x509_verify' do |
| 81 |
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(true) |
| 82 |
end |
| 83 |
end |
| 84 |
|
| 85 |
context 'when configuring qemu with vnc_tls_verify disabled' do |
| 86 |
let :params do |
| 87 |
{ |
| 88 |
:configure_qemu => true, |
| 89 |
:vnc_tls => true, |
| 90 |
:vnc_tls_verify => false, |
| 91 |
} |
| 92 |
end |
| 93 |
it 'should disable vnc_tls_x509_veridy' do |
| 94 |
is_expected.to contain_qemu_config('vnc_tls').with_value(true) |
| 95 |
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(false) |
| 96 |
end |
| 97 |
end |
| 98 |
|
| 99 |
context 'when configuring qemu with default_tls_verify disabled' do |
| 100 |
let :params do |
| 101 |
{ |
| 102 |
:configure_qemu => true, |
| 103 |
:default_tls_verify => false, |
| 104 |
} |
| 105 |
end |
| 106 |
it 'should disable default_tls_x509_verify' do |
| 107 |
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(false) |
| 108 |
end |
| 109 |
end |
| 110 |
|
| 111 |
context 'when configuring qemu with nbd_tls' do |
| 112 |
let :params do |
| 113 |
{ |
| 114 |
:configure_qemu => true, |
| 115 |
:nbd_tls => true, |
| 116 |
} |
| 117 |
end |
| 118 |
it 'should enable nbd_tls' do |
| 119 |
is_expected.to contain_qemu_config('nbd_tls').with_value(true) |
| 120 |
end |
| 121 |
end |
| 122 |
|
| 123 |
end |
| 124 |
|
| 125 |
on_supported_os({ |
| 126 |
:supported_os => OSDefaults.get_supported_os |
| 127 |
}).each do |os,facts| |
| 128 |
context "on #{os}" do |
| 129 |
let (:facts) do |
| 130 |
facts.merge!(OSDefaults.get_facts()) |
| 131 |
end |
| 132 |
|
| 133 |
it_configures 'nova compute libvirt with qemu' |
| 134 |
end |
| 135 |
end |
| 136 |
end |