Add $::path fact to tests, required by archive mod
[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(yum_repo)
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(yum_repo)
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 unsupported OS families
83     ['Debian', 'Suse', 'Solaris'].each do |osfamily|
84       context "OS family #{osfamily}" do
85         let(:facts) {{
86           :osfamily => osfamily,
87         }}
88
89         # Run shared tests applicable to all unsupported OSs
90         # Note that this function is defined in spec_helper
91         unsupported_os_tests("Unsupported OS family: #{osfamily}")
92       end
93     end
94   end
95
96   # All Karaf feature tests
97   describe 'Karaf feature tests' do
98     # Non-OS-type tests assume CentOS 7
99     #   See issue #43 for reasoning:
100     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
101     osfamily = 'RedHat'
102     operatingsystem = 'CentOS'
103     operatingsystemmajrelease = '7'
104     # This is the CentOS 7 Yum repo URL
105     yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
106     describe 'using default features' do
107       # NB: This list should be the same as the one in opendaylight::params
108       # TODO: Remove this possible source of bugs^^
109       default_features = ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management']
110       context 'and not passing extra features' do
111         let(:facts) {{
112           :osfamily => osfamily,
113           :operatingsystem => operatingsystem,
114           :operatingsystemmajrelease => operatingsystemmajrelease,
115         }}
116
117         let(:params) {{ }}
118
119         # Run shared tests applicable to all supported OSs
120         # Note that this function is defined in spec_helper
121         generic_tests(yum_repo)
122
123         # Run test that specialize in checking Karaf feature installs
124         # Note that this function is defined in spec_helper
125         karaf_feature_tests(default_features)
126       end
127
128       context 'and passing extra features' do
129         let(:facts) {{
130           :osfamily => osfamily,
131           :operatingsystem => operatingsystem,
132           :operatingsystemmajrelease => operatingsystemmajrelease,
133         }}
134
135         # These are real but arbitrarily chosen features
136         extra_features = ['odl-base-all', 'odl-ovsdb-all']
137         let(:params) {{
138           :extra_features => extra_features,
139         }}
140
141         # Run shared tests applicable to all supported OSs
142         # Note that this function is defined in spec_helper
143         generic_tests(yum_repo)
144
145         # Run test that specialize in checking Karaf feature installs
146         # Note that this function is defined in spec_helper
147         karaf_feature_tests(default_features + extra_features)
148       end
149     end
150
151     describe 'overriding default features' do
152       default_features = ['standard', 'ssh']
153       context 'and not passing extra features' do
154         let(:facts) {{
155           :osfamily => osfamily,
156           :operatingsystem => operatingsystem,
157           :operatingsystemmajrelease => operatingsystemmajrelease,
158         }}
159
160         let(:params) {{
161           :default_features => default_features,
162         }}
163
164         # Run shared tests applicable to all supported OSs
165         # Note that this function is defined in spec_helper
166         generic_tests(yum_repo)
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(default_features)
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           :default_features => default_features,
184           :extra_features => extra_features,
185         }}
186
187         # Run shared tests applicable to all supported OSs
188         # Note that this function is defined in spec_helper
189         generic_tests(yum_repo)
190
191         # Run test that specialize in checking Karaf feature installs
192         # Note that this function is defined in spec_helper
193         karaf_feature_tests(default_features + extra_features)
194       end
195     end
196   end
197
198   # All install method tests
199   describe 'install method tests' do
200     # Non-OS-type tests assume CentOS 7
201     #   See issue #43 for reasoning:
202     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
203     osfamily = 'RedHat'
204     operatingsystem = 'CentOS'
205     operatingsystemmajrelease = '7'
206     # This is the CentOS 7 Yum repo URL
207     yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
208
209     # All tests for RPM install method
210     context 'RPM' do
211       let(:facts) {{
212         :osfamily => osfamily,
213         :operatingsystem => operatingsystem,
214         :operatingsystemmajrelease => operatingsystemmajrelease,
215       }}
216
217       let(:params) {{
218           :install_method => 'rpm',
219       }}
220
221       # Run shared tests applicable to all supported OSs
222       # Note that this function is defined in spec_helper
223       generic_tests(yum_repo)
224
225       # Run test that specialize in checking Karaf feature installs
226       # Note that this function is defined in spec_helper
227       install_method_tests('rpm', yum_repo)
228     end
229
230     # All tests for tarball install method
231     describe 'tarball' do
232       describe 'using default tarball_url' do
233         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'
234         context 'using default unitfile_url' do
235           unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
236           let(:facts) {{
237             :osfamily => osfamily,
238             :operatingsystem => operatingsystem,
239             :operatingsystemmajrelease => operatingsystemmajrelease,
240             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
241           }}
242
243           let(:params) {{
244               :install_method => 'tarball',
245           }}
246
247           # Run shared tests applicable to all supported OSs
248           # Note that this function is defined in spec_helper
249           generic_tests(yum_repo)
250
251           # Run test that specialize in checking Karaf feature installs
252           # Note that this function is defined in spec_helper
253           install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
254         end
255
256         context 'overriding default unitfile_url' do
257           # Doesn't matter if this is valid, just that it honors what we pass
258           unitfile_url = 'fake_unitfile'
259           let(:facts) {{
260             :osfamily => osfamily,
261             :operatingsystem => operatingsystem,
262             :operatingsystemmajrelease => operatingsystemmajrelease,
263             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
264           }}
265
266           let(:params) {{
267               :install_method => 'tarball',
268               :unitfile_url => unitfile_url,
269           }}
270
271           # Run shared tests applicable to all supported OSs
272           # Note that this function is defined in spec_helper
273           generic_tests(yum_repo)
274
275           # Run test that specialize in checking Karaf feature installs
276           # Note that this function is defined in spec_helper
277           install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
278         end
279       end
280
281       describe 'overriding default tarball_url' do
282         # Doesn't matter if this is valid, just that it honors what we pass
283         tarball_url = 'fake_tarball'
284         context 'using default unitfile_url' do
285           unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
286           let(:facts) {{
287             :osfamily => osfamily,
288             :operatingsystem => operatingsystem,
289             :operatingsystemmajrelease => operatingsystemmajrelease,
290             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
291           }}
292
293           let(:params) {{
294               :install_method => 'tarball',
295               :tarball_url => tarball_url,
296           }}
297
298           # Run shared tests applicable to all supported OSs
299           # Note that this function is defined in spec_helper
300           generic_tests(yum_repo)
301
302           # Run test that specialize in checking Karaf feature installs
303           # Note that this function is defined in spec_helper
304           install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
305         end
306
307         context 'overriding default unitfile_url' do
308           # Doesn't matter if this is valid, just that it honors what we pass
309           unitfile_url = 'fake_unitfile'
310           let(:facts) {{
311             :osfamily => osfamily,
312             :operatingsystem => operatingsystem,
313             :operatingsystemmajrelease => operatingsystemmajrelease,
314             :path => ['/usr/local/bin', '/usr/bin', '/bin'],
315           }}
316
317           let(:params) {{
318               :install_method => 'tarball',
319               :tarball_url => tarball_url,
320               :unitfile_url => unitfile_url,
321           }}
322
323           # Run shared tests applicable to all supported OSs
324           # Note that this function is defined in spec_helper
325           generic_tests(yum_repo)
326
327           # Run test that specialize in checking Karaf feature installs
328           # Note that this function is defined in spec_helper
329           install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
330         end
331       end
332     end
333   end
334 end