+
+ it {
+ if odl_bind_ip =~ /.*:.*/
+ java_options = '-Djava.net.preferIPv6Addresses=true'
+ else
+ java_options = '-Djava.net.preferIPv4Stack=true'
+ end
+
+ should contain_file_line('Karaf Java Options').with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/bin/karaf',
+ 'line' => "EXTRA_JAVA_OPTS=\"#{java_options}\"",
+ 'match' => '^EXTRA_JAVA_OPTS=.*$',
+ 'after' => '^PROGNAME=.*$'
+ )
+ }
+
+ it {
+ should contain_file('org.opendaylight.ovsdb.library.cfg').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /ovsdb-listener-ip = #{odl_bind_ip}/
+ )
+ }
+
+ it {
+ should contain_file('default-openflow-connection-config.xml').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /<address>#{odl_bind_ip}<\/address>/
+ )
+ }
+
+ unless inactivity_probe == :undef
+ it {
+ should contain_file('Configure inactivity probe timer').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /<controller-inactivity-probe>#{inactivity_probe}<\/controller-inactivity-probe>/
+ )
+ }
+ end
+
+end
+
+# Shared tests that specialize in testing log file size and rollover
+def log_settings(options = {})
+ # Extraxt params. The dafault value should be same as in opendaylight::params
+ log_max_size = options.fetch(:log_max_size, '10GB')
+ log_max_rollover = options.fetch(:log_max_rollover, 2)
+ log_rollover_fileindex = options.fetch(:log_rollover_fileindex, 'min')
+ log_pattern = options.fetch(:log_pattern, '%d{ISO8601} | %-5p | %-16t | %-60c{6} | %m%n')
+ log_mechanism = options.fetch(:log_mechanism, 'file')
+
+ if log_mechanism == 'console'
+ it {
+ should contain_file_line('consoleappender').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => 'karaf.log.console=INFO',
+ 'after' => 'log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter',
+ 'match' => '^karaf.log.console.*$'
+ )
+ }
+ it {
+ should contain_file_line('direct').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => 'log4j2.appender.console.direct = true',
+ 'after' => 'karaf.log.console=INFO',
+ 'match' => '^log4j2.appender.console.direct.*$'
+ )
+ }
+ else
+
+ it {
+ should contain_file_line('logmaxsize').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j2.appender.rolling.policies.size.size = #{log_max_size}",
+ 'match' => '^log4j2.appender.rolling.policies.size.size.*$',
+ )
+ }
+ it {
+ should contain_file_line('rolloverstrategy').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => 'log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy'
+ )
+ }
+ it {
+ should contain_file_line('logmaxrollover').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j2.appender.rolling.strategy.max = #{log_max_rollover}",
+ 'match' => '^log4j2.appender.rolling.strategy.max.*$',
+ )
+ }
+ it {
+ should contain_file_line('logrolloverfileindex').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j2.appender.rolling.strategy.fileIndex = #{log_rollover_fileindex}",
+ 'match' => '^log4j2.appender.rolling.strategy.fileIndex.*$',
+ )
+ }
+ end
+ it {
+ should contain_file_line('logpattern').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j2.pattern = #{log_pattern}",
+ 'match' => '^log4j2.pattern.*$',
+ )
+ }