Merge "Add boolean flag to disable the PaxOsgi appender"
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper.rb
index de4a25195efb6a7df225a23cca1e3b0a69a1ca9f..3318939e7725762859afd5c4877b14b47d71a469 100644 (file)
@@ -120,7 +120,9 @@ def log_settings(options = {})
   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')
+  enable_paxosgi_logger = options.fetch(:enable_paxosgi_logger, false)
 
   if log_mechanism == 'console'
     it {
@@ -169,13 +171,56 @@ def log_settings(options = {})
       )
     }
   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.*$',
+    )
+  }
+  if enable_paxosgi_logger == true
+      presence = 'present'
+  else
+      presence = 'absent'
+  end
+
+  it {
+    should contain_file_line('paxosgiappenderref').with(
+      'ensure' => presence,
+      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      'line'   => "log4j2.rootLogger.appenderRef.PaxOsgi.ref = PaxOsgi",
+    )
+  }
+  it {
+    should contain_file_line('paxosgisection').with(
+      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      'line'   => "# OSGi appender",
+    )
+  }
+  it {
+    should contain_file_line('paxosgitype').with(
+      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      'line'   => "log4j2.appender.osgi.type = PaxOsgi",
+    )
+  }
+  it {
+    should contain_file_line('paxosginame').with(
+      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      'line'   => "log4j2.appender.osgi.name = PaxOsgi",
+    )
+  }
+  it {
+    should contain_file_line('paxosgifilter').with(
+      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      'line'   => "log4j2.appender.osgi.filter = *",
+    )
+  }
 end
 
 # Shared tests that specialize in testing Karaf feature installs
 def karaf_feature_tests(options = {})
   # Extract params
   # NB: This default list should be the same as the one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
   default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
   extra_features = options.fetch(:extra_features, [])
 
@@ -207,7 +252,6 @@ end
 def odl_rest_port_tests(options = {})
   # Extract params
   # NB: This default value should be the same as one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
   odl_rest_port = options.fetch(:odl_rest_port, 8181)
   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
   # Confirm properties of ODL REST port config file
@@ -253,7 +297,6 @@ end
 def log_level_tests(options = {})
   # Extract params
   # NB: This default value should be the same as one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
   log_levels = options.fetch(:log_levels, {})
 
   if log_levels.empty?
@@ -348,7 +391,7 @@ end
 
 def rpm_install_tests(options = {})
   # Extract params
-  rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-fluorine-epel-7-$basearch-devel')
+  rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-neon-epel-7-$basearch-devel')
 
 
   # Default to CentOS 7 Yum repo URL
@@ -403,7 +446,7 @@ end
 def unsupported_os_tests(options = {})
   # Extract params
   expected_msg = options.fetch(:expected_msg)
-  rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-fluorine-epel-7-$basearch-devel')
+  rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-neon-epel-7-$basearch-devel')
 
   # Confirm that classes fail on unsupported OSs
   it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
@@ -494,7 +537,6 @@ end
 def vpp_routing_node_tests(options = {})
   # Extract params
   # NB: This default list should be the same as the one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
   routing_node = options.fetch(:routing_node, '')
 
   if routing_node.empty?
@@ -536,7 +578,6 @@ end
 def odl_websocket_address_tests(options = {})
   # Extract params
   # NB: This default value should be the same as one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
   # Confirm properties of ODL REST port config file
   # NB: These hashes don't work with Ruby 1.8.7, but we
@@ -665,7 +706,6 @@ end
 def stats_polling_enablement_tests(options = {})
   # Extract params
   # NB: This default value should be the same as one in opendaylight::params
-  # TODO: Remove this possible source of bugs^^
   stats_polling_enabled = options.fetch(:stats_polling_enabled, false)
   # Confirm properties of ODL REST port config file
   # NB: These hashes don't work with Ruby 1.8.7, but we