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