Do Karaf/install tests with defaults for all OSs
[integration/packaging/puppet-opendaylight.git] / spec / classes / opendaylight_spec.rb
1 require 'spec_helper'
2
3 describe 'opendaylight' do
4   # All tests that check OS support/not-support
5   describe 'OS support tests' do
6     # All tests for OSs in the Red Hat family (CentOS, Fedora)
7     describe 'OS family Red Hat ' do
8       osfamily = 'RedHat'
9       # All tests for Fedora
10       describe 'Fedora' do
11         operatingsystem = 'Fedora'
12
13         # All tests for supported versions of Fedora
14         ['20', '21'].each do |operatingsystemmajrelease|
15           context "#{operatingsystemmajrelease}" do
16             let(:facts) {{
17               :osfamily => osfamily,
18               :operatingsystem => operatingsystem,
19               :operatingsystemmajrelease => operatingsystemmajrelease,
20             }}
21             # Run shared tests applicable to all supported OSs
22             # Note that this function is defined in spec_helper
23             generic_tests
24
25             # Run test that specialize in checking rpm-based installs
26             # NB: Only testing defaults here, specialized rpm tests elsewhere
27             # Note that this function is defined in spec_helper
28             rpm_install_tests(operatingsystem: operatingsystem)
29
30             # Run test that specialize in checking Karaf feature installs
31             # NB: Only testing defaults here, specialized Karaf tests elsewhere
32             # Note that this function is defined in spec_helper
33             karaf_feature_tests
34           end
35         end
36
37         # All tests for unsupported versions of Fedora
38         ['18', '19', '22'].each do |operatingsystemmajrelease|
39           context "#{operatingsystemmajrelease}" do
40             let(:facts) {{
41               :osfamily => osfamily,
42               :operatingsystem => operatingsystem,
43               :operatingsystemmajrelease => operatingsystemmajrelease,
44             }}
45             # Run shared tests applicable to all unsupported OSs
46             # Note that this function is defined in spec_helper
47             expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}"
48             unsupported_os_tests(expected_msg: expected_msg)
49           end
50         end
51       end
52
53       # All tests for CentOS
54       describe 'CentOS' do
55         operatingsystem = 'CentOS'
56
57         # All tests for supported versions of CentOS
58         ['7'].each do |operatingsystemmajrelease|
59           context "#{operatingsystemmajrelease}" do
60             let(:facts) {{
61               :osfamily => osfamily,
62               :operatingsystem => operatingsystem,
63               :operatingsystemmajrelease => operatingsystemmajrelease,
64             }}
65             # Run shared tests applicable to all supported OSs
66             # Note that this function is defined in spec_helper
67             generic_tests
68
69             # Run test that specialize in checking rpm-based installs
70             # NB: Only testing defaults here, specialized rpm tests elsewhere
71             # Note that this function is defined in spec_helper
72             rpm_install_tests
73
74             # Run test that specialize in checking Karaf feature installs
75             # NB: Only testing defaults here, specialized Karaf tests elsewhere
76             # Note that this function is defined in spec_helper
77             karaf_feature_tests
78           end
79         end
80
81         # All tests for unsupported versions of CentOS
82         ['5', '6', '8'].each do |operatingsystemmajrelease|
83           context "#{operatingsystemmajrelease}" do
84             let(:facts) {{
85               :osfamily => osfamily,
86               :operatingsystem => operatingsystem,
87               :operatingsystemmajrelease => operatingsystemmajrelease,
88             }}
89             # Run shared tests applicable to all unsupported OSs
90             # Note that this function is defined in spec_helper
91             expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}"
92             unsupported_os_tests(expected_msg: expected_msg)
93           end
94         end
95       end
96     end
97
98     # All tests for OSs in the Debian family (Ubuntu)
99     describe 'OS family Debian' do
100       osfamily = 'Debian'
101
102       # All tests for Ubuntu 14.04
103       describe 'Ubuntu' do
104         operatingsystem = 'Ubuntu'
105
106         # All tests for supported versions of Ubuntu
107         ['14.04'].each do |operatingsystemmajrelease|
108           context "#{operatingsystemmajrelease}" do
109             let(:facts) {{
110               :osfamily => osfamily,
111               :operatingsystem => operatingsystem,
112               :operatingsystemmajrelease => operatingsystemmajrelease,
113               # TODO: Do more elegantly. Java mod uses codenames to ID version.
114               :lsbdistcodename => 'trusty',
115               :path => ['/usr/local/bin', '/usr/bin', '/bin'],
116             }}
117
118             # NB: Only tarball installs are supported for Debian family OSs
119             let(:params) {{
120                 :install_method => 'tarball',
121             }}
122
123             # Run shared tests applicable to all supported OSs
124             # Note that this function is defined in spec_helper
125             generic_tests
126
127             # Run test that specialize in checking tarball-based installs
128             # NB: Only testing defaults here, specialized tarball tests elsewhere
129             # Passing osfamily required to do upstart vs systemd (default) checks
130             # Note that this function is defined in spec_helper
131             tarball_install_tests(osfamily: osfamily)
132
133             # Run test that specialize in checking Karaf feature installs
134             # NB: Only testing defaults here, specialized Karaf tests elsewhere
135             # Note that this function is defined in spec_helper
136             karaf_feature_tests
137           end
138         end
139
140         # All tests for unsupported versions of Ubuntu
141         ['12.04', '12.10', '13.04', '13.10', '14.10', '15.04'].each do |operatingsystemmajrelease|
142           context "#{operatingsystemmajrelease}" do
143             let(:facts) {{
144               :osfamily => osfamily,
145               :operatingsystem => operatingsystem,
146               :operatingsystemmajrelease => operatingsystemmajrelease,
147             }}
148             # Run shared tests applicable to all unsupported OSs
149             # Note that this function is defined in spec_helper
150             expected_msg = "Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}"
151             unsupported_os_tests(expected_msg: expected_msg)
152           end
153         end
154       end
155     end
156
157     # All tests for unsupported OS families
158     ['Suse', 'Solaris'].each do |osfamily|
159       context "OS family #{osfamily}" do
160         let(:facts) {{
161           :osfamily => osfamily,
162         }}
163
164         # Run shared tests applicable to all unsupported OSs
165         # Note that this function is defined in spec_helper
166         expected_msg = "Unsupported OS family: #{osfamily}"
167         unsupported_os_tests(expected_msg: expected_msg)
168       end
169     end
170   end
171
172   # All Karaf feature tests
173   describe 'Karaf feature tests' do
174     # Non-OS-type tests assume CentOS 7
175     #   See issue #43 for reasoning:
176     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
177     osfamily = 'RedHat'
178     operatingsystem = 'CentOS'
179     operatingsystemmajrelease = '7'
180     describe 'using default features' do
181       context 'and not passing extra features' do
182         let(:facts) {{
183           :osfamily => osfamily,
184           :operatingsystem => operatingsystem,
185           :operatingsystemmajrelease => operatingsystemmajrelease,
186         }}
187
188         let(:params) {{ }}
189
190         # Run shared tests applicable to all supported OSs
191         # Note that this function is defined in spec_helper
192         generic_tests
193
194         # Run test that specialize in checking Karaf feature installs
195         # Note that this function is defined in spec_helper
196         karaf_feature_tests
197       end
198
199       context 'and passing extra features' do
200         let(:facts) {{
201           :osfamily => osfamily,
202           :operatingsystem => operatingsystem,
203           :operatingsystemmajrelease => operatingsystemmajrelease,
204         }}
205
206         # These are real but arbitrarily chosen features
207         extra_features = ['odl-base-all', 'odl-ovsdb-all']
208         let(:params) {{
209           :extra_features => extra_features,
210         }}
211
212         # Run shared tests applicable to all supported OSs
213         # Note that this function is defined in spec_helper
214         generic_tests
215
216         # Run test that specialize in checking Karaf feature installs
217         # Note that this function is defined in spec_helper
218         karaf_feature_tests(extra_features: extra_features)
219       end
220     end
221
222     describe 'overriding default features' do
223       default_features = ['standard', 'ssh']
224       context 'and not passing extra features' do
225         let(:facts) {{
226           :osfamily => osfamily,
227           :operatingsystem => operatingsystem,
228           :operatingsystemmajrelease => operatingsystemmajrelease,
229         }}
230
231         let(:params) {{
232           :default_features => default_features,
233         }}
234
235         # Run shared tests applicable to all supported OSs
236         # Note that this function is defined in spec_helper
237         generic_tests
238
239         # Run test that specialize in checking Karaf feature installs
240         # Note that this function is defined in spec_helper
241         karaf_feature_tests(default_features: default_features)
242       end
243
244       context 'and passing extra features' do
245         let(:facts) {{
246           :osfamily => osfamily,
247           :operatingsystem => operatingsystem,
248           :operatingsystemmajrelease => operatingsystemmajrelease,
249         }}
250
251         # These are real but arbitrarily chosen features
252         extra_features = ['odl-base-all', 'odl-ovsdb-all']
253         let(:params) {{
254           :default_features => default_features,
255           :extra_features => extra_features,
256         }}
257
258         # Run shared tests applicable to all supported OSs
259         # Note that this function is defined in spec_helper
260         generic_tests
261
262         # Run test that specialize in checking Karaf feature installs
263         # Note that this function is defined in spec_helper
264         karaf_feature_tests(default_features: default_features, extra_features: extra_features)
265       end
266     end
267   end
268
269   # All install method tests
270   describe 'install method tests' do
271     # Non-OS-type tests assume CentOS 7
272     #   See issue #43 for reasoning:
273     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
274     osfamily = 'RedHat'
275     operatingsystem = 'CentOS'
276     operatingsystemrelease = '7.0'
277     operatingsystemmajrelease = '7'
278
279     # All tests for RPM install method
280     context 'RPM' do
281       let(:facts) {{
282         :osfamily => osfamily,
283         :operatingsystem => operatingsystem,
284         :operatingsystemmajrelease => operatingsystemmajrelease,
285       }}
286
287       let(:params) {{
288           :install_method => 'rpm',
289       }}
290
291       # Run shared tests applicable to all supported OSs
292       # Note that this function is defined in spec_helper
293       generic_tests
294
295       # Run test that specialize in checking RPM-based installs
296       # Note that this function is defined in spec_helper
297       rpm_install_tests
298     end
299
300     # All tests for tarball install method
301     describe 'tarball' do
302       describe 'using default tarball_url' do
303         context 'using default unitfile_url' do
304           let(:facts) {{
305             :osfamily => osfamily,
306             :operatingsystem => operatingsystem,
307             :operatingsystemrelease => operatingsystemrelease,
308             :operatingsystemmajrelease => operatingsystemmajrelease,
309             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
310           }}
311
312           let(:params) {{
313               :install_method => 'tarball',
314           }}
315
316           # Run shared tests applicable to all supported OSs
317           # Note that this function is defined in spec_helper
318           generic_tests
319
320           # Run test that specialize in checking tarball-based installs
321           # Note that this function is defined in spec_helper
322           tarball_install_tests
323         end
324
325         context 'overriding default unitfile_url' do
326           # Doesn't matter if this is valid, just that it honors what we pass
327           unitfile_url = 'fake_unitfile'
328           let(:facts) {{
329             :osfamily => osfamily,
330             :operatingsystem => operatingsystem,
331             :operatingsystemrelease => operatingsystemrelease,
332             :operatingsystemmajrelease => operatingsystemmajrelease,
333             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
334           }}
335
336           let(:params) {{
337               :install_method => 'tarball',
338               :unitfile_url => unitfile_url,
339           }}
340
341           # Run shared tests applicable to all supported OSs
342           # Note that this function is defined in spec_helper
343           generic_tests
344
345           # Run test that specialize in checking tarball-based installs
346           # Note that this function is defined in spec_helper
347           tarball_install_tests(unitfile_url: unitfile_url)
348         end
349       end
350
351       describe 'overriding default tarball_url' do
352         # Doesn't matter if this is valid, just that it honors what we pass
353         tarball_url = 'fake_tarball'
354         context 'using default unitfile_url' do
355           unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
356           let(:facts) {{
357             :osfamily => osfamily,
358             :operatingsystem => operatingsystem,
359             :operatingsystemrelease => operatingsystemrelease,
360             :operatingsystemmajrelease => operatingsystemmajrelease,
361             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
362           }}
363
364           let(:params) {{
365               :install_method => 'tarball',
366               :tarball_url => tarball_url,
367           }}
368
369           # Run shared tests applicable to all supported OSs
370           # Note that this function is defined in spec_helper
371           generic_tests
372
373           # Run test that specialize in checking tarball-based installs
374           # Note that this function is defined in spec_helper
375           tarball_install_tests(tarball_url: tarball_url)
376         end
377
378         context 'overriding default unitfile_url' do
379           # Doesn't matter if this is valid, just that it honors what we pass
380           unitfile_url = 'fake_unitfile'
381           let(:facts) {{
382             :osfamily => osfamily,
383             :operatingsystem => operatingsystem,
384             :operatingsystemrelease => operatingsystemrelease,
385             :operatingsystemmajrelease => operatingsystemmajrelease,
386             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
387           }}
388
389           let(:params) {{
390               :install_method => 'tarball',
391               :tarball_url => tarball_url,
392               :unitfile_url => unitfile_url,
393           }}
394
395           # Run shared tests applicable to all supported OSs
396           # Note that this function is defined in spec_helper
397           generic_tests
398
399           # Run test that specialize in checking tarball-based installs
400           # Note that this function is defined in spec_helper
401           tarball_install_tests(tarball_url: tarball_url, unitfile_url: unitfile_url)
402         end
403       end
404     end
405   end
406 end