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