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