635298d9b519168e6b34c7f7f3db073e2128a13f
[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       default_features = ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management']
109       context 'and not passing extra features' do
110         let(:facts) {{
111           :osfamily => osfamily,
112           :operatingsystem => operatingsystem,
113           :operatingsystemmajrelease => operatingsystemmajrelease,
114         }}
115
116         let(:params) {{ }}
117
118         # Run shared tests applicable to all supported OSs
119         # Note that this function is defined in spec_helper
120         generic_tests(yum_repo)
121
122         # Run test that specialize in checking Karaf feature installs
123         # Note that this function is defined in spec_helper
124         karaf_feature_tests(default_features)
125       end
126
127       context 'and passing extra features' do
128         let(:facts) {{
129           :osfamily => osfamily,
130           :operatingsystem => operatingsystem,
131           :operatingsystemmajrelease => operatingsystemmajrelease,
132         }}
133
134         # These are real but arbitrarily chosen features
135         extra_features = ['odl-base-all', 'odl-ovsdb-all']
136         let(:params) {{
137           :extra_features => extra_features,
138         }}
139
140         # Run shared tests applicable to all supported OSs
141         # Note that this function is defined in spec_helper
142         generic_tests(yum_repo)
143
144         # Run test that specialize in checking Karaf feature installs
145         # Note that this function is defined in spec_helper
146         karaf_feature_tests(default_features + extra_features)
147       end
148     end
149
150     describe 'overriding default features' do
151       default_features = ['standard', 'ssh']
152       context 'and not passing extra features' do
153         let(:facts) {{
154           :osfamily => osfamily,
155           :operatingsystem => operatingsystem,
156           :operatingsystemmajrelease => operatingsystemmajrelease,
157         }}
158
159         let(:params) {{
160           :default_features => default_features,
161         }}
162
163         # Run shared tests applicable to all supported OSs
164         # Note that this function is defined in spec_helper
165         generic_tests(yum_repo)
166
167         # Run test that specialize in checking Karaf feature installs
168         # Note that this function is defined in spec_helper
169         karaf_feature_tests(default_features)
170       end
171
172       context 'and passing extra features' do
173         let(:facts) {{
174           :osfamily => osfamily,
175           :operatingsystem => operatingsystem,
176           :operatingsystemmajrelease => operatingsystemmajrelease,
177         }}
178
179         # These are real but arbitrarily chosen features
180         extra_features = ['odl-base-all', 'odl-ovsdb-all']
181         let(:params) {{
182           :default_features => default_features,
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(yum_repo)
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(default_features + extra_features)
193       end
194     end
195   end
196
197   # All install method tests
198   describe 'install method tests' do
199     # Non-OS-type tests assume CentOS 7
200     #   See issue #43 for reasoning:
201     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
202     osfamily = 'RedHat'
203     operatingsystem = 'CentOS'
204     operatingsystemmajrelease = '7'
205     # This is the CentOS 7 Yum repo URL
206     yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
207
208     # All tests for RPM install method
209     context 'RPM' do
210       let(:facts) {{
211         :osfamily => osfamily,
212         :operatingsystem => operatingsystem,
213         :operatingsystemmajrelease => operatingsystemmajrelease,
214       }}
215
216       let(:params) {{
217           :install_method => 'rpm',
218       }}
219
220       # Run shared tests applicable to all supported OSs
221       # Note that this function is defined in spec_helper
222       generic_tests(yum_repo)
223
224       # Run test that specialize in checking Karaf feature installs
225       # Note that this function is defined in spec_helper
226       install_method_tests('rpm', yum_repo)
227     end
228
229     # All tests for tarball install method
230     describe 'tarball' do
231       describe 'using default tarball_url' do
232         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'
233         context 'using default unitfile_url' do
234           unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
235           let(:facts) {{
236             :osfamily => osfamily,
237             :operatingsystem => operatingsystem,
238             :operatingsystemmajrelease => operatingsystemmajrelease,
239           }}
240
241           let(:params) {{
242               :install_method => 'tarball',
243           }}
244
245           # Run shared tests applicable to all supported OSs
246           # Note that this function is defined in spec_helper
247           generic_tests(yum_repo)
248
249           # Run test that specialize in checking Karaf feature installs
250           # Note that this function is defined in spec_helper
251           install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
252         end
253       end
254     end
255   end
256 end