Debian Codegraph @

spec/classes/nova_compute_libvirt_services_spec.rb

raw
1 require 'spec_helper'
2
3 describe 'nova::compute::libvirt::services' do
4
5 shared_examples_for 'nova compute libvirt services' do
6 context 'with default parameters' do
7 it 'installs ovmf' do
8 is_expected.to contain_package('ovmf').with(
9 :ensure => 'present',
10 :name => platform_params[:ovmf_package_name],
11 :tag => ['openstack', 'nova-support-package'],
12 )
13 end
14
15 it 'skips installs swtpm' do
16 is_expected.to_not contain_package('swtpm')
17 end
18 end
19
20 context 'when libvirt service is not managed' do
21 before :each do
22 params.merge!({
23 :libvirt_service_name => false,
24 })
25 end
26
27 it 'skips installing libvirt' do
28 is_expected.not_to contain_package('libvirt')
29 is_expected.not_to contain_package('libvirt-daemon')
30 is_expected.not_to contain_service('libvirt')
31 end
32 end
33
34 context 'when ovmf package is not managed' do
35 before :each do
36 params.merge!({
37 :manage_ovmf => false,
38 })
39 end
40
41 it 'skips installing ovmf' do
42 is_expected.not_to contain_package('ovmf')
43 end
44 end
45
46 context 'when swtpm package is managed' do
47 before :each do
48 params.merge!({
49 :manage_swtpm => true,
50 })
51 end
52
53 it 'installs swtpm' do
54 is_expected.to contain_package('swtpm').with(
55 :ensure => 'present',
56 :name => platform_params[:swtpm_package_name],
57 :tag => ['openstack', 'nova-support-package'],
58 )
59 end
60 end
61 end
62
63 shared_examples_for 'nova compute libvirt services with monolithic libvirt' do
64 context 'with default parameters' do
65 it 'deploys libvirt service' do
66 is_expected.to contain_package('libvirt').with(
67 :ensure => 'present',
68 :name => platform_params[:libvirt_package_name],
69 :tag => ['openstack', 'nova-support-package'],
70 )
71 if facts[:os]['family'] == 'RedHat'
72 is_expected.to contain_package('libvirt-daemon').with(
73 :ensure => 'present',
74 :name => platform_params[:libvirt_daemon_package_name],
75 :tag => ['openstack', 'nova-support-package'],
76 )
77 end
78
79 is_expected.to contain_service('libvirt').with(
80 :ensure => 'running',
81 :enable => true,
82 :name => platform_params[:libvirt_service_name],
83 :tag => ['libvirt-service', 'libvirt-qemu-service'],
84 )
85 is_expected.to contain_service('virtlogd').with(
86 :ensure => 'running',
87 :enable => true,
88 :name => platform_params[:virtlog_service_name],
89 :tag => ['libvirt-service'],
90 )
91 is_expected.to contain_service('virtlockd').with(
92 :ensure => 'running',
93 :enable => true,
94 :name => platform_params[:virtlock_service_name],
95 :tag => ['libvirt-service'],
96 )
97 end
98
99 it 'does not deploy modular libvirt services' do
100 is_expected.to_not contain_package('virtsecret')
101 is_expected.to_not contain_package('virtnodedev')
102 is_expected.to_not contain_package('virtqemu')
103 is_expected.to_not contain_package('virtstorage')
104
105 is_expected.to_not contain_service('virtsecretd')
106 is_expected.to_not contain_service('virtnodedevd')
107 is_expected.to_not contain_service('virtqemud')
108 is_expected.to_not contain_service('virtproxyd')
109 is_expected.to_not contain_service('virtstoraged')
110 end
111 end
112 end
113
114 shared_examples_for 'nova compute libvirt services with modular libvirt' do
115 context 'with default parameters' do
116 before :each do
117 params.merge!({
118 :modular_libvirt => true
119 })
120 end
121
122 it 'deploys libvirt service' do
123 is_expected.to contain_package('libvirt').with(
124 :ensure => 'present',
125 :name => platform_params[:libvirt_package_name],
126 :tag => ['openstack', 'nova-support-package'],
127 )
128 is_expected.to_not contain_package('libvirt-daemon')
129
130 is_expected.to contain_service('libvirt').with(
131 :ensure => 'stopped',
132 :enable => false,
133 :name => platform_params[:libvirt_service_name],
134 :tag => ['libvirt-service', 'libvirt-qemu-service'],
135 )
136 is_expected.to contain_service('virtlogd').with(
137 :ensure => 'running',
138 :enable => true,
139 :name => platform_params[:virtlog_service_name],
140 :tag => ['libvirt-service'],
141 )
142 is_expected.to contain_service('virtlockd').with(
143 :ensure => 'running',
144 :enable => true,
145 :name => platform_params[:virtlock_service_name],
146 :tag => ['libvirt-service'],
147 )
148 end
149
150 it 'deploys modular libvirt services' do
151 is_expected.to contain_package('virtsecret').with(
152 :ensure => 'present',
153 :name => platform_params[:virtsecret_package_name],
154 :tag => ['openstack', 'nova-support-package'],
155 )
156 is_expected.to contain_package('virtnodedev').with(
157 :ensure => 'present',
158 :name => platform_params[:virtnodedev_package_name],
159 :tag => ['openstack', 'nova-support-package'],
160 )
161 is_expected.to contain_package('virtqemu').with(
162 :ensure => 'present',
163 :name => platform_params[:virtqemu_package_name],
164 :tag => ['openstack', 'nova-support-package'],
165 )
166 is_expected.to contain_package('virtstorage').with(
167 :ensure => 'present',
168 :name => platform_params[:virtstorage_package_name],
169 :tag => ['openstack', 'nova-support-package'],
170 )
171
172 is_expected.to contain_service('virtsecretd').with(
173 :ensure => 'running',
174 :enable => true,
175 :name => platform_params[:virtsecret_service_name],
176 :tag => ['libvirt-service', 'libvirt-modular-service'],
177 )
178 is_expected.to contain_service('virtnodedevd').with(
179 :ensure => 'running',
180 :enable => true,
181 :name => platform_params[:virtnodedev_service_name],
182 :tag => ['libvirt-service', 'libvirt-modular-service'],
183 )
184 is_expected.to contain_service('virtqemud').with(
185 :ensure => 'running',
186 :enable => true,
187 :name => platform_params[:virtqemu_service_name],
188 :tag => ['libvirt-service', 'libvirt-qemu-service', 'libvirt-modular-service'],
189 )
190 is_expected.to contain_service('virtproxyd').with(
191 :ensure => 'running',
192 :enable => true,
193 :name => platform_params[:virtproxy_service_name],
194 :tag => ['libvirt-service', 'libvirt-modular-service'],
195 )
196 is_expected.to contain_service('virtnodedevd').with(
197 :ensure => 'running',
198 :enable => true,
199 :name => platform_params[:virtnodedev_service_name],
200 :tag => ['libvirt-service', 'libvirt-modular-service'],
201 )
202 is_expected.to contain_service('virtstoraged').with(
203 :ensure => 'running',
204 :enable => true,
205 :name => platform_params[:virtstorage_service_name],
206 :tag => ['libvirt-service', 'libvirt-modular-service'],
207 )
208 end
209 end
210 end
211
212 on_supported_os({
213 :supported_os => OSDefaults.get_supported_os
214 }).each do |os,facts|
215 context "on #{os}" do
216 let :facts do
217 facts.merge!(OSDefaults.get_facts())
218 end
219
220 let :platform_params do
221 case facts[:os]['family']
222 when 'Debian'
223 {
224 :libvirt_package_name => 'libvirt-daemon-system',
225 :libvirt_service_name => 'libvirtd',
226 :virtlock_service_name => 'virtlockd',
227 :virtlog_service_name => 'virtlogd',
228 :ovmf_package_name => 'ovmf',
229 :swtpm_package_name => 'swtpm'
230 }
231 when 'RedHat'
232 {
233 :libvirt_package_name => 'libvirt-daemon-kvm',
234 :libvirt_daemon_package_name => 'libvirt-daemon',
235 :libvirt_service_name => 'libvirtd',
236 :virtlock_service_name => 'virtlockd',
237 :virtlog_service_name => 'virtlogd',
238 :virtsecret_package_name => 'libvirt-daemon-driver-secret',
239 :virtnodedev_package_name => 'libvirt-daemon-driver-nodedev',
240 :virtqemu_package_name => 'libvirt-daemon-driver-qemu',
241 :virtstorage_package_name => 'libvirt-daemon-driver-storage',
242 :virtsecret_service_name => 'virtsecretd.socket',
243 :virtnodedev_service_name => 'virtnodedevd.socket',
244 :virtqemu_service_name => 'virtqemud.socket',
245 :virtproxy_service_name => 'virtproxyd.socket',
246 :virtstorage_service_name => 'virtstoraged.socket',
247 :ovmf_package_name => 'edk2-ovmf',
248 :swtpm_package_name => 'swtpm'
249 }
250 end
251 end
252
253 let :params do
254 {}
255 end
256
257 it_configures 'nova compute libvirt services'
258 if facts[:os]['family'] == 'Debian'
259 # NOTE(tkajinam): Debian family uses monolithic libvirt by default, and
260 # does not support modular libvirt
261 it_configures 'nova compute libvirt services with monolithic libvirt'
262 else
263 # NOTE(tkajinam): RedHat family uses modular libvirt by default
264 it_configures 'nova compute libvirt services with modular libvirt'
265
266 context 'with modular libvirt disabled' do
267 before :each do
268 params.merge!({ :modular_libvirt => false })
269 end
270 it_configures 'nova compute libvirt services with monolithic libvirt'
271 end
272 end
273 end
274 end
275 end