X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=spec%2Fspec_helper_acceptance.rb;h=d433f867e3152ac0a7b72709d426a1e09aeb27bd;hb=0724dba3d883763cc362c906e809ec12e7f64fae;hp=9abd6e58b77d0f72c4937d2f8e9457b09a0e7fe7;hpb=0fb7db910ecf90e8568d0cbc7db2866779ed632f;p=integration%2Fpackaging%2Fpuppet-opendaylight.git diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 9abd6e5..d433f86 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -47,26 +47,27 @@ def install_odl(options = {}) rpm_repo = ENV['RPM_REPO'] deb_repo = ENV['DEB_REPO'] - if rpm_repo == '' - rpm_repo = 'none' - elsif deb_repo == '' - deb_repo = 'none' - end - # NB: These param defaults should match the ones used by the opendaylight # class, which are defined in opendaylight::params # TODO: Remove this possible source of bugs^^ # Extract params if given, defaulting to odl class defaults if not - extra_features = options.fetch(:extra_features, []) - default_features = options.fetch(:default_features, - ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management']) - odl_rest_port = options.fetch(:odl_rest_port, 8080) + extra_features = options.fetch(:extra_features, ['odl-restconf']) + default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh']) + odl_rest_port = options.fetch(:odl_rest_port, 8181) + odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0') log_levels = options.fetch(:log_levels, {}) enable_ha = options.fetch(:enable_ha, false) 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 }) 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) + snat_mechanism = options.fetch(:snat_mechanism, 'controller') + enable_tls = options.fetch(:enable_tls, false) + tls_keystore_password = options.fetch(:tls_keystore_password, 'dummypass') + log_mechanism = options.fetch(:log_mechanism, 'file') # Build script for consumption by Puppet apply it 'should work idempotently with no errors' do @@ -76,13 +77,21 @@ def install_odl(options = {}) deb_repo => '#{deb_repo}', default_features => #{default_features}, extra_features => #{extra_features}, - odl_rest_port=> #{odl_rest_port}, - enable_ha=> #{enable_ha}, - ha_node_ips=> #{ha_node_ips}, - ha_node_index=> #{ha_node_index}, - 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}, + snat_mechanism => #{snat_mechanism}, + enable_tls => #{enable_tls}, + tls_keystore_password => #{tls_keystore_password}, + log_mechanism => #{log_mechanism}, } EOS @@ -201,14 +210,39 @@ def generic_validations() end end +# Shared function for validations related to log file settings +def log_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) + log_mechanism = options.fetch(:log_mechanism, 'file') + + if log_mechanism == 'console' + 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 /^karaf.log.console=INFO/ } + end + else + 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 /^log4j2.appender.rolling.policies.size.size = #{log_max_size}/ } + its(:content) { should match /^log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy/ } + its(:content) { should match /^log4j2.appender.rolling.strategy.max = #{log_max_rollover}/ } + end + 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 # class, which are defined in opendaylight::params # TODO: Remove this possible source of bugs^^ extra_features = options.fetch(:extra_features, []) - default_features = options.fetch(:default_features, ['config', 'standard', 'region', - 'package', 'kar', 'ssh', 'management']) + default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh']) # Create one list of all of the features features = default_features + extra_features @@ -226,7 +260,7 @@ def port_config_validations(options = {}) # NB: This param default should match the one used by the opendaylight # class, which is defined 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) describe file('/opt/opendaylight/etc/jetty.xml') do it { should be_file } @@ -250,13 +284,6 @@ def log_level_validations(options = {}) it { should be_owned_by 'odl' } it { should be_grouped_into 'odl' } end - # Should not contain custom log level config - 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_not match /# Log level config added by puppet-opendaylight/ } - end else # Should contain log level config file describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do @@ -264,20 +291,15 @@ def log_level_validations(options = {}) it { should be_owned_by 'odl' } it { should be_grouped_into 'odl' } end - # Should not contain custom log level config - 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 /# Log level config added by puppet-opendaylight/ } - end # Verify each custom log level config entry log_levels.each_pair do |logger, level| + underscored_version = "#{logger}".gsub('.', '_') 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.logger.#{logger} = #{level}/ } + its(:content) { should match /^log4j2.logger.#{underscored_version}.level = #{level}/ } + its(:content) { should match /^log4j2.logger.#{underscored_version}.name = #{logger}/ } end end end @@ -290,7 +312,8 @@ def enable_ha_validations(options = {}) # TODO: Remove this possible source of bugs^^ enable_ha = options.fetch(:enable_ha, false) ha_node_ips = options.fetch(:ha_node_ips, []) - ha_node_index = options.fetch(:ha_node_index, 0) + odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0') + ha_db_modules = options.fetch(:ha_db_modules, { 'default' => false }) # HA_NODE_IPS size ha_node_count = ha_node_ips.size @@ -298,13 +321,48 @@ def enable_ha_validations(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) + describe file('/opt/opendaylight/configuration/initial/akka.conf') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /roles\s*=\s*\["member-#{ha_node_index}"\]/ } + end + + ha_db_modules.each do |mod, urn| + describe file('/opt/opendaylight/configuration/initial/module-shards.conf') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /name = "#{mod}"/ } + end + + if mod == 'default' + describe file('/opt/opendaylight/configuration/initial/modules.conf') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + end + else + describe file('/opt/opendaylight/configuration/initial/modules.conf') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /name = "#{mod}"/ } + its(:content) { should match /namespace = "#{urn}"/ } + end + end + end + end end # Shared function that handles validations specific to RPM-type installs def rpm_validations() rpm_repo = ENV['RPM_REPO'] - describe yumrepo(rpm_repo) do + describe yumrepo('opendaylight') do it { should exist } it { should be_enabled } end @@ -336,13 +394,123 @@ def username_password_validations(options = {}) # TODO: Remove this possible source of bugs^^ odl_username = options.fetch(:username, 'admin') odl_password = options.fetch(:password, 'admin') - odl_check_url = 'http://127.0.0.1:8080/restconf' + odl_check_url = 'http://127.0.0.1:8181/restconf' describe file('/opt/opendaylight/data/idmlight.db.mv.db') do it { should be_file } end - describe command("sleep 60 && curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do + describe command("loop_count=0; until [[ \$loop_count -ge 300 ]]; do curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url} && break; loop_count=\$[\$loop_count+1]; sleep 1; done; echo \"Waited \$loop_count seconds for ODL to become active\"") do its(:exit_status) { should eq 0 } end + + describe command("curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do + its(:exit_status) { should eq 0 } + end +end + +# Shared function for validations related to the SNAT config file +def snat_mechanism_validations(options = {}) + # NB: This param default should match the one used by the opendaylight + # class, which is defined in opendaylight::params + # TODO: Remove this possible source of bugs^^ + snat_mechanism = options.fetch(:snat_mechanism, 'controller') + + describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /#{snat_mechanism}<\/nat-mode>/ } + end +end + +# Shared function for validations related to SFC +def sfc_validations() + # NB: This param default should match the one used by the opendaylight + # class, which is defined in opendaylight::params + # TODO: Remove this possible source of bugs^^ + + describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /true<\/use-of-tunnels>/ } + end + + describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /true<\/gpe-extension-enabled>/ } + end +end + +def websocket_address_validations(options = {}) + # NB: This param default should match the one used by the opendaylight + # class, which is defined in opendaylight::params + # TODO: Remove this possible source of bugs^^ + odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0') + + if not odl_bind_ip.eql? '0.0.0.0' + describe file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /^websocket-address=#{odl_bind_ip}/ } + end + else + describe file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg') do + it { should be_file } + end + end +end + +def tls_validations(options = {}) + # NB: This param default should match the one used by the opendaylight + # class, which is defined in opendaylight::params + # TODO: Remove this possible source of bugs^^ + tls_keystore_password = options.fetch(:tls_keystore_password) + odl_rest_port = options.fetch(:odl_rest_port, 8181) + + describe file('/opt/opendaylight/etc/org.ops4j.pax.web.cfg') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /org.osgi.service.http.port.secure = #{odl_rest_port}/ } + its(:content) { should match /org.ops4j.pax.web.ssl.keystore = configuration\/ssl\/ctl.jks/ } + its(:content) { should match /org.ops4j.pax.web.ssl.password = #{tls_keystore_password}/ } + its(:content) { should match /org.ops4j.pax.web.ssl.keypassword = #{tls_keystore_password}/ } + its(:content) { should match /org.osgi.service.http.secure.enabled = true/ } + end + + describe file('/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /use-ssl = true/ } + end + + describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /#{tls_keystore_password}<\/keystore-password>/ } + its(:content) { should match /#{tls_keystore_password}<\/truststore-password>/ } + its(:content) { should match /TLS<\/transport-protocol>/ } + end + + describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/aaa-cert-config.xml') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match /#{tls_keystore_password}<\/store-password>/ } + its(:content) { should match /false<\/use-mdsal>/ } + end + + describe file('/opt/opendaylight/etc/jetty.xml') do + it { should be_file } + it { should be_owned_by 'odl' } + it { should be_grouped_into 'odl' } + its(:content) { should match // } + end end