| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
describe 'nova::compute::libvirt_guests' do |
| 4 |
|
| 5 |
shared_examples 'nova::compute::libvirt_guests' do |
| 6 |
|
| 7 |
context 'with default parameters' do |
| 8 |
|
| 9 |
it { is_expected.to contain_class('nova::params')} |
| 10 |
|
| 11 |
it { is_expected.to contain_file(platform_params[:libvirt_guests_environment_file]).with( |
| 12 |
:ensure => 'file', |
| 13 |
:path => platform_params[:libvirt_guests_environment_file], |
| 14 |
:tag => 'libvirt-guests-file' |
| 15 |
)} |
| 16 |
it { is_expected.to contain_file_line('libvirt-guests ON_BOOT').with( |
| 17 |
:path => platform_params[:libvirt_guests_environment_file], |
| 18 |
:line => 'ON_BOOT=ignore', |
| 19 |
:match => '^ON_BOOT=.*', |
| 20 |
:tag => 'libvirt-guests-file_line' |
| 21 |
) } |
| 22 |
it { is_expected.to contain_file_line('libvirt-guests ON_SHUTDOWN').with( |
| 23 |
:path => platform_params[:libvirt_guests_environment_file], |
| 24 |
:line => 'ON_SHUTDOWN=shutdown', |
| 25 |
:match => '^ON_SHUTDOWN=.*', |
| 26 |
:tag => 'libvirt-guests-file_line' |
| 27 |
) } |
| 28 |
it { is_expected.to contain_file_line('libvirt-guests START_DELAY').with( |
| 29 |
:ensure => 'absent', |
| 30 |
:path => platform_params[:libvirt_guests_environment_file], |
| 31 |
:match => '^START_DELAY=.*', |
| 32 |
:match_for_absence => true, |
| 33 |
:tag => 'libvirt-guests-file_line' |
| 34 |
) } |
| 35 |
it { is_expected.to contain_file_line('libvirt-guests SHUTDOWN_TIMEOUT').with( |
| 36 |
:ensure => 'absent', |
| 37 |
:path => platform_params[:libvirt_guests_environment_file], |
| 38 |
:match => '^SHUTDOWN_TIMEOUT=.*', |
| 39 |
:match_for_absence => true, |
| 40 |
:tag => 'libvirt-guests-file_line' |
| 41 |
) } |
| 42 |
it { is_expected.to contain_file_line('libvirt-guests PARALLEL_SHUTDOWN').with( |
| 43 |
:ensure => 'absent', |
| 44 |
:path => platform_params[:libvirt_guests_environment_file], |
| 45 |
:match => '^PARALLEL_SHUTDOWN=.*', |
| 46 |
:match_for_absence => true, |
| 47 |
:tag => 'libvirt-guests-file_line' |
| 48 |
) } |
| 49 |
it { is_expected.to contain_file_line('libvirt-guests BYPASS_CACHE').with( |
| 50 |
:ensure => 'absent', |
| 51 |
:path => platform_params[:libvirt_guests_environment_file], |
| 52 |
:match => '^BYPASS_CACHE=.*', |
| 53 |
:match_for_absence => true, |
| 54 |
:tag => 'libvirt-guests-file_line' |
| 55 |
) } |
| 56 |
it { is_expected.to contain_file_line('libvirt-guests SYNC_TIME').with( |
| 57 |
:ensure => 'absent', |
| 58 |
:path => platform_params[:libvirt_guests_environment_file], |
| 59 |
:match => '^SYNC_TIME=.*', |
| 60 |
:match_for_absence => true, |
| 61 |
:tag => 'libvirt-guests-file_line' |
| 62 |
) } |
| 63 |
|
| 64 |
it { is_expected.to contain_package('libvirt-client').with( |
| 65 |
:name => platform_params[:libvirt_client_package_name], |
| 66 |
:ensure => 'present' |
| 67 |
) } |
| 68 |
|
| 69 |
it { is_expected.to_not contain_service('libvirt-guests')} |
| 70 |
end |
| 71 |
|
| 72 |
context 'with params' do |
| 73 |
let :params do |
| 74 |
{ |
| 75 |
:enabled => true, |
| 76 |
:manage_service => true, |
| 77 |
:on_boot => 'start', |
| 78 |
:on_shutdown => 'suspend', |
| 79 |
:start_delay => 0, |
| 80 |
:shutdown_timeout => 300, |
| 81 |
:parallel_shutdown => 0, |
| 82 |
:bypass_cache => true, |
| 83 |
:sync_time => true, |
| 84 |
} |
| 85 |
end |
| 86 |
|
| 87 |
it { is_expected.to contain_file(platform_params[:libvirt_guests_environment_file]).with( |
| 88 |
:ensure => 'file', |
| 89 |
:path => platform_params[:libvirt_guests_environment_file], |
| 90 |
:tag => 'libvirt-guests-file' |
| 91 |
)} |
| 92 |
it { is_expected.to contain_file_line('libvirt-guests ON_BOOT').with( |
| 93 |
:path => platform_params[:libvirt_guests_environment_file], |
| 94 |
:line => 'ON_BOOT=start', |
| 95 |
:match => '^ON_BOOT=.*', |
| 96 |
:tag => 'libvirt-guests-file_line' |
| 97 |
) } |
| 98 |
it { is_expected.to contain_file_line('libvirt-guests ON_SHUTDOWN').with( |
| 99 |
:path => platform_params[:libvirt_guests_environment_file], |
| 100 |
:line => "ON_SHUTDOWN=suspend", |
| 101 |
:match => '^ON_SHUTDOWN=.*', |
| 102 |
:tag => 'libvirt-guests-file_line' |
| 103 |
) } |
| 104 |
it { is_expected.to contain_file_line('libvirt-guests START_DELAY').with( |
| 105 |
:path => platform_params[:libvirt_guests_environment_file], |
| 106 |
:line => 'START_DELAY=0', |
| 107 |
:match => '^START_DELAY=.*', |
| 108 |
:tag => 'libvirt-guests-file_line' |
| 109 |
) } |
| 110 |
it { is_expected.to contain_file_line('libvirt-guests SHUTDOWN_TIMEOUT').with( |
| 111 |
:path => platform_params[:libvirt_guests_environment_file], |
| 112 |
:line => "SHUTDOWN_TIMEOUT=300", |
| 113 |
:match => '^SHUTDOWN_TIMEOUT=.*', |
| 114 |
:tag => 'libvirt-guests-file_line' |
| 115 |
) } |
| 116 |
it { is_expected.to contain_file_line('libvirt-guests PARALLEL_SHUTDOWN').with( |
| 117 |
:path => platform_params[:libvirt_guests_environment_file], |
| 118 |
:line => "PARALLEL_SHUTDOWN=0", |
| 119 |
:match => '^PARALLEL_SHUTDOWN=.*', |
| 120 |
:tag => 'libvirt-guests-file_line' |
| 121 |
) } |
| 122 |
it { is_expected.to contain_file_line('libvirt-guests BYPASS_CACHE').with( |
| 123 |
:path => platform_params[:libvirt_guests_environment_file], |
| 124 |
:line => "BYPASS_CACHE=1", |
| 125 |
:match => '^BYPASS_CACHE=.*', |
| 126 |
:tag => 'libvirt-guests-file_line' |
| 127 |
) } |
| 128 |
it { is_expected.to contain_file_line('libvirt-guests SYNC_TIME').with( |
| 129 |
:path => platform_params[:libvirt_guests_environment_file], |
| 130 |
:line => "SYNC_TIME=1", |
| 131 |
:match => '^SYNC_TIME=.*', |
| 132 |
:tag => 'libvirt-guests-file_line' |
| 133 |
) } |
| 134 |
|
| 135 |
it { is_expected.to contain_package('libvirt-client').with( |
| 136 |
:name => platform_params[:libvirt_client_package_name], |
| 137 |
:ensure => 'present' |
| 138 |
) } |
| 139 |
|
| 140 |
it { is_expected.to contain_service('libvirt-guests').with( |
| 141 |
:name => platform_params[:libvirt_guests_service_name], |
| 142 |
:enable => true, |
| 143 |
:ensure => 'running', |
| 144 |
)} |
| 145 |
end |
| 146 |
|
| 147 |
context 'while not managing service state' do |
| 148 |
let :params do |
| 149 |
{ |
| 150 |
:enabled => true, |
| 151 |
} |
| 152 |
end |
| 153 |
|
| 154 |
it { is_expected.to_not contain_service('libvirt-guests') } |
| 155 |
end |
| 156 |
|
| 157 |
end |
| 158 |
|
| 159 |
on_supported_os({ |
| 160 |
:supported_os => OSDefaults.get_supported_os |
| 161 |
}).each do |os,facts| |
| 162 |
context "on #{os}" do |
| 163 |
let (:facts) do |
| 164 |
facts.merge!(OSDefaults.get_facts({ :os_workers => 5 })) |
| 165 |
end |
| 166 |
|
| 167 |
let (:platform_params) do |
| 168 |
case facts[:os]['family'] |
| 169 |
when 'Debian' |
| 170 |
{ |
| 171 |
:libvirt_client_package_name => 'libvirt-clients', |
| 172 |
:libvirt_guests_service_name => 'libvirt-guests', |
| 173 |
:libvirt_guests_environment_file => '/etc/default/libvirt-guests' |
| 174 |
} |
| 175 |
when 'RedHat' |
| 176 |
{ |
| 177 |
:libvirt_client_package_name => 'libvirt-client', |
| 178 |
:libvirt_guests_service_name => 'libvirt-guests', |
| 179 |
:libvirt_guests_environment_file => '/etc/sysconfig/libvirt-guests' |
| 180 |
} |
| 181 |
end |
| 182 |
end |
| 183 |
it_behaves_like 'nova::compute::libvirt_guests' |
| 184 |
end |
| 185 |
end |
| 186 |
end |