X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=spec%2Fspec_helper.rb;h=1726a30cb9544c21a11a608234b3f4a139888484;hb=4fa363098e550d4d57245d0347763765a8291088;hp=cd9457b4451c9ae8eba2d9816e00451599ba7190;hpb=9e22e9e083861c614353fc0b96ca9f82c504e5e6;p=integration%2Fpackaging%2Fpuppet-opendaylight.git diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cd9457b..1726a30 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,35 +3,8 @@ require 'rspec-puppet-facts' include RspecPuppetFacts # Customize filters to ignore 3rd-party code -# If the coverage report shows not-our-code results, add it here +# If the rspec coverage report shows not-our-code results, add it here custom_filters = [ - 'Anchor[java::end]', - 'Stage[setup]', - 'Anchor[java::begin:]', - 'Archive::Download[opendaylight.tar.gz]', - 'Archive::Download[opendaylight-systemd.tar.gz]', - 'Archive::Extract[opendaylight]', - 'Archive::Extract[opendaylight-systemd]', - 'Class[Java::Config]', - 'Class[Java::Params]', - 'Class[Stdlib::Stages]', - 'Class[Stdlib]', - 'Exec[Configure ODL OVSDB Clustering]', - 'Exec[download archive opendaylight.tar.gz and check sum]', - 'Exec[download archive opendaylight-systemd.tar.gz and check sum]', - 'Exec[opendaylight unpack]', - 'Exec[opendaylight-systemd unpack]', - 'Exec[rm-on-error-opendaylight.tar.gz]', - 'Exec[rm-on-error-opendaylight-systemd.tar.gz]', - 'Exec[reload_systemd_units]', - 'Exec[update-java-alternatives]', - 'Package[curl]', - 'Stage[deploy]', - 'Stage[deploy_app]', - 'Stage[deploy_infra]', - 'Stage[runtime]', - 'Stage[setup_app]', - 'Stage[setup_infra]', ] RSpec::Puppet::Coverage.filters.push(*custom_filters) @@ -85,6 +58,28 @@ def generic_tests() } 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 @@ -128,13 +123,7 @@ def odl_rest_port_tests(options = {}) # 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('jetty.xml').with( - 'ensure' => 'file', - 'path' => '/opt/opendaylight/etc/jetty.xml', - 'owner' => 'odl', - 'group' => 'odl', - 'content' => /Property name="jetty.port" default="#{odl_rest_port}"/ - ) + should contain_augeas('jetty.xml') } end @@ -147,52 +136,16 @@ def log_level_tests(options = {}) if log_levels.empty? # Should contain log level config file it { - should contain_file('org.ops4j.pax.logging.cfg').with( - 'ensure' => 'file', - 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg', - 'owner' => 'odl', - 'group' => 'odl', - ) - } - # Should not contain custom log level config - it { - should_not contain_file('org.ops4j.pax.logging.cfg').with( - 'ensure' => 'file', - 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg', - 'owner' => 'odl', - 'group' => 'odl', - 'content' => /# Log level config added by puppet-opendaylight/ - ) + should_not contain_file_line('logger-org.opendaylight.ovsdb') } else - # Should contain log level config file - it { - should contain_file('org.ops4j.pax.logging.cfg').with( - 'ensure' => 'file', - 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg', - 'owner' => 'odl', - 'group' => 'odl', - ) - } - # Should contain custom log level config - it { - should contain_file('org.ops4j.pax.logging.cfg').with( - 'ensure' => 'file', - 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg', - 'owner' => 'odl', - 'group' => 'odl', - 'content' => /# Log level config added by puppet-opendaylight/ - ) - } # Verify each custom log level config entry log_levels.each_pair do |logger, level| it { - should contain_file('org.ops4j.pax.logging.cfg').with( - 'ensure' => 'file', - 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg', - 'owner' => 'odl', - 'group' => 'odl', - 'content' => /^log4j.logger.#{logger} = #{level}/ + should contain_file_line("logger-#{logger}").with( + 'ensure' => 'present', + 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg', + 'line' => "log4j.logger.#{logger}=#{level}", ) } end @@ -202,8 +155,9 @@ end def enable_ha_tests(options = {}) # Extract params enable_ha = options.fetch(:enable_ha, false) + odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0') ha_node_ips = options.fetch(:ha_node_ips, []) - ha_node_index = options.fetch(:ha_node_index, 0) + ha_db_modules = options.fetch(:ha_db_modules, { 'default' => false }) # HA_NODE_IPS size ha_node_count = ha_node_ips.size @@ -211,6 +165,51 @@ def enable_ha_tests(options = {}) # Check for HA_NODE_COUNT < 2 fail("Number of HA nodes less than 2: #{ha_node_count} and HA Enabled") end + + if enable_ha + ha_node_index = ha_node_ips.index(odl_bind_ip) + it { + should contain_file('akka.conf').with( + 'path' => '/opt/opendaylight/configuration/initial/akka.conf', + 'ensure' => 'file', + 'owner' => 'odl', + 'group' => 'odl', + 'content' => /roles\s*=\s*\["member-#{ha_node_index}"\]/ + ) + } + + ha_db_modules.each do |mod, urn| + it { should contain_file('module-shards.conf').with( + 'path' => '/opt/opendaylight/configuration/initial/module-shards.conf', + 'ensure' => 'file', + 'owner' => 'odl', + 'group' => 'odl', + 'content' => /name = "#{mod}"/ + )} + if mod == 'default' + it { should contain_file('modules.conf').with( + 'path' => '/opt/opendaylight/configuration/initial/modules.conf', + 'ensure' => 'file', + 'owner' => 'odl', + 'group' => 'odl' + )} + else + it { should contain_file('modules.conf').with( + 'path' => '/opt/opendaylight/configuration/initial/modules.conf', + 'ensure' => 'file', + 'owner' => 'odl', + 'group' => 'odl', + 'content' => /name = "#{mod}"/, + )} + end + end + else + it { + should_not contain_file('akka.conf') + should_not contain_file('module-shards.conf') + should_not contain_file('modules.conf') + } + end end def rpm_install_tests(options = {}) @@ -257,7 +256,7 @@ end def deb_install_tests(options = {}) # Extract params - deb_repo = options.fetch(:deb_repo, 'ppa:odl-team/boron') + deb_repo = options.fetch(:deb_repo, 'ppa:odl-team/carbon') # Confirm the presence of Deb-related resources it { should contain_apt__ppa(deb_repo) } @@ -330,6 +329,50 @@ def enable_sg_tests(sg_mode='stateful', os_release) end end +# Shared tests that specialize in testing SNAT mechanism +def snat_mechanism_tests(snat_mechanism='controller') + 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')} + + # Confirm snat_mechanism + it { + should contain_file('netvirt-natservice-config.xml').with( + 'ensure' => 'file', + 'path' => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml', + 'owner' => 'odl', + 'group' => 'odl', + 'content' => /#{snat_mechanism}<\/nat-mode>/ + ) + } +end + +# Shared tests that specialize in testing SFC Config +def sfc_tests() + 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' + ) + } +end + # Shared tests that specialize in testing VPP routing node config def vpp_routing_node_tests(options = {}) # Extract params