Binds OpenFlow and OVSDB IPs
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper_acceptance.rb
1 require 'beaker-rspec/spec_helper'
2 require 'beaker-rspec/helpers/serverspec'
3 require 'beaker-puppet'
4
5 include Beaker::DSL::InstallUtils::FOSSUtils
6 include Beaker::DSL::InstallUtils::ModuleUtils
7 include Beaker::DSL::Helpers::PuppetHelpers
8
9 # Install Puppet on all Beaker hosts
10 unless ENV['BEAKER_provision'] == 'no'
11   hosts.each do |host|
12     # Install Puppet
13     install_puppet_agent_on(host, {:puppet_collection => "pc1"})
14   end
15 end
16
17 RSpec.configure do |c|
18   # Project root
19   proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
20
21   # Readable test descriptions
22   c.formatter = :documentation
23
24   # Configure all nodes in nodeset
25   c.before :suite do
26     # Install opendaylight module on any/all Beaker hosts
27     # TODO: Should this be done in host.each loop?
28     puppet_module_install(:source => proj_root, :module_name => 'opendaylight')
29     hosts.each do |host|
30       # Install stdlib, a dependency of the odl mod
31       on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0] }
32       # Install apt, a dependency of the deb install method
33       on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0] }
34     end
35   end
36 end
37
38 #
39 # NB: These are a library of helper fns used by the Beaker tests
40 #
41
42 # NB: There are a large number of helper functions used in these tests.
43 # They make this code much more friendly, but may need to be referenced.
44 # The serverspec helpers (`should`, `be_running`...) are documented here:
45 #   http://serverspec.org/resource_types.html
46
47 def install_odl(options = {})
48   # Install params are passed via environment var, set in Rakefile
49   # Changing the installed version of ODL via `puppet apply` is not supported
50   # by puppet-odl, so it's not possible to vary these params in the same
51   # Beaker test run. Do a different run passing different env vars.
52   rpm_repo = ENV['RPM_REPO']
53   deb_repo = ENV['DEB_REPO']
54
55   # NB: These param defaults should match the ones used by the opendaylight
56   #   class, which are defined in opendaylight::params
57   # TODO: Remove this possible source of bugs^^
58   # Extract params if given, defaulting to odl class defaults if not
59   extra_features = options.fetch(:extra_features, ['odl-restconf'])
60   default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
61   odl_rest_port = options.fetch(:odl_rest_port, 8181)
62   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
63   log_levels = options.fetch(:log_levels, {})
64   enable_ha = options.fetch(:enable_ha, false)
65   ha_node_ips = options.fetch(:ha_node_ips, [])
66   ha_node_index = options.fetch(:ha_node_index, 0)
67   ha_db_modules = options.fetch(:ha_db_modules, { 'default' => false })
68   username = options.fetch(:username, 'admin')
69   password = options.fetch(:password, 'admin')
70   log_max_size = options.fetch(:log_max_size, '10GB')
71   log_max_rollover = options.fetch(:log_max_rollover, 2)
72   log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
73   snat_mechanism = options.fetch(:snat_mechanism, 'controller')
74   enable_tls = options.fetch(:enable_tls, false)
75   tls_keystore_password = options.fetch(:tls_keystore_password, 'dummypass')
76   log_mechanism = options.fetch(:log_mechanism, 'file')
77   inherit_dscp_marking = options.fetch(:inherit_dscp_marking, false)
78   stats_polling_enabled = options.fetch(:stats_polling_enabled, false)
79
80   # Build script for consumption by Puppet apply
81   it 'should work idempotently with no errors' do
82     pp = <<-EOS
83     class { 'opendaylight':
84       rpm_repo => '#{rpm_repo}',
85       deb_repo => '#{deb_repo}',
86       default_features => #{default_features},
87       extra_features => #{extra_features},
88       odl_rest_port => #{odl_rest_port},
89       odl_bind_ip => '#{odl_bind_ip}',
90       enable_ha => #{enable_ha},
91       ha_node_ips => #{ha_node_ips},
92       ha_node_index => #{ha_node_index},
93       ha_db_modules => #{ha_db_modules},
94       log_levels => #{log_levels},
95       username => #{username},
96       password => #{password},
97       log_max_size => '#{log_max_size}',
98       log_max_rollover => #{log_max_rollover},
99       log_rollover_fileindex => #{log_rollover_fileindex},
100       snat_mechanism => #{snat_mechanism},
101       enable_tls => #{enable_tls},
102       tls_keystore_password => #{tls_keystore_password},
103       log_mechanism => #{log_mechanism},
104       inherit_dscp_marking => #{inherit_dscp_marking},
105       stats_polling_enabled => #{stats_polling_enabled},
106     }
107     EOS
108
109     # Apply our Puppet manifest on the Beaker host
110     apply_manifest(pp, :catch_failures => true)
111
112     # Not checking for idempotence because of false failures
113     # related to package manager cache updates outputting to
114     # stdout and different IDs for the puppet manifest apply.
115     # I think this is a limitation in how Beaker can check
116     # for changes, not a problem with the Puppet module.
117     end
118 end
119
120 # Shared function that handles generic validations
121 # These should be common for all odl class param combos
122 def generic_validations(options = {})
123   java_opts = options.fetch(:java_opts, [])
124   # Verify ODL's directory
125   describe file('/opt/opendaylight/') do
126     it { should be_directory }
127     it { should be_owned_by 'odl' }
128     it { should be_grouped_into 'odl' }
129   end
130
131   # Verify ODL's systemd service
132   describe service('opendaylight') do
133     it { should be_enabled }
134     it { should be_enabled.with_level(3) }
135     it { should be_running.under('systemd') }
136   end
137
138   # Creation handled by RPM or Deb
139   describe user('odl') do
140     it { should exist }
141     it { should belong_to_group 'odl' }
142     # NB: This really shouldn't have a slash at the end!
143     #     The home dir set by the RPM is `/opt/opendaylight`.
144     #     Since we use the trailing slash elsewhere else, this
145     #     may look like a style issue. It isn't! It will make
146     #     Beaker tests fail if it ends with a `/`. A future
147     #     version of the ODL RPM may change this.
148     it { should have_home_directory '/opt/opendaylight' }
149   end
150
151   # Creation handled by RPM or Deb
152   describe group('odl') do
153     it { should exist }
154   end
155
156   # This should not be the odl user's home dir
157   describe file('/home/odl') do
158     # Home dir shouldn't be created for odl user
159     it { should_not be_directory }
160   end
161
162   # OpenDaylight will appear as a Java process
163   describe process('java') do
164     it { should be_running }
165   end
166
167   # Should contain Karaf features config file
168   describe file('/opt/opendaylight/etc/org.apache.karaf.features.cfg') do
169     it { should be_file }
170     it { should be_owned_by 'odl' }
171     it { should be_grouped_into 'odl' }
172   end
173
174   odl_bind_ip = options.fetch(:odl_bind_ip, '127.0.0.1')
175   if odl_bind_ip == '127.0.0.1'
176     java_options = ['-Djava.net.preferIPv4Stack=true'] + java_opts
177   else
178     java_options = ['-Djava.net.preferIPv6Addresses=true'] + java_opts
179   end
180
181   # Should contain karaf file with Java options set
182   describe file('/opt/opendaylight/bin/karaf') do
183     it { should be_file }
184     it { should be_owned_by 'odl' }
185     it { should be_grouped_into 'odl' }
186     its(:content) { should match /^EXTRA_JAVA_OPTS=#{java_options.join(" ")}/ }
187   end
188
189   # Should contain ODL NB port config file
190   describe file('/opt/opendaylight/etc/jetty.xml') do
191     it { should be_file }
192     it { should be_owned_by 'odl' }
193     it { should be_grouped_into 'odl' }
194   end
195
196   # Should contain log level config file
197   describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
198     it { should be_file }
199     it { should be_owned_by 'odl' }
200     it { should be_grouped_into 'odl' }
201   end
202
203   if ['centos-7', 'centos-7-docker'].include? ENV['RS_SET']
204     # Validations for modern Red Hat family OSs
205
206     # Verify ODL systemd .service file
207     describe file('/usr/lib/systemd/system/opendaylight.service') do
208       it { should be_file }
209       it { should be_owned_by 'root' }
210       it { should be_grouped_into 'root' }
211       it { should be_mode '644' }
212     end
213
214     # Java 8 should be installed
215     describe package('java-1.8.0-openjdk') do
216       it { should be_installed }
217     end
218
219   # Ubuntu 16.04 specific validation
220   elsif ['ubuntu-16', 'ubuntu-16-docker'].include? ENV['RS_SET']
221
222     # Verify ODL systemd .service file
223     describe file('/lib/systemd/system/opendaylight.service') do
224       it { should be_file }
225       it { should be_owned_by 'root' }
226       it { should be_grouped_into 'root' }
227       it { should be_mode '644' }
228     end
229
230     # Java 8 should be installed
231     describe package('openjdk-8-jre-headless') do
232       it { should be_installed }
233     end
234
235   else
236     fail("Unexpected RS_SET (host OS): #{ENV['RS_SET']}")
237   end
238 end
239
240 # Shared function for validations related to log file settings
241 def log_settings_validations(options = {})
242   # Should contain log level config file with correct file size and rollover values
243   log_max_size = options.fetch(:log_max_size, '10GB')
244   log_max_rollover = options.fetch(:log_max_rollover, 2)
245   log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
246   log_mechanism = options.fetch(:log_mechanism, 'file')
247
248   if log_mechanism == 'console'
249     describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
250       it { should be_file }
251       it { should be_owned_by 'odl' }
252       it { should be_grouped_into 'odl' }
253       its(:content) { should match /^karaf.log.console=INFO/ }
254       its(:content) { should match /^log4j2.appender.console.direct = true/ }
255     end
256   else
257     describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
258       it { should be_file }
259       it { should be_owned_by 'odl' }
260       it { should be_grouped_into 'odl' }
261       its(:content) { should match /^log4j2.appender.rolling.policies.size.size = #{log_max_size}/ }
262       its(:content) { should match /^log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy/ }
263       its(:content) { should match /^log4j2.appender.rolling.strategy.max = #{log_max_rollover}/ }
264       its(:content) { should match /^log4j2.appender.rolling.strategy.fileIndex = #{log_rollover_fileindex}/ }
265     end
266   end
267 end
268
269 # Shared function for validations related to the Karaf config file
270 def karaf_config_validations(options = {})
271   # NB: These param defaults should match the ones used by the opendaylight
272   #   class, which are defined in opendaylight::params
273   # TODO: Remove this possible source of bugs^^
274   extra_features = options.fetch(:extra_features, [])
275   default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
276
277   # Create one list of all of the features
278   features = default_features + extra_features
279
280   describe file('/opt/opendaylight/etc/org.apache.karaf.features.cfg') do
281     it { should be_file }
282     it { should be_owned_by 'odl' }
283     it { should be_grouped_into 'odl' }
284     its(:content) { should match /^featuresBoot=#{features.join(",")}/ }
285   end
286 end
287
288 # Shared function for validations related to the ODL REST port config file
289 def port_config_validations(options = {})
290   # NB: This param default should match the one used by the opendaylight
291   #   class, which is defined in opendaylight::params
292   # TODO: Remove this possible source of bugs^^
293   odl_rest_port = options.fetch(:odl_rest_port, 8181)
294
295   describe file('/opt/opendaylight/etc/jetty.xml') do
296     it { should be_file }
297     it { should be_owned_by 'odl' }
298     it { should be_grouped_into 'odl' }
299     its(:content) { should match /Property name="jetty.port" default="#{odl_rest_port}"/ }
300   end
301
302   describe file('/opt/opendaylight/etc/org.ops4j.pax.web.cfg') do
303     it { should be_file }
304     it { should be_owned_by 'odl' }
305     it { should be_grouped_into 'odl' }
306     its(:content) { should match /org.osgi.service.http.port = #{odl_rest_port}/ }
307   end
308 end
309
310 # Shared function for validations related to the ODL bind IP
311 def odl_bind_ip_validation(options = {})
312   # NB: This param default should match the one used by the opendaylight
313   #   class, which is defined in opendaylight::params
314   # TODO: Remove this possible source of bugs^^
315   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
316
317   if odl_bind_ip != '0.0.0.0'
318     describe file('/opt/opendaylight/etc/org.apache.karaf.shell.cfg') do
319       it { should be_file }
320       it { should be_owned_by 'odl' }
321       it { should be_grouped_into 'odl' }
322       its(:content) { should match /sshHost = #{odl_bind_ip}/ }
323     end
324
325     describe file('/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg') do
326       it { should be_file }
327       it { should be_owned_by 'odl' }
328       it { should be_grouped_into 'odl' }
329       its(:content) { should match /ovsdb-listener-ip = #{odl_bind_ip}/ }
330     end
331
332     describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml') do
333       it { should be_file }
334       it { should be_owned_by 'odl' }
335       it { should be_grouped_into 'odl' }
336       its(:content) { should match /<address>#{odl_bind_ip}<\/address>/ }
337     end
338
339     describe command("loop_count=0; until [[ \$loop_count -ge 30 ]]; do netstat -punta | grep 8101 | grep #{odl_bind_ip} && break; loop_count=\$[\$loop_count+1]; sleep 1; done; echo \"Waited \$loop_count seconds to detect ODL karaf bound to IP\"") do
340       its(:exit_status) { should eq 0 }
341     end
342
343     describe command("loop_count=0; until [[ \$loop_count -ge 60 ]]; do netstat -punta | grep 6653 | grep #{odl_bind_ip} && break; loop_count=\$[\$loop_count+1]; sleep 1; done; echo \"Waited \$loop_count seconds to detect ODL karaf bound to IP\"") do
344       its(:exit_status) { should eq 0 }
345     end
346
347     describe command("loop_count=0; until [[ \$loop_count -ge 60 ]]; do netstat -punta | grep 6640 | grep #{odl_bind_ip} && break; loop_count=\$[\$loop_count+1]; sleep 1; done; echo \"Waited \$loop_count seconds to detect ODL karaf bound to IP\"") do
348       its(:exit_status) { should eq 0 }
349     end
350   end
351 end
352
353 # Shared function for validations related to custom logging verbosity
354 def log_level_validations(options = {})
355   # NB: This param default should match the one used by the opendaylight
356   #   class, which is defined in opendaylight::params
357   # TODO: Remove this possible source of bugs^^
358   log_levels = options.fetch(:log_levels, {})
359
360   if log_levels.empty?
361     # Should contain log level config file
362     describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
363       it { should be_file }
364       it { should be_owned_by 'odl' }
365       it { should be_grouped_into 'odl' }
366     end
367   else
368     # Should contain log level config file
369     describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
370       it { should be_file }
371       it { should be_owned_by 'odl' }
372       it { should be_grouped_into 'odl' }
373     end
374     # Verify each custom log level config entry
375     log_levels.each_pair do |logger, level|
376       underscored_version = "#{logger}".gsub('.', '_')
377       describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
378         it { should be_file }
379         it { should be_owned_by 'odl' }
380         it { should be_grouped_into 'odl' }
381         its(:content) { should match /^log4j2.logger.#{underscored_version}.level = #{level}/ }
382         its(:content) { should match /^log4j2.logger.#{underscored_version}.name = #{logger}/ }
383       end
384     end
385   end
386 end
387
388 # Shared function for validations related to ODL OVSDB HA config
389 def enable_ha_validations(options = {})
390   # NB: This param default should match the one used by the opendaylight
391   #   class, which is defined in opendaylight::params
392   # TODO: Remove this possible source of bugs^^
393   enable_ha = options.fetch(:enable_ha, false)
394   ha_node_ips = options.fetch(:ha_node_ips, [])
395   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
396   ha_db_modules = options.fetch(:ha_db_modules, { 'default' => false })
397   # HA_NODE_IPS size
398   ha_node_count = ha_node_ips.size
399
400   if (enable_ha) && (ha_node_count < 2)
401     # Check for HA_NODE_COUNT < 2
402     fail("Number of HA nodes less than 2: #{ha_node_count} and HA Enabled")
403   end
404
405   if enable_ha
406     ha_node_index = ha_node_ips.index(odl_bind_ip)
407     describe file('/opt/opendaylight/configuration/initial/akka.conf') do
408       it { should be_file }
409       it { should be_owned_by 'odl' }
410       it { should be_grouped_into 'odl' }
411       its(:content) { should match /roles\s*=\s*\["member-#{ha_node_index}"\]/ }
412     end
413
414     ha_db_modules.each do |mod, urn|
415       describe file('/opt/opendaylight/configuration/initial/module-shards.conf') do
416         it { should be_file }
417         it { should be_owned_by 'odl' }
418         it { should be_grouped_into 'odl' }
419         its(:content) { should match /name = "#{mod}"/ }
420       end
421
422       if mod == 'default'
423         describe file('/opt/opendaylight/configuration/initial/modules.conf') do
424           it { should be_file }
425           it { should be_owned_by 'odl' }
426           it { should be_grouped_into 'odl' }
427         end
428       else
429         describe file('/opt/opendaylight/configuration/initial/modules.conf') do
430           it { should be_file }
431           it { should be_owned_by 'odl' }
432           it { should be_grouped_into 'odl' }
433           its(:content) { should match /name = "#{mod}"/ }
434           its(:content) { should match /namespace = "#{urn}"/ }
435         end
436       end
437     end
438   end
439 end
440
441 # Shared function that handles validations specific to RPM-type installs
442 def rpm_validations()
443   rpm_repo = ENV['RPM_REPO']
444
445   describe yumrepo('opendaylight') do
446     it { should exist }
447     it { should be_enabled }
448   end
449
450   describe package('opendaylight') do
451     it { should be_installed }
452   end
453 end
454
455 # Shared function that handles validations specific to Deb-type installs
456 def deb_validations()
457   deb_repo = ENV['DEB_REPO']
458   # Check ppa
459   # Docs: http://serverspec.org/resource_types.html#ppa
460   describe ppa(deb_repo) do
461     it { should exist }
462     it { should be_enabled }
463   end
464
465   describe package('opendaylight') do
466     it { should be_installed }
467   end
468 end
469
470 # Shared function for validations related to username/password
471 def username_password_validations(options = {})
472   # NB: This param default should match the one used by the opendaylight
473   #   class, which is defined in opendaylight::params
474   # TODO: Remove this possible source of bugs^^
475   odl_username = options.fetch(:username, 'admin')
476   odl_password = options.fetch(:password, 'admin')
477   odl_check_url = 'http://127.0.0.1:8181/restconf'
478
479   describe file('/opt/opendaylight/data/idmlight.db.mv.db') do
480     it { should be_file }
481   end
482
483   describe command("loop_count=0; until [[ \$loop_count -ge 300 ]]; do curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url} && break; loop_count=\$[\$loop_count+1]; sleep 1; done; echo \"Waited \$loop_count seconds for ODL to become active\"") do
484     its(:exit_status) { should eq 0 }
485   end
486
487   describe command("curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
488     its(:exit_status) { should eq 0 }
489   end
490 end
491
492 # Shared function for validations related to the SNAT config file
493 def snat_mechanism_validations(options = {})
494   # NB: This param default should match the one used by the opendaylight
495   #   class, which is defined in opendaylight::params
496   # TODO: Remove this possible source of bugs^^
497   snat_mechanism = options.fetch(:snat_mechanism, 'controller')
498
499   describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml') do
500     it { should be_file }
501     it { should be_owned_by 'odl' }
502     it { should be_grouped_into 'odl' }
503     its(:content) { should match /<nat-mode>#{snat_mechanism}<\/nat-mode>/ }
504   end
505 end
506
507 # Shared function for validations related to SFC
508 def sfc_validations(options = {})
509   # NB: This param default should match the one used by the opendaylight
510   #   class, which is defined in opendaylight::params
511   # TODO: Remove this possible source of bugs^^
512
513   extra_features = options.fetch(:extra_features, [])
514   if extra_features.include? 'odl-netvirt-sfc'
515     sfc_enabled = true
516   else
517     sfc_enabled = false
518   end
519
520   describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml') do
521     it { should be_file }
522     it { should be_owned_by 'odl' }
523     it { should be_grouped_into 'odl' }
524     its(:content) { should match /<gpe-extension-enabled>#{sfc_enabled}<\/gpe-extension-enabled>/ }
525   end
526 end
527
528 # Shared function for validations related to tos value for DSCP marking
529 def dscp_validations(options = {})
530   # NB: This param default should match the one used by the opendaylight
531   #   class, which is defined in opendaylight::params
532   # TODO: Remove this possible source of bugs^^
533
534   inherit_dscp_marking = options.fetch(:inherit_dscp_marking, false)
535
536   if inherit_dscp_marking
537     describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml') do
538       it { should be_file }
539       it { should be_owned_by 'odl' }
540       it { should be_grouped_into 'odl' }
541       its(:content) { should match /<default-tunnel-tos>inherit<\/default-tunnel-tos>/ }
542     end
543   end
544 end
545
546 def websocket_address_validations(options = {})
547   # NB: This param default should match the one used by the opendaylight
548   #   class, which is defined in opendaylight::params
549   # TODO: Remove this possible source of bugs^^
550   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
551
552   if not odl_bind_ip.eql? '0.0.0.0'
553     describe file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg') do
554       it { should be_file }
555       it { should be_owned_by 'odl' }
556       it { should be_grouped_into 'odl' }
557       its(:content) { should match /^websocket-address=#{odl_bind_ip}/ }
558     end
559   else
560     describe file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg') do
561       it { should be_file }
562     end
563   end
564 end
565
566 def tls_validations(options = {})
567   # NB: This param default should match the one used by the opendaylight
568   #   class, which is defined in opendaylight::params
569   # TODO: Remove this possible source of bugs^^
570   tls_keystore_password = options.fetch(:tls_keystore_password)
571   odl_rest_port = options.fetch(:odl_rest_port, 8181)
572
573   describe file('/opt/opendaylight/etc/org.ops4j.pax.web.cfg') do
574     it { should be_file }
575     it { should be_owned_by 'odl' }
576     it { should be_grouped_into 'odl' }
577     its(:content) { should match /org.osgi.service.http.port.secure = #{odl_rest_port}/ }
578     its(:content) { should match /org.ops4j.pax.web.ssl.keystore = configuration\/ssl\/ctl.jks/ }
579     its(:content) { should match /org.ops4j.pax.web.ssl.password = #{tls_keystore_password}/ }
580     its(:content) { should match /org.ops4j.pax.web.ssl.keypassword = #{tls_keystore_password}/ }
581     its(:content) { should match /org.osgi.service.http.secure.enabled = true/ }
582     its(:content) { should match /org.osgi.service.http.enabled = false/ }
583   end
584
585   describe file('/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg') do
586     it { should be_file }
587     it { should be_owned_by 'odl' }
588     it { should be_grouped_into 'odl' }
589     its(:content) { should match /use-ssl = true/ }
590   end
591
592   describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml') do
593     it { should be_file }
594     it { should be_owned_by 'odl' }
595     it { should be_grouped_into 'odl' }
596     its(:content) { should match /<keystore-password>#{tls_keystore_password}<\/keystore-password>/ }
597     its(:content) { should match /<truststore-password>#{tls_keystore_password}<\/truststore-password>/ }
598     its(:content) { should match /<transport-protocol>TLS<\/transport-protocol>/ }
599   end
600
601   describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/aaa-cert-config.xml') do
602     it { should be_file }
603     it { should be_owned_by 'odl' }
604     it { should be_grouped_into 'odl' }
605     its(:content) { should match /<store-password>#{tls_keystore_password}<\/store-password>/ }
606     its(:content) { should match /<use-mdsal>false<\/use-mdsal>/ }
607   end
608
609   describe file('/opt/opendaylight/etc/jetty.xml') do
610     it { should be_file }
611     it { should be_owned_by 'odl' }
612     it { should be_grouped_into 'odl' }
613     its(:content) { should match /<Property name="jetty.secure.port" default="#{odl_rest_port}" \/>/ }
614   end
615 end
616
617 # Shared function for validations related to OVS statistics polling
618 def stats_polling_validations(options = {})
619   # NB: This param default should match the one used by the opendaylight
620   #   class, which is defined in opendaylight::params
621   # TODO: Remove this possible source of bugs^^
622
623   stats_polling_enabled = options.fetch(:stats_polling_enabled, false)
624   describe file('/opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg') do
625     it { should be_file }
626     it { should be_owned_by 'odl' }
627     it { should be_grouped_into 'odl' }
628     its(:content) { should match /is-statistics-polling-on=#{stats_polling_enabled}/ }
629   end
630 end