Parametrize the logging pattern to use
[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: '1GB')
89
90       # Call specialized helper fn for log settings validations
91       log_settings_validations(log_max_size: '1GB')
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: 3)
97
98       # Call specialized helper fn for log settings validations
99       log_settings_validations(log_max_rollover: 3)
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: '1GB',
105                   log_max_rollover: 3,
106                   log_rollover_fileIndex: 'min')
107
108       # Call specialized helper fn for log settings validations
109       log_settings_validations(log_max_size: '1GB',
110                                log_max_rollover: 3,
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 console' do
123       # Call specialized helper fn to install OpenDaylight
124       install_odl(log_mechanism: 'console')
125
126       # Call specialized helper fn for log settings validations
127       log_settings_validations(log_mechanism: 'console')
128     end
129
130     context 'log to console customizing pattern' do
131       # Call specialized helper fn to install OpenDaylight
132       install_odl(log_mechanism: 'console',
133                   log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
134
135       # Call specialized helper fn for log settings validations
136       log_settings_validations(log_mechanism: 'console',
137                                log_pattern: '%d{ISO8601} | %-5p | %-16t | %m%n')
138     end
139   end
140
141   describe 'testing REST port config file' do
142     context 'using default port' do
143       # Call specialized helper fn to install OpenDaylight
144       install_odl
145
146       # Call specialized helper fn for REST port config validations
147       port_config_validations
148     end
149
150     context 'overriding default port' do
151       # Call specialized helper fn to install OpenDaylight
152       install_odl(odl_rest_port: 7777)
153
154       # Call specialized helper fn for REST port config validations
155       port_config_validations(odl_rest_port: 7777)
156     end
157   end
158
159   describe 'testing binding ODL to an IP' do
160     install_odl(odl_bind_ip: '127.0.0.1')
161     context 'using specific IP for ODL' do
162       odl_bind_ip_validation(odl_bind_ip: '127.0.0.1')
163     end
164   end
165
166   describe 'testing custom logging verbosity' do
167     context 'using default log levels' do
168       # Call specialized helper fn to install OpenDaylight
169       install_odl
170
171       # Call specialized helper fn for custom logger verbosity validations
172       log_level_validations
173     end
174
175     context 'adding one custom log level' do
176       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE' }
177
178       # Call specialized helper fn to install OpenDaylight
179       install_odl(log_levels: custom_log_levels)
180
181       # Call specialized helper fn for custom logger verbosity validations
182       log_level_validations(log_levels: custom_log_levels)
183     end
184
185     context 'adding two custom log level' do
186       custom_log_levels = { 'org.opendaylight.ovsdb' => 'TRACE',
187                             'org.opendaylight.ovsdb.lib' => 'INFO' }
188
189       # Call specialized helper fn to install OpenDaylight
190       install_odl(log_levels: custom_log_levels)
191
192       # Call specialized helper fn for custom logger verbosity validations
193       log_level_validations(log_levels: custom_log_levels)
194     end
195   end
196
197   describe 'testing odl username/password' do
198     bind_ip = '127.0.0.1'
199     context 'using default username/password' do
200     context 'using non-default bind ip' do
201       # Call specialized helper fn to install OpenDaylight
202       install_odl({:odl_bind_ip => bind_ip, :extra_features => ['odl-restconf']})
203
204       # Call specialized helper fn for username/password validations
205       #username_password_validations
206     end
207     end
208   end
209
210   describe 'testing odl HA configuration' do
211     bind_ip = '127.0.0.1'
212     odl_ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3']
213     context 'using default modules' do
214       install_odl(odl_bind_ip: bind_ip, enable_ha: true, ha_node_ips: odl_ips)
215
216       enable_ha_validations(odl_bind_ip: bind_ip, enable_ha: true,
217                             ha_node_ips: odl_ips)
218     end
219
220     context 'specifying datastore modules' do
221       db_modules = {
222         'default' => false,
223         'topology' => 'urn:opendaylight:topology'
224       }
225       install_odl(odl_bind_ip: bind_ip, enable_ha: true, ha_node_ips: odl_ips,
226                   ha_db_modules: db_modules)
227       enable_ha_validations(odl_bind_ip: bind_ip, enable_ha: true,
228                             ha_node_ips: odl_ips, ha_db_modules: db_modules)
229     end
230   end
231
232   describe 'testing configuring SNAT' do
233     context 'using default SNAT mechanism' do
234       # Call specialized helper fn to install OpenDaylight
235       install_odl(extra_features: ['odl-netvirt-openstack'])
236
237       # Call specialized helper fn for SNAT config validations
238       snat_mechanism_validations
239     end
240
241     context 'using conntrack SNAT' do
242       # Call specialized helper fn to install OpenDaylight
243       install_odl(extra_features: ['odl-netvirt-openstack'], snat_mechanism: 'conntrack')
244
245       # Call specialized helper fn for SNAT mechanism validations
246       snat_mechanism_validations(snat_mechanism: 'conntrack')
247     end
248   end
249
250   describe 'testing configuring SFC' do
251     context 'not using SFC feature' do
252       # Call specialized helper fn to install OpenDaylight
253       install_odl
254
255       # Call specialized helper fn for SFC config validations
256       sfc_validations
257     end
258
259     context 'using SFC feature' do
260       # Call specialized helper fn to install OpenDaylight
261       install_odl(extra_features: ['odl-netvirt-sfc'])
262
263       # Call specialized helper fn for SFC config validations
264       sfc_validations(extra_features: ['odl-netvirt-sfc'])
265     end
266   end
267
268   describe 'testing configuring tos value for DSCP marking' do
269     context 'not enabling DSCP marking' do
270       # Call specialized helper fn to install OpenDaylight
271       install_odl
272
273       # Call specialized helper fn for SFC config validations
274       dscp_validations
275     end
276
277     context 'enabling DSCP marking' do
278       # Call specialized helper fn to install OpenDaylight
279       install_odl(inherit_dscp_marking: true)
280
281       # Call specialized helper fn for SFC config validations
282       dscp_validations(inherit_dscp_marking: true)
283     end
284   end
285
286   describe 'testing websocket address config' do
287     context 'using default ip' do
288       # Call specialized helper fn to install OpenDaylight
289       install_odl
290
291       # Call specialized helper fn for websocket address config validations
292       websocket_address_validations
293     end
294
295     context 'overriding default ip' do
296       # Call specialized helper fn to install OpenDaylight
297       install_odl(odl_bind_ip: '127.0.0.1')
298
299       # Call specialized helper fn for websocket address config validations
300       websocket_address_validations(odl_bind_ip: '127.0.0.1')
301     end
302   end
303
304   describe 'testing enabling TLS' do
305     context 'with self-signed key/cert creation' do
306       install_odl(enable_tls: true, tls_keystore_password: '123456')
307
308       # Call specialized helper fn for TLS config validations
309       tls_validations(enable_tls: true, tls_keystore_password: '123456')
310     end
311   end
312
313   describe 'testing stats polling enablement' do
314     context 'with polling enabled' do
315       # Call specialized helper fn to install OpenDaylight
316       install_odl(stats_polling_enabled: true)
317
318       # Call specialized helper fn for polling enablement validations
319       stats_polling_validations(stats_polling_enabled: true)
320     end
321
322     context 'with polling disabled' do
323       # Call specialized helper fn to install OpenDaylight
324       install_odl
325
326       # Call specialized helper fn for polling enablement validations
327       stats_polling_validations
328     end
329   end
330
331   describe 'testing different IPv deployments' do
332     context 'IPv6 support tests' do
333       # Call specialized helper fn to install OpenDaylight
334       install_odl(odl_bind_ip: '::1')
335
336       # Call specialized helper fn for polling enablement validations
337       generic_validations(odl_bind_ip: '::1')
338     end
339
340     context 'IPv4 support test' do
341       # Call specialized helper fn to install OpenDaylight
342       install_odl(odl_bind_ip: '127.0.0.1')
343
344       # Call specialized helper fn for polling enablement validations
345       generic_validations(odl_bind_ip: '127.0.0.1')
346     end
347   end
348
349   describe 'testing passing extra java option' do
350     context 'pass java heap size' do
351       # Call specialized helper fn to install OpenDaylight
352       install_odl(java_opts: '-Xmx8192m')
353
354       # Call specialized helper fn for polling enablement validations
355       generic_validations(java_opts: '-Xmx8192m')
356     end
357   end
358
359   describe 'testing configuring inactivity probe' do
360     context 'with specifying inactivity probe timer' do
361       # Call specialized helper fn to install OpenDaylight
362       install_odl(inactivity_probe: 99999)
363
364       # Call specialized helper fn for probe validations
365       inactivity_probe_validations(inactivity_probe: 99999)
366     end
367   end
368 end