Binds OpenFlow and OVSDB IPs
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper.rb
1 require 'puppetlabs_spec_helper/module_spec_helper'
2 require 'rspec-puppet-facts'
3 include RspecPuppetFacts
4
5 # Customize filters to ignore 3rd-party code
6 # If the rspec coverage report shows not-our-code results, add it here
7 custom_filters = [
8 ]
9 RSpec::Puppet::Coverage.filters.push(*custom_filters)
10
11 #
12 # NB: This is a library of helper fns used by the rspec-puppet tests
13 #
14
15 # Tests that are common to all possible configurations
16 def generic_tests(options = {})
17   java_opts = options.fetch(:java_opts, '')
18   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
19
20   # Confirm that module compiles
21   it { should compile }
22   it { should compile.with_all_deps }
23
24   # Confirm presence of classes
25   it { should contain_class('opendaylight') }
26   it { should contain_class('opendaylight::params') }
27   it { should contain_class('opendaylight::install') }
28   it { should contain_class('opendaylight::config') }
29   it { should contain_class('opendaylight::post_config') }
30   it { should contain_class('opendaylight::service') }
31
32   # Confirm relationships between classes
33   it { should contain_class('opendaylight::install').that_comes_before('Class[opendaylight::config]') }
34   it { should contain_class('opendaylight::config').that_requires('Class[opendaylight::install]') }
35   it { should contain_class('opendaylight::config').that_notifies('Class[opendaylight::service]') }
36   it { should contain_class('opendaylight::service').that_subscribes_to('Class[opendaylight::config]') }
37   it { should contain_class('opendaylight::service').that_comes_before('Class[opendaylight]') }
38   it { should contain_class('opendaylight::post_config').that_requires('Class[opendaylight::service]') }
39   it { should contain_class('opendaylight::post_config').that_comes_before('Class[opendaylight]') }
40   it { should contain_class('opendaylight').that_requires('Class[opendaylight::service]') }
41
42   # Confirm presence of generic resources
43   it { should contain_service('opendaylight') }
44   it { should contain_file('org.apache.karaf.features.cfg') }
45
46   # Confirm properties of generic resources
47   # NB: These hashes don't work with Ruby 1.8.7, but we
48   #   don't support 1.8.7 so that's okay. See issue #36.
49   it {
50     should contain_service('opendaylight').with(
51       'ensure'      => 'running',
52       'enable'      => 'true',
53       'hasstatus'   => 'true',
54       'hasrestart'  => 'true',
55     )
56   }
57   it {
58     should contain_file('org.apache.karaf.features.cfg').with(
59       'ensure'      => 'file',
60       'path'        => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
61       'owner'   => 'odl',
62       'group'   => 'odl',
63     )
64   }
65
66   it {
67     if odl_bind_ip =~ /.*:.*/
68         java_options = '-Djava.net.preferIPv6Addresses=true'
69     else
70         java_options = '-Djava.net.preferIPv4Stack=true'
71     end
72
73     should contain_file_line('Karaf Java Options').with(
74       'ensure' => 'present',
75       'path'   => '/opt/opendaylight/bin/karaf',
76       'line'   => "EXTRA_JAVA_OPTS=#{java_options}",
77       'match'  => '^EXTRA_JAVA_OPTS=.*$',
78       'after'  => '^PROGNAME=.*$'
79     )
80   }
81
82   it {
83     should contain_file('org.opendaylight.ovsdb.library.cfg').with(
84       'ensure'  => 'file',
85       'path'    => '/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg',
86       'owner'   => 'odl',
87       'group'   => 'odl',
88       'content' =>  /ovsdb-listener-ip = #{odl_bind_ip}/
89     )
90   }
91
92   it {
93     should contain_file('default-openflow-connection-config.xml').with(
94       'ensure'  => 'file',
95       'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml',
96       'owner'   => 'odl',
97       'group'   => 'odl',
98       'content' =>  /<address>#{odl_bind_ip}<\/address>/
99     )
100   }
101
102 end
103
104 # Shared tests that specialize in testing log file size and rollover
105 def log_settings(options = {})
106   # Extraxt params. The dafault value should be same as in opendaylight::params
107   log_max_size = options.fetch(:log_max_size, '10GB')
108   log_max_rollover = options.fetch(:log_max_rollover, 2)
109   log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
110   log_mechanism = options.fetch(:log_mechanism, 'file')
111
112   if log_mechanism == 'console'
113     it {
114       should contain_file_line('consoleappender').with(
115         'path'  => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
116         'line'  => 'karaf.log.console=INFO',
117         'after' => 'log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter',
118         'match' => '^karaf.log.console.*$'
119       )
120     }
121     it {
122       should contain_file_line('direct').with(
123         'path'  => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
124         'line'  => 'log4j2.appender.console.direct = true',
125         'after' => 'karaf.log.console=INFO',
126         'match' => '^log4j2.appender.console.direct.*$'
127       )
128     }
129   else
130
131     it {
132       should contain_file_line('logmaxsize').with(
133         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
134         'line'   => "log4j2.appender.rolling.policies.size.size = #{log_max_size}",
135         'match'  => '^log4j2.appender.rolling.policies.size.size.*$',
136       )
137     }
138     it {
139       should contain_file_line('rolloverstrategy').with(
140         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
141         'line'   => 'log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy'
142       )
143     }
144     it {
145       should contain_file_line('logmaxrollover').with(
146         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
147         'line'   => "log4j2.appender.rolling.strategy.max = #{log_max_rollover}",
148         'match'  => '^log4j2.appender.rolling.strategy.max.*$',
149       )
150     }
151     it {
152       should contain_file_line('logrolloverfileindex').with(
153         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
154         'line'   => "log4j2.appender.rolling.strategy.fileIndex = #{log_rollover_fileindex}",
155         'match'  => '^log4j2.appender.rolling.strategy.fileIndex.*$',
156       )
157     }
158   end
159 end
160
161 # Shared tests that specialize in testing Karaf feature installs
162 def karaf_feature_tests(options = {})
163   # Extract params
164   # NB: This default list should be the same as the one in opendaylight::params
165   # TODO: Remove this possible source of bugs^^
166   default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
167   extra_features = options.fetch(:extra_features, [])
168
169   # The order of this list concat matters
170   features = default_features + extra_features
171   features_csv = features.join(',')
172
173   # Confirm properties of Karaf features config file
174   # NB: These hashes don't work with Ruby 1.8.7, but we
175   #   don't support 1.8.7 so that's okay. See issue #36.
176   it {
177     should contain_file('org.apache.karaf.features.cfg').with(
178       'ensure'      => 'file',
179       'path'        => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
180       'owner'   => 'odl',
181       'group'   => 'odl',
182     )
183   }
184   it {
185     should contain_file_line('featuresBoot').with(
186       'path'  => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
187       'line'  => "featuresBoot=#{features_csv}",
188       'match' => '^featuresBoot=.*$',
189     )
190   }
191 end
192
193 # Shared tests that specialize in testing ODL's REST port config
194 def odl_rest_port_tests(options = {})
195   # Extract params
196   # NB: This default value should be the same as one in opendaylight::params
197   # TODO: Remove this possible source of bugs^^
198   odl_rest_port = options.fetch(:odl_rest_port, 8181)
199   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
200   # Confirm properties of ODL REST port config file
201   # NB: These hashes don't work with Ruby 1.8.7, but we
202   #   don't support 1.8.7 so that's okay. See issue #36.
203   it {
204     should contain_augeas('ODL REST Port')
205   }
206
207   if not odl_bind_ip.eql? '0.0.0.0'
208     it {
209       should contain_augeas('ODL REST IP')
210       should contain_file_line('set pax bind IP').with(
211         'ensure'  => 'present',
212         'path'    => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
213         'line'    => "org.ops4j.pax.web.listening.addresses = #{odl_bind_ip}",
214         'require' => 'File[org.ops4j.pax.web.cfg]'
215       )
216       should contain_file_line('set karaf IP').with(
217         'ensure' => 'present',
218         'path'   => '/opt/opendaylight/etc/org.apache.karaf.shell.cfg',
219         'line'   => "sshHost = #{odl_bind_ip}",
220         'match'  => '^sshHost\s*=.*$',
221       )
222     }
223   else
224     it {
225       should_not contain_augeas('ODL REST IP')
226     }
227   end
228
229   it {
230     should contain_file_line('set pax bind port').with(
231         'ensure'  => 'present',
232         'path'    => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
233         'line'    => "org.osgi.service.http.port = #{odl_rest_port}",
234         'match'   => '^#?org.osgi.service.http.port\s.*$',
235         'require' => 'File[org.ops4j.pax.web.cfg]'
236     )
237   }
238 end
239
240 def log_level_tests(options = {})
241   # Extract params
242   # NB: This default value should be the same as one in opendaylight::params
243   # TODO: Remove this possible source of bugs^^
244   log_levels = options.fetch(:log_levels, {})
245
246   if log_levels.empty?
247     # Should contain log level config file
248     it {
249       should_not contain_file_line('logger-org.opendaylight.ovsdb-level')
250     }
251     it {
252       should_not contain_file_line('logger-org.opendaylight.ovsdb-name')
253     }
254   else
255     # Verify each custom log level config entry
256     log_levels.each_pair do |logger, level|
257       underscored_version = "#{logger}".gsub('.', '_')
258       it {
259         should contain_file_line("logger-#{logger}-level").with(
260           'ensure' => 'present',
261           'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
262           'line' => "log4j2.logger.#{underscored_version}.level = #{level}",
263           'match'  => "log4j2.logger.#{underscored_version}.level = .*$"
264         )
265         should contain_file_line("logger-#{logger}-name").with(
266           'ensure' => 'present',
267           'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
268           'line' => "log4j2.logger.#{underscored_version}.name = #{logger}",
269           'match'  => "log4j2.logger.#{underscored_version}.name = .*$"
270         )
271       }
272     end
273   end
274 end
275
276 def enable_ha_tests(options = {})
277   # Extract params
278   enable_ha = options.fetch(:enable_ha, false)
279   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
280   ha_node_ips = options.fetch(:ha_node_ips, [])
281   ha_db_modules = options.fetch(:ha_db_modules, { 'default' => false })
282   # HA_NODE_IPS size
283   ha_node_count = ha_node_ips.size
284
285   if (enable_ha) && (ha_node_count < 2)
286     # Check for HA_NODE_COUNT < 2
287     fail("Number of HA nodes less than 2: #{ha_node_count} and HA Enabled")
288   end
289
290   if enable_ha
291     ha_node_index = ha_node_ips.index(odl_bind_ip)
292     it {
293       should contain_file('akka.conf').with(
294         'path'    => '/opt/opendaylight/configuration/initial/akka.conf',
295         'ensure'  => 'file',
296         'owner'   => 'odl',
297         'group'   => 'odl',
298         'content' => /roles\s*=\s*\["member-#{ha_node_index}"\]/
299       )
300     }
301
302     ha_db_modules.each do |mod, urn|
303       it { should contain_file('module-shards.conf').with(
304         'path'    => '/opt/opendaylight/configuration/initial/module-shards.conf',
305         'ensure'  => 'file',
306         'owner'   => 'odl',
307         'group'   => 'odl',
308         'content' => /name = "#{mod}"/
309       )}
310       if mod == 'default'
311         it { should contain_file('modules.conf').with(
312           'path'    => '/opt/opendaylight/configuration/initial/modules.conf',
313           'ensure'  => 'file',
314           'owner'   => 'odl',
315           'group'   => 'odl'
316         )}
317       else
318         it { should contain_file('modules.conf').with(
319           'path'    => '/opt/opendaylight/configuration/initial/modules.conf',
320           'ensure'  => 'file',
321           'owner'   => 'odl',
322           'group'   => 'odl',
323           'content' => /name = "#{mod}"/,
324         )}
325       end
326     end
327   else
328     it {
329       should_not contain_file('akka.conf')
330       should_not contain_file('module-shards.conf')
331       should_not contain_file('modules.conf')
332       }
333   end
334 end
335
336 def rpm_install_tests(options = {})
337   # Extract params
338   rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-fluorine-epel-7-$basearch-devel')
339
340
341   # Default to CentOS 7 Yum repo URL
342
343   # Confirm presence of RPM-related resources
344   it { should contain_yumrepo('opendaylight') }
345   it { should contain_package('opendaylight') }
346
347   # Confirm relationships between RPM-related resources
348   it { should contain_package('opendaylight').that_requires('Yumrepo[opendaylight]') }
349   it { should contain_yumrepo('opendaylight').that_comes_before('Package[opendaylight]') }
350
351   # Confirm properties of RPM-related resources
352   # NB: These hashes don't work with Ruby 1.8.7, but we
353   #   don't support 1.8.7 so that's okay. See issue #36.
354   it {
355     should contain_yumrepo('opendaylight').with(
356       'enabled'     => '1',
357       'gpgcheck'    => '0',
358       'descr'       => 'OpenDaylight SDN Controller',
359       'baseurl'     => "#{rpm_repo}",
360     )
361   }
362   it {
363     should contain_package('opendaylight').with(
364       'ensure'   => 'present',
365     )
366   }
367 end
368
369 def deb_install_tests(options = {})
370   # Extract params
371   deb_repo = options.fetch(:deb_repo, 'ppa:odl-team/nitrogen')
372
373   # Confirm the presence of Deb-related resources
374   it { should contain_apt__ppa(deb_repo) }
375   it { should contain_package('opendaylight') }
376
377   # Confirm relationships between Deb-related resources
378   it { should contain_package('opendaylight').that_requires("Apt::Ppa[#{deb_repo}]") }
379   it { should contain_apt__ppa(deb_repo).that_comes_before('Package[opendaylight]') }
380
381   # Confirm presence of Deb-related resources
382   it {
383     should contain_package('opendaylight').with(
384       'ensure'   => 'present',
385     )
386   }
387 end
388
389 # Shared tests for unsupported OSs
390 def unsupported_os_tests(options = {})
391   # Extract params
392   expected_msg = options.fetch(:expected_msg)
393   rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-fluorine-epel-7-$basearch-devel')
394
395   # Confirm that classes fail on unsupported OSs
396   it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
397   it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
398   it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
399   it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
400
401   # Confirm that other resources fail on unsupported OSs
402   it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
403   it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
404   it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
405   it { expect { should contain_file('org.apache.karaf.features.cfg') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
406 end
407
408 # Shared tests that specialize in testing SNAT mechanism
409 def snat_mechanism_tests(snat_mechanism='controller')
410   it { should contain_file('/opt/opendaylight/etc/opendaylight') }
411   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore')}
412   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial')}
413   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial/config')}
414
415   # Confirm snat_mechanism
416   it {
417     should contain_file('netvirt-natservice-config.xml').with(
418       'ensure'      => 'file',
419       'path'        => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml',
420       'owner'   => 'odl',
421       'group'   => 'odl',
422       'content'     =>  /<nat-mode>#{snat_mechanism}<\/nat-mode>/
423       )
424     }
425 end
426
427 # Shared tests that specialize in testing SFC Config
428 def sfc_tests(options = {})
429   extra_features = options.fetch(:extra_features, [])
430
431   if extra_features.include? 'odl-netvirt-sfc'
432     sfc_enabled = true
433   else
434     sfc_enabled = false
435   end
436
437   it { should contain_file('/opt/opendaylight/etc/opendaylight') }
438   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore')}
439   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial')}
440   it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial/config')}
441
442   it {
443     should contain_file('genius-itm-config.xml').with(
444       'ensure'  => 'file',
445       'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
446       'owner'   => 'odl',
447       'group'   => 'odl',
448       'content' => /<gpe-extension-enabled>#{sfc_enabled}<\/gpe-extension-enabled>/
449       )
450     }
451 end
452
453 # Shared tests that specialize in testing DSCP marking config
454 def dscp_tests(options = {})
455   inherit_dscp_marking = options.fetch(:inherit_dscp_marking, false)
456
457   if inherit_dscp_marking
458     it {
459       should contain_file('genius-itm-config.xml').with(
460         'ensure'  => 'file',
461         'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
462         'owner'   => 'odl',
463         'group'   => 'odl',
464         'content' => /<default-tunnel-tos>inherit<\/default-tunnel-tos>/
465       )
466     }
467   else
468     it {
469       should contain_file('genius-itm-config.xml').with(
470         'ensure'  => 'file',
471         'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
472         'owner'   => 'odl',
473         'group'   => 'odl',
474         'content' => /<default-tunnel-tos>0<\/default-tunnel-tos>/
475       )
476     }
477   end
478 end
479
480 # Shared tests that specialize in testing VPP routing node config
481 def vpp_routing_node_tests(options = {})
482   # Extract params
483   # NB: This default list should be the same as the one in opendaylight::params
484   # TODO: Remove this possible source of bugs^^
485   routing_node = options.fetch(:routing_node, '')
486
487   if routing_node.empty?
488     it { should_not contain_file('org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg') }
489     it { should_not contain_file_line('routing-node') }
490   else
491     # Confirm properties of Karaf config file
492     # NB: These hashes don't work with Ruby 1.8.7, but we
493     #   don't support 1.8.7 so that's okay. See issue #36.
494     it {
495       should contain_file('org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg').with(
496         'ensure'      => 'file',
497         'path'        => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
498         'owner'   => 'odl',
499         'group'   => 'odl',
500       )
501     }
502     it {
503       should contain_file_line('routing-node').with(
504         'path'  => '/opt/opendaylight/etc/org.opendaylight.groupbasedpolicy.neutron.vpp.mapper.startup.cfg',
505         'line'  => "routing-node=#{routing_node}",
506         'match' => '^routing-node=.*$',
507       )
508     }
509   end
510 end
511
512 # ODL username/password tests
513 def username_password_tests(username, password)
514
515   it {
516     should contain_odl_user(username).with(
517       :password => password
518     )
519   }
520 end
521
522 # ODL websocket address tests
523 def odl_websocket_address_tests(options = {})
524   # Extract params
525   # NB: This default value should be the same as one in opendaylight::params
526   # TODO: Remove this possible source of bugs^^
527   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
528   # Confirm properties of ODL REST port config file
529   # NB: These hashes don't work with Ruby 1.8.7, but we
530   #   don't support 1.8.7 so that's okay. See issue #36.
531
532   if not odl_bind_ip.eql? '0.0.0.0'
533     it {
534       should contain_file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg').with(
535         'ensure'      => 'file',
536         'path'        => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
537         'owner'   => 'odl',
538         'group'   => 'odl',
539       )
540     }
541     it {
542         should contain_file_line('websocket-address').with(
543           'path'    => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
544           'line'    => "websocket-address=#{odl_bind_ip}",
545           'match'   => '^websocket-address=.*$',
546       )
547     }
548   else
549     it {
550       should_not contain_file_line('websocket-address')
551     }
552   end
553 end
554
555 def odl_tls_tests(options = {})
556   enable_tls = options.fetch(:enable_tls, false)
557   tls_keystore_password = options.fetch(:tls_keystore_password, nil)
558   tls_trusted_certs = options.fetch(:tls_trusted_certs, [])
559   tls_keystore_password = options.fetch(:tls_keystore_password, nil)
560   tls_key_file = options.fetch(:tls_key_file, nil)
561   tls_cert_file = options.fetch(:tls_cert_file, nil)
562   tls_ca_cert_file = options.fetch(:tls_ca_cert_file, nil)
563   odl_rest_port = options.fetch(:odl_rest_port, 8181)
564
565   if enable_tls
566     if tls_keystore_password.nil?
567       it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::PreformattedError) }
568       return
569     end
570
571     if tls_key_file or tls_cert_file
572       if tls_key_file and tls_cert_file
573         it {
574           should contain_odl_keystore('controller')
575         }
576       else
577         it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::PreformattedError) }
578       end
579     end
580     it {
581       should contain_augeas('Remove HTTP ODL REST Port')
582       should contain_augeas('ODL SSL REST Port')
583       should contain_file_line('set pax TLS port').with(
584         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
585         'line'   => "org.osgi.service.http.port.secure = #{odl_rest_port}",
586         'match'  => '^#?org.osgi.service.http.port.secure.*$',
587       )
588       should contain_file_line('set pax TLS keystore location').with(
589         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
590         'line'   => 'org.ops4j.pax.web.ssl.keystore = configuration/ssl/ctl.jks',
591         'match'  => '^#?org.ops4j.pax.web.ssl.keystore.*$',
592       )
593       should contain_file_line('set pax TLS keystore integrity password').with(
594         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
595         'line'   => "org.ops4j.pax.web.ssl.password = #{tls_keystore_password}",
596         'match'  => '^#?org.ops4j.pax.web.ssl.password.*$',
597       )
598       should contain_file_line('set pax TLS keystore password').with(
599         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
600         'line'   => "org.ops4j.pax.web.ssl.keypassword = #{tls_keystore_password}",
601         'match'  => '^#?org.ops4j.pax.web.ssl.keypassword.*$',
602       )
603       should contain_file('aaa-cert-config.xml').with(
604         'ensure'  => 'file',
605         'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/aaa-cert-config.xml',
606         'owner'   => 'odl',
607         'group'   => 'odl',
608       )
609       should contain_file('org.opendaylight.ovsdb.library.cfg').with(
610         'ensure'  => 'file',
611         'path'    => '/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg',
612         'owner'   => 'odl',
613         'group'   => 'odl',
614         'content' =>  /use-ssl = true/
615       )
616       should contain_file('/opt/opendaylight/configuration/ssl').with(
617         'ensure' => 'directory',
618         'path'   => '/opt/opendaylight/configuration/ssl',
619         'owner'  => 'odl',
620         'group'  => 'odl',
621         'mode'   => '0755'
622       )
623       should contain_file_line('enable pax TLS').with(
624         'ensure' => 'present',
625         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
626         'line'   => 'org.osgi.service.http.secure.enabled = true',
627         'match'  => '^#?org.osgi.service.http.secure.enabled.*$',
628       )
629       should contain_file_line('disable pax HTTP').with(
630         'ensure' => 'present',
631         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
632         'line'   => 'org.osgi.service.http.enabled = false',
633         'match'  => '^#?org.osgi.service.http.enabled.*$',
634       )
635       should contain_file('org.ops4j.pax.web.cfg').with(
636         'ensure' => 'file',
637         'path'   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
638         'owner'  => 'odl',
639         'group'  => 'odl',
640       )
641       should contain_file('default-openflow-connection-config.xml').with(
642         'ensure'  => 'file',
643         'path'    => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml',
644         'owner'   => 'odl',
645         'group'   => 'odl',
646         'content' =>  /<transport-protocol>TLS<\/transport-protocol>/
647       )
648     }
649   end
650 end
651
652 def stats_polling_enablement_tests(options = {})
653   # Extract params
654   # NB: This default value should be the same as one in opendaylight::params
655   # TODO: Remove this possible source of bugs^^
656   stats_polling_enabled = options.fetch(:stats_polling_enabled, false)
657   # Confirm properties of ODL REST port config file
658   # NB: These hashes don't work with Ruby 1.8.7, but we
659   #   don't support 1.8.7 so that's okay. See issue #36.
660   it {
661     should contain_file('openflowplugin.cfg').with(
662       'ensure' => 'file',
663       'path'   => '/opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg',
664       'owner'  => 'odl',
665       'group'  => 'odl',
666     )
667     should contain_file_line('stats-polling').with(
668       'ensure' => 'present',
669       'path'   => '/opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg',
670       'line'   => "is-statistics-polling-on=#{stats_polling_enabled}",
671       'match'  => '^is-statistics-polling-on=.*$',
672     )
673   }
674 end