The main log output file is `/opt/opendaylight/data/log/karaf.log`.
+##### `log_max_size`
+
+Maximum size of OpenDaylight's log file, `/opt/opendaylight/data/log/karaf.log`.
+
+Once this size is reached, the log will be rolled over, with up to
+`log_max_rollover` log rollovers preserved in total.
+
+Default: `10GB`
+
+Valid options: A valid size as a string with unit specified.
+
+##### `log_max_rollover`
+
+Maximum number of OpenDaylight karaf.log rollovers to keep.
+
+Note that if this is set to 1, log rollovers will result in loosing newly
+logged data. It's recommended to use values greater than one to prune from
+the end of the log.
+
+Default: `2`
+
+Valid options: An integer greater than 0.
+
##### `enable_ha`
Enable or disable ODL High Availablity.
}
}
+ # Set maximum ODL log file size
+ file_line { 'logmaxsize':
+ ensure => present,
+ path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ line => "log4j.appender.out.maxFileSize=${::opendaylight::log_max_size}",
+ match => '^log4j.appender.out.maxFileSize.*$'
+ }
+
+ # Set maximum number of ODL log file rollovers to preserve
+ file_line { 'logmaxrollover':
+ ensure => present,
+ path => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ line => "log4j.appender.out.maxBackupIndex=${::opendaylight::log_max_rollover}",
+ match => '^log4j.appender.out.maxBackupIndex.*$'
+ }
+
# Configure ODL HA if enabled
$ha_node_count = count($::opendaylight::ha_node_ips)
if $::opendaylight::enable_ha {
# (Boolean) Should this module manage the apt or yum repositories for the
# package installation.
# Defaults to true
+# [*log_max_size*]
+# Maxium size of OpenDaylight's log file.
+# [*log_max_rollover*]
+# Maxium number of OpenDaylight log rollovers to keep.
#
# === Deprecated Parameters
#
$manage_repositories = $::opendaylight::params::manage_repositories,
$username = $::opendaylight::params::username,
$password = $::opendaylight::params::password,
+ $log_max_size = $::opendaylight::params::log_max_size,
+ $log_max_rollover = $::opendaylight::params::log_max_rollover
) inherits ::opendaylight::params {
# Validate OS family
$manage_repositories = true
$username = 'admin'
$password = 'admin'
+ $log_max_size = '10GB'
+ $log_max_rollover = 2
}
end
end
+ describe 'log file size and rollover' do
+ context 'using default size and rollover' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl
+
+ # Call specialized helper fn for log file settings validations
+ log_file_settings_validations
+ end
+
+ context 'customising size' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(log_max_size: '1GB')
+
+ # Call specialized helper fn for log file settings validations
+ log_file_settings_validations(log_max_size: '1GB')
+ end
+
+ context 'customising rollover' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(log_max_rollover: 3)
+
+ # Call specialized helper fn for log file settings validations
+ log_file_settings_validations(log_max_rollover: 3)
+ end
+
+ context 'customising size and rollover' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(log_max_size: '1GB',
+ log_max_rollover: 3)
+
+ # Call specialized helper fn for log file settings validations
+ log_file_settings_validations(log_max_size: '1GB',
+ log_max_rollover: 3)
+ end
+ end
+
describe 'testing REST port config file' do
context 'using default port' do
# Call specialized helper fn to install OpenDaylight
# NB: Only testing defaults here, specialized enabling HA tests elsewhere
# Note that this function is defined in spec_helper
enable_ha_tests
+
+ # Run tests that specialize in checking log file settings
+ # NB: Only testing defaults here, specialized log file settings tests elsewhere
+ # Note that this function is defined in spec_helper
+ log_file_settings
end
end
# NB: Only testing defaults here, specialized enabling HA tests elsewhere
# Note that this function is defined in spec_helper
enable_ha_tests
+
+ # Run tests that specialize in checking log file settings
+ # NB: Only testing defaults here, specialized log file settings tests elsewhere
+ # Note that this function is defined in spec_helper
+ log_file_settings
end
end
# NB: Only testing defaults here, specialized enabling HA tests elsewhere
# Note that this function is defined in spec_helper
enable_ha_tests
+
+ # Run tests that specialize in checking log file settings
+ # NB: Only testing defaults here, specialized log file settings tests elsewhere
+ # Note that this function is defined in spec_helper
+ log_file_settings
end
end
end
end
+ # All custom log file size and rollover tests
+ describe 'log file size and rollover' do
+ # Non-OS-type tests assume CentOS 7
+ # See issue #43 for reasoning:
+ # https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
+ osfamily = 'RedHat'
+ operatingsystem = 'CentOS'
+ operatingsystemmajrelease = '7'
+ context 'using default size and rollover' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test specific to log file settings
+ log_file_settings
+ end
+
+ context 'customizing size' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :log_max_size => '1GB',
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test specific to log file settings
+ log_file_settings(log_max_size: '1GB')
+ end
+
+ context 'customizing rollover' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :log_max_rollover => 3,
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test specific to log file settings
+ log_file_settings(log_max_rollover: 3)
+ end
+
+ context 'customizing size and rollover' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :log_max_size => '1GB',
+ :log_max_rollover => 3,
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test specific to log file settings
+ log_file_settings(log_max_size: '1GB',
+ log_max_rollover: 3)
+ end
+ end
+
# All OVSDB HA enable/disable tests
describe 'OVSDB HA enable/disable tests' do
# Non-OS-type tests assume CentOS 7
}
end
+# Shared tests that specialize in testing log file size and rollover
+def log_file_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)
+
+ it {
+ should contain_file_line('logmaxsize').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j.appender.out.maxFileSize=#{log_max_size}",
+ 'match' => '^log4j.appender.out.maxFileSize.*$',
+ )
+ }
+ it {
+ should contain_file_line('logmaxrollover').with(
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j.appender.out.maxBackupIndex=#{log_max_rollover}",
+ 'match' => '^log4j.appender.out.maxBackupIndex.*$',
+ )
+ }
+end
+
# Shared tests that specialize in testing Karaf feature installs
def karaf_feature_tests(options = {})
# Extract params
ha_db_modules = options.fetch(:ha_db_modules, { 'default' => false })
username = options.fetch(:username, 'admin')
password = options.fetch(:password, 'admin')
+ log_max_size = options.fetch(:log_max_size, '10GB')
+ log_max_rollover = options.fetch(:log_max_rollover, 2)
# Build script for consumption by Puppet apply
it 'should work idempotently with no errors' do
deb_repo => '#{deb_repo}',
default_features => #{default_features},
extra_features => #{extra_features},
- odl_rest_port=> #{odl_rest_port},
- odl_bind_ip=> '#{odl_bind_ip}',
- enable_ha=> #{enable_ha},
- ha_node_ips=> #{ha_node_ips},
- ha_node_index=> #{ha_node_index},
- ha_db_modules=> #{ha_db_modules},
- log_levels=> #{log_levels},
- username=> #{username},
- password=> #{password},
+ odl_rest_port => #{odl_rest_port},
+ odl_bind_ip => '#{odl_bind_ip}',
+ enable_ha => #{enable_ha},
+ ha_node_ips => #{ha_node_ips},
+ ha_node_index => #{ha_node_index},
+ ha_db_modules => #{ha_db_modules},
+ log_levels => #{log_levels},
+ username => #{username},
+ password => #{password},
+ log_max_size => '#{log_max_size}',
+ log_max_rollover => #{log_max_rollover},
}
EOS
end
end
+# Shared function for validations related to log file settings
+def log_file_settings_validations(options = {})
+ # Should contain log level config file with correct file size and rollover values
+ log_max_size = options.fetch(:log_max_size, '10GB')
+ log_max_rollover = options.fetch(:log_max_rollover, 2)
+
+ describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /^log4j.appender.out.maxFileSize=#{log_max_size}/ }
+ its(:content) { should match /^log4j.appender.out.maxBackupIndex=#{log_max_rollover}/ }
+ end
+end
+
# Shared function for validations related to the Karaf config file
def karaf_config_validations(options = {})
# NB: These param defaults should match the ones used by the opendaylight