#
# Tests that are common to all possible configurations
-def generic_tests()
+def generic_tests(options = {})
+ 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 }
it { should compile.with_all_deps }
'group' => 'odl',
)
}
+
+ 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_max_size = options.fetch(:log_max_size, '500MB')
+ log_max_rollover = options.fetch(:log_max_rollover, 4)
+ 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 {
- should contain_file_line('rootlogger').with(
+ should contain_file_line('consoleappender').with(
'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
- 'line' => 'log4j.rootLogger=INFO, stdout, osgi:*',
- 'match' => '^log4j.rootLogger.*$',
+ 'line' => 'karaf.log.console=INFO',
+ 'after' => 'log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter',
+ 'match' => '^karaf.log.console.*$'
)
}
it {
- should contain_file_line('logappender').with(
- 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
- 'line' => 'log4j.appender.stdout.direct=true',
- 'after' => 'log4j.appender.stdout=org.apache.log4j.ConsoleAppender',
- 'match' => '^log4j.appender.stdout.direct.*$',
- 'append_on_no_match' => true
+ 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' => "log4j.appender.out.maxFileSize=#{log_max_size}",
- 'match' => '^log4j.appender.out.maxFileSize.*$',
+ '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' => "log4j.appender.out.maxBackupIndex=#{log_max_rollover}",
- 'match' => '^log4j.appender.out.maxBackupIndex.*$',
+ '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.*$',
+ )
+ }
+ 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, [])
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, 8080)
+ 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
# NB: These hashes don't work with Ruby 1.8.7, but we
'line' => "org.ops4j.pax.web.listening.addresses = #{odl_bind_ip}",
'require' => 'File[org.ops4j.pax.web.cfg]'
)
+ should contain_file_line('set karaf IP').with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/etc/org.apache.karaf.shell.cfg',
+ 'line' => "sshHost = #{odl_bind_ip}",
+ 'match' => '^sshHost\s*=.*$',
+ )
}
else
it {
should_not contain_augeas('ODL REST IP')
}
end
+
+ it {
+ should contain_file_line('set pax bind port').with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
+ 'line' => "org.osgi.service.http.port = #{odl_rest_port}",
+ 'match' => '^#?org.osgi.service.http.port\s.*$',
+ 'require' => 'File[org.ops4j.pax.web.cfg]'
+ )
+ }
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?
# Should contain log level config file
it {
- should_not contain_file_line('logger-org.opendaylight.ovsdb')
+ should_not contain_file_line('logger-org.opendaylight.ovsdb-level')
+ }
+ it {
+ should_not contain_file_line('logger-org.opendaylight.ovsdb-name')
}
else
# Verify each custom log level config entry
log_levels.each_pair do |logger, level|
+ underscored_version = "#{logger}".gsub('.', '_')
it {
- should contain_file_line("logger-#{logger}").with(
+ should contain_file_line("logger-#{logger}-level").with(
'ensure' => 'present',
'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
- 'line' => "log4j.logger.#{logger}=#{level}",
+ 'line' => "log4j2.logger.#{underscored_version}.level = #{level}",
+ 'match' => "log4j2.logger.#{underscored_version}.level = .*$"
+ )
+ should contain_file_line("logger-#{logger}-name").with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j2.logger.#{underscored_version}.name = #{logger}",
+ 'match' => "log4j2.logger.#{underscored_version}.name = .*$"
)
}
end
def rpm_install_tests(options = {})
# Extract params
- rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-oxygen-epel-7-$basearch-devel')
- java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+ 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
'ensure' => 'present',
)
}
-
- it {
- should contain_file_line('java_options_systemd').with(
- 'ensure' => 'present',
- 'path' => '/usr/lib/systemd/system/opendaylight.service',
- 'line' => "Environment=_JAVA_OPTIONS=\'#{java_opts}\'",
- 'after' => 'ExecStart=/opt/opendaylight/bin/start',
- )
- }
end
def deb_install_tests(options = {})
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-oxygen-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}/) }
end
# Shared tests that specialize in testing SFC Config
-def sfc_tests()
+def sfc_tests(options = {})
+ extra_features = options.fetch(:extra_features, [])
+
+ if extra_features.include? 'odl-netvirt-sfc'
+ sfc_enabled = true
+ else
+ sfc_enabled = false
+ end
+
it { should contain_file('/opt/opendaylight/etc/opendaylight') }
it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore')}
it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial')}
it { should contain_file('/opt/opendaylight/etc/opendaylight/datastore/initial/config')}
it {
- should contain_file('netvirt-elanmanager-config.xml').with(
- 'ensure' => 'file',
- 'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml',
- 'owner' => 'odl',
- 'group' => 'odl',
- 'source' => 'puppet:///modules/opendaylight/netvirt-elanmanager-config.xml'
- )
should contain_file('genius-itm-config.xml').with(
'ensure' => 'file',
'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
'owner' => 'odl',
'group' => 'odl',
- 'source' => 'puppet:///modules/opendaylight/genius-itm-config.xml'
+ 'content' => /<gpe-extension-enabled>#{sfc_enabled}<\/gpe-extension-enabled>/
)
}
end
+# Shared tests that specialize in testing DSCP marking config
+def dscp_tests(options = {})
+ inherit_dscp_marking = options.fetch(:inherit_dscp_marking, false)
+
+ if inherit_dscp_marking
+ it {
+ should contain_file('genius-itm-config.xml').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /<default-tunnel-tos>inherit<\/default-tunnel-tos>/
+ )
+ }
+ else
+ it {
+ should contain_file('genius-itm-config.xml').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /<default-tunnel-tos>0<\/default-tunnel-tos>/
+ )
+ }
+ end
+end
+
# Shared tests that specialize in testing VPP routing node config
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?
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
tls_key_file = options.fetch(:tls_key_file, nil)
tls_cert_file = options.fetch(:tls_cert_file, nil)
tls_ca_cert_file = options.fetch(:tls_ca_cert_file, nil)
- odl_rest_port = options.fetch(:odl_rest_port, 8080)
+ odl_rest_port = options.fetch(:odl_rest_port, 8181)
if enable_tls
if tls_keystore_password.nil?
'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',
'line' => 'org.osgi.service.http.secure.enabled = true',
'match' => '^#?org.osgi.service.http.secure.enabled.*$',
)
+ should contain_file_line('disable pax HTTP').with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
+ 'line' => 'org.osgi.service.http.enabled = false',
+ 'match' => '^#?org.osgi.service.http.enabled.*$',
+ )
should contain_file('org.ops4j.pax.web.cfg').with(
'ensure' => 'file',
'path' => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
}
end
end
+
+def stats_polling_enablement_tests(options = {})
+ # Extract params
+ # NB: This default value should be the same as one in opendaylight::params
+ 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
+ # don't support 1.8.7 so that's okay. See issue #36.
+ it {
+ should contain_file('openflowplugin.cfg').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ )
+ should contain_file_line('stats-polling').with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg',
+ 'line' => "is-statistics-polling-on=#{stats_polling_enabled}",
+ 'match' => '^is-statistics-polling-on=.*$',
+ )
+ }
+end