Merge "Bump Puppet version 4.x to 5.x"
[integration/packaging/puppet-opendaylight.git] / spec / acceptance / class_spec.rb
1 require 'spec_helper_acceptance'
2
3 # NB: There are a large number of helper functions used in these tests.
4 # They make this code much more friendly, but may need to be referenced.
5 #   The serverspec helpers (`should`, `be_running`...) are documented here:
6 #     http://serverspec.org/resource_types.html
7 #   Custom helpers (`install_odl`, `*_validations`) are in:
8 #     <this module>/spec/spec_helper_acceptance.rb
9
10 describe 'opendaylight class' do
11   describe 'testing install methods' do
12     # Call specialized helper fn to install OpenDaylight
13     install_odl
14
15     # Run checks specific to install type, via env var passed from Rakefile
16     if :osfamily == 'RedHat'
17       # Call specialized helper fn for RPM-type install validations
18       rpm_validations
19     elsif :osfamily == 'Debian'
20       # Call specialized helper fn for Deb-type install validations
21       deb_validations
22     end
23
24     # Use helper fn to run generic validations
25     generic_validations
26   end
27
28   describe 'testing Karaf config file' do
29     describe 'using default features' do
30       context 'and not passing extra features' do
31         # Call specialized helper fn to install OpenDaylight
32         install_odl
33
34         # Call specialized helper fn for Karaf config validations
35         karaf_config_validations
36       end
37
38       context 'and passing extra features' do
39         # These are real but arbitrarily chosen features
40         extra_features = ['odl-base-all', 'odl-ovsdb-all']
41
42         # Call specialized helper fn to install OpenDaylight
43         install_odl(extra_features: extra_features)
44
45         # Call specialized helper fn for Karaf config validations
46         karaf_config_validations(extra_features: extra_features)
47       end
48     end
49
50     describe 'overriding default features' do
51       # These are real but arbitrarily chosen features
52       default_features = ['standard', 'ssh']
53
54       context 'and not passing extra features' do
55         # Call specialized helper fn to install OpenDaylight
56         install_odl(default_features: default_features)
57
58         # Call specialized helper fn for Karaf config validations
59         karaf_config_validations(default_features: default_features)
60       end
61
62       context 'and passing extra features' do
63         # These are real but arbitrarily chosen features
64         extra_features = ['odl-base-all', 'odl-ovsdb-all']
65
66         # Call specialized helper fn to install OpenDaylight
67         install_odl(default_features: default_features,
68                     extra_features: extra_features)
69
70         # Call specialized helper fn for Karaf config validations
71         karaf_config_validations(default_features: default_features,
72                                  extra_features: extra_features)
73       end
74     end
75   end
76
77   describe 'logging mechanism' do
78     context 'log to file using default size and rollover' do
79       # Call specialized helper fn to install OpenDaylight
80       install_odl
81
82       # Call specialized helper fn for log settings validations
83       log_settings_validations
84     end
85
86     context 'log to file customising size' do
87       # Call specialized helper fn to install OpenDaylight
88       install_odl(log_max_size: '100MB')
89
90       # Call specialized helper fn for log settings validations
91       log_settings_validations(log_max_size: '100MB')
92     end
93
94     context 'log to file customising rollover' do
95       # Call specialized helper fn to install OpenDaylight
96       install_odl(log_max_rollover: 10)
97
98       # Call specialized helper fn for log settings validations
99       log_settings_validations(log_max_rollover: 10)
100     end
101
102     context 'log to file customising size and rollover' do
103       # Call specialized helper fn to install OpenDaylight
104       install_odl(log_max_size: '250MB',
105                   log_max_rollover: 8,
106                   log_rollover_fileIndex: 'min')
107
108       # Call specialized helper fn for log settings validations
109       log_settings_validations(log_max_size: '250MB',
110                                log_max_rollover: 8,
111                                log_rollover_fileIndex: 'min')
112     end
113
114     context 'log to file customizing pattern' do
115       # Call specialized helper fn to install OpenDaylight
116       install_odl(log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
117
118       # Call specialized helper fn for log settings validations
119       log_settings_validations(log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
120     end
121
122     context 'log to file enabling the PaxOsgi appender' do
123       # Call specialized helper fn to install OpenDaylight
124       install_odl(enable_paxosgi_logger: true)
125
126       # Call specialized helper fn for log settings validations
127       log_settings_validations(enable_paxosgi_logger: true)
128     end
129
130     context 'log to file disabling the PaxOsgi appender' do
131       # Call specialized helper fn to install OpenDaylight
132       install_odl(enable_paxosgi_logger: false)
133
134       # Call specialized helper fn for log settings validations
135       log_settings_validations(enable_paxosgi_logger: false)
136     end
137
138     context 'log to console' do
139       # Call specialized helper fn to install OpenDaylight
140       install_odl(log_mechanism: 'console')
141
142       # Call specialized helper fn for log settings validations
143       log_settings_validations(log_mechanism: 'console')
144     end
145
146     context 'log to console customizing pattern' do
147       # Call specialized helper fn to install OpenDaylight
148       install_odl(log_mechanism: 'console',
149                   log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
150
151       # Call specialized helper fn for log settings validations
152       log_settings_validations(log_mechanism: 'console',
153                                log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
154     end
155
156     context 'log to console enabling the PaxOsgi appender' do
157       # Call specialized helper fn to install OpenDaylight
158       install_odl(log_mechanism: 'console',
159                   enable_paxosgi_logger: true)
160
161       # Call specialized helper fn for log settings validations
162       log_settings_validations(log_mechanism: 'console',
163                                enable_paxosgi_logger: true)
164     end
165
166     context 'log to console disabling the PaxOsgi appender' do
167       # Call specialized helper fn to install OpenDaylight
168       install_odl(log_mechanism: 'console',
169                   enable_paxosgi_logger: false)
170
171       # Call specialized helper fn for log settings validations
172       log_settings_validations(log_mechanism: 'console',
173                                enable_paxosgi_logger: false)
174     end
175   end
176
177   describe 'testing REST port config file' do
178     context 'using default port' do
179       # Call specialized helper fn to install OpenDaylight
180       install_odl
181
182       # Call specialized helper fn for REST port config validations
183       port_config_validations
184     end
185
186     context 'overriding default port' do
187       # Call specialized helper fn to install OpenDaylight
188       install_odl(odl_rest_port: 7777)
189
190       # Call specialized helper fn for REST port config validations
191       port_config_validations(odl_rest_port: 7777)
192     end
193   end
194
195   describe 'testing binding ODL to an IP' do
196     install_odl(odl_bind_ip: '127.0.0.1')
197     context 'using specific IP for ODL' do
198       odl_bind_ip_validation(odl_bind_ip: '127.0.0.1')
199     end
200   end
201
202   describe 'testing custom logging verbosity' do
203     context 'using default log levels' do
204       # Call specialized helper fn to install OpenDaylight
205       install_odl
206
207       # Call specialized helper fn for custom logger verbosity validations
208       log_level_validations
209     end
210
211     context 'adding one custom log level' do
212       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE' }
213
214       # Call specialized helper fn to install OpenDaylight
215       install_odl(log_levels: custom_log_levels)
216
217       # Call specialized helper fn for custom logger verbosity validations
218       log_level_validations(log_levels: custom_log_levels)
219     end
220
221     context 'adding two custom log level' do
222       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE',
223                             'org.opendaylight.ovsdb.lib' => 'INFO' }
224
225       # Call specialized helper fn to install OpenDaylight
226       install_odl(log_levels: custom_log_levels)
227
228       # Call specialized helper fn for custom logger verbosity validations
229       log_level_validations(log_levels: custom_log_levels)
230     end
231   end
232
233   describe 'testing odl username/password' do
234     bind_ip = '127.0.0.1'
235     context 'using default username/password' do
236     context 'using non-default bind ip' do
237       # Call specialized helper fn to install OpenDaylight
238       install_odl({:odl_bind_ip => bind_ip, :extra_features => ['odl-restconf']})
239
240       # Call specialized helper fn for username/password validations
241       #username_password_validations
242     end
243     end
244   end
245
246   describe 'testing odl HA configuration' do
247     bind_ip = '127.0.0.1'
248     odl_ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3']
249     context 'using default modules' do
250       install_odl(odl_bind_ip: bind_ip, enable_ha: true, ha_node_ips: odl_ips)
251
252       enable_ha_validations(odl_bind_ip: bind_ip, enable_ha: true,
253                             ha_node_ips: odl_ips)
254     end
255
256     context 'specifying datastore modules' do
257       db_modules = {
258         'default' => false,
259         'topology' => 'urn:opendaylight:topology'
260       }
261       install_odl(odl_bind_ip: bind_ip, enable_ha: true, ha_node_ips: odl_ips,
262                   ha_db_modules: db_modules)
263       enable_ha_validations(odl_bind_ip: bind_ip, enable_ha: true,
264                             ha_node_ips: odl_ips, ha_db_modules: db_modules)
265     end
266   end
267
268   describe 'testing configuring SNAT' do
269     context 'using default SNAT mechanism' do
270       # Call specialized helper fn to install OpenDaylight
271       install_odl(extra_features: ['odl-netvirt-openstack'])
272
273       # Call specialized helper fn for SNAT config validations
274       snat_mechanism_validations
275     end
276
277     context 'using conntrack SNAT' do
278       # Call specialized helper fn to install OpenDaylight
279       install_odl(extra_features: ['odl-netvirt-openstack'], snat_mechanism: 'conntrack')
280
281       # Call specialized helper fn for SNAT mechanism validations
282       snat_mechanism_validations(snat_mechanism: 'conntrack')
283     end
284   end
285
286   describe 'testing configuring SFC' do
287     context 'not using SFC feature' do
288       # Call specialized helper fn to install OpenDaylight
289       install_odl
290
291       # Call specialized helper fn for SFC config validations
292       sfc_validations
293     end
294
295     context 'using SFC feature' do
296       # Call specialized helper fn to install OpenDaylight
297       install_odl(extra_features: ['odl-netvirt-sfc'])
298
299       # Call specialized helper fn for SFC config validations
300       sfc_validations(extra_features: ['odl-netvirt-sfc'])
301     end
302   end
303
304   describe 'testing configuring tos value for DSCP marking' do
305     context 'not enabling DSCP marking' do
306       # Call specialized helper fn to install OpenDaylight
307       install_odl
308
309       # Call specialized helper fn for SFC config validations
310       dscp_validations
311     end
312
313     context 'enabling DSCP marking' do
314       # Call specialized helper fn to install OpenDaylight
315       install_odl(inherit_dscp_marking: true)
316
317       # Call specialized helper fn for SFC config validations
318       dscp_validations(inherit_dscp_marking: true)
319     end
320   end
321
322   describe 'testing websocket address config' do
323     context 'using default ip' do
324       # Call specialized helper fn to install OpenDaylight
325       install_odl
326
327       # Call specialized helper fn for websocket address config validations
328       websocket_address_validations
329     end
330
331     context 'overriding default ip' do
332       # Call specialized helper fn to install OpenDaylight
333       install_odl(odl_bind_ip: '127.0.0.1')
334
335       # Call specialized helper fn for websocket address config validations
336       websocket_address_validations(odl_bind_ip: '127.0.0.1')
337     end
338   end
339
340   describe 'testing enabling TLS' do
341     context 'with self-signed key/cert creation' do
342       install_odl(enable_tls: true, tls_keystore_password: '123456')
343
344       # Call specialized helper fn for TLS config validations
345       tls_validations(enable_tls: true, tls_keystore_password: '123456')
346     end
347   end
348
349   describe 'testing stats polling enablement' do
350     context 'with polling enabled' do
351       # Call specialized helper fn to install OpenDaylight
352       install_odl(stats_polling_enabled: true)
353
354       # Call specialized helper fn for polling enablement validations
355       stats_polling_validations(stats_polling_enabled: true)
356     end
357
358     context 'with polling disabled' do
359       # Call specialized helper fn to install OpenDaylight
360       install_odl
361
362       # Call specialized helper fn for polling enablement validations
363       stats_polling_validations
364     end
365   end
366
367   describe 'testing different IPv deployments' do
368     context 'IPv6 support tests' do
369       # Call specialized helper fn to install OpenDaylight
370       install_odl(odl_bind_ip: '::1')
371
372       # Call specialized helper fn for polling enablement validations
373       generic_validations(odl_bind_ip: '::1')
374     end
375
376     context 'IPv4 support test' do
377       # Call specialized helper fn to install OpenDaylight
378       install_odl(odl_bind_ip: '127.0.0.1')
379
380       # Call specialized helper fn for polling enablement validations
381       generic_validations(odl_bind_ip: '127.0.0.1')
382     end
383   end
384
385   describe 'testing passing extra java option' do
386     context 'pass java heap size' do
387       # Call specialized helper fn to install OpenDaylight
388       install_odl(java_opts: '-Xmx8192m')
389
390       # Call specialized helper fn for polling enablement validations
391       generic_validations(java_opts: '-Xmx8192m')
392     end
393   end
394
395   describe 'testing configuring inactivity probe' do
396     context 'with specifying inactivity probe timer' do
397       # Call specialized helper fn to install OpenDaylight
398       install_odl(inactivity_probe: 99999)
399
400       # Call specialized helper fn for probe validations
401       inactivity_probe_validations(inactivity_probe: 99999)
402     end
403   end
404 end