Parametrize the logging pattern to use
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper.rb
index eb5c4693c2b10a2e2e459de3d2289f6c6533620b..69f23606f60ece770f44b33044fc826dd45c449b 100644 (file)
@@ -14,7 +14,9 @@ RSpec::Puppet::Coverage.filters.push(*custom_filters)
 
 # Tests that are common to all possible configurations
 def generic_tests(options = {})
-  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+  java_opts = options.fetch(:java_opts, '')
+  odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
+  inactivity_probe = options.fetch(:inactivity_probe, :undef)
 
   # Confirm that module compiles
   it { should compile }
@@ -63,15 +65,53 @@ def generic_tests(options = {})
   }
 
   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_opts}",
+      '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
@@ -79,6 +119,8 @@ 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'
@@ -120,7 +162,21 @@ def log_settings(options = {})
         '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.*$',
+    )
+  }
 end
 
 # Shared tests that specialize in testing Karaf feature installs
@@ -572,11 +628,11 @@ def odl_tls_tests(options = {})
         'group'   => 'odl',
       )
       should contain_file('org.opendaylight.ovsdb.library.cfg').with(
-        'ensure' => 'file',
-        'path'   => '/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg',
-        'owner'  => 'odl',
-        'group'  => 'odl',
-        'source' => 'puppet:///modules/opendaylight/org.opendaylight.ovsdb.library.cfg'
+        'ensure'  => 'file',
+        'path'    => '/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg',
+        'owner'   => 'odl',
+        'group'   => 'odl',
+        'content' =>  /use-ssl = true/
       )
       should contain_file('/opt/opendaylight/configuration/ssl').with(
         'ensure' => 'directory',
@@ -636,4 +692,4 @@ def stats_polling_enablement_tests(options = {})
       'match'  => '^is-statistics-polling-on=.*$',
     )
   }
-end
\ No newline at end of file
+end