}
->
# Configure the systemd file to force ipv4 binds (instead of ipv6)
- file_line { 'odl_start_ipv4 ':
+ file_line { 'odl_start_ipv4':
ensure => present,
path => '/usr/lib/systemd/system/opendaylight.service',
line => 'Environment=_JAVA_OPTIONS=\'-Djava.net.preferIPv4Stack=true\'',
# NB: Only testing defaults here, specialized enabling L3 tests elsewhere
# Note that this function is defined in spec_helper
enable_l3_tests
+
+ # Run tests that specialize in checking ODL OVSDB HA config
+ # NB: Only testing defaults here, specialized enabling HA tests elsewhere
+ # Note that this function is defined in spec_helper
+ enable_ha_tests
end
end
# NB: Only testing defaults here, specialized enabling L3 tests elsewhere
# Note that this function is defined in spec_helper
enable_l3_tests
+
+ # Run tests that specialize in checking ODL OVSDB HA config
+ # NB: Only testing defaults here, specialized enabling HA tests elsewhere
+ # Note that this function is defined in spec_helper
+ enable_ha_tests
end
end
# NB: Only testing defaults here, specialized enabling L3 tests elsewhere
# Note that this function is defined in spec_helper
enable_l3_tests
+
+ # Run tests that specialize in checking ODL OVSDB HA config
+ # NB: Only testing defaults here, specialized enabling HA tests elsewhere
+ # Note that this function is defined in spec_helper
+ enable_ha_tests
end
end
}}
let(:params) {{
- :enable_l3 => false ,
+ :enable_l3 => false,
}}
# Run shared tests applicable to all supported OSs
end
end
+ # All OVSDB HA enable/disable tests
+ describe 'OVSDB HA enable/disable tests' 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 enable_ha default' 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 that specialize in checking ODL OVSDB HA config
+ # Note that this function is defined in spec_helper
+ enable_ha_tests
+ end
+
+ context 'using false for enable_ha' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :enable_ha => false,
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test that specialize in checking ODL OVSDB HA config
+ # Note that this function is defined in spec_helper
+ enable_ha_tests(enable_ha: false)
+ end
+
+ context 'using true for enable_ha' do
+ context 'using ha_node_count >=2' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :enable_ha => true,
+ :ha_node_ips => ['0.0.0.0', '127.0.0.1']
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test that specialize in checking ODL OVSDB HA config
+ # Note that this function is defined in spec_helper
+ enable_ha_tests(enable_ha: true, ha_node_ips: ['0.0.0.0', '127.0.0.1'])
+ end
+ end
+ end
+
+
# All install method tests
describe 'install method tests' do
# Non-OS-type tests assume CentOS 7
'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]',
end
end
+def enable_ha_tests(options = {})
+ # Extract params
+ enable_ha = options.fetch(:enable_ha, false)
+ ha_node_ips = options.fetch(:ha_node_ips, [])
+ ha_node_index = options.fetch(:ha_node_index, '')
+ # HA_NODE_IPS size
+ ha_node_count = ha_node_ips.size
+
+ if enable_ha
+ # Confirm ODL OVSDB HA is enabled
+ if ha_node_count >=2
+ # Check for HA_NODE_COUNT >= 2
+ it {
+ should contain_file('opendaylight/jolokia.xml').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/deploy/jolokia.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl'
+ )
+ }
+ else
+ # Check for HA_NODE_COUNT < 2
+ fail("Number of HA nodes less than 2: #{ha_node_count} and HA Enabled")
+ end
+ end
+end
+
def tarball_install_tests(options = {})
# Extract params
# NB: These default values should be the same as ones in opendaylight::params
'ensure' => 'present',
)
}
+
+ it {
+ should contain_file_line('odl_start_ipv4').with(
+ 'ensure' => 'present',
+ 'path' => '/usr/lib/systemd/system/opendaylight.service',
+ 'line' => 'Environment=_JAVA_OPTIONS=\'-Djava.net.preferIPv4Stack=true\'',
+ 'after' => 'ExecStart=/opt/opendaylight/bin/start',
+ )
+ }
end
# Shared tests for unsupported OSs
# NB: This default value should be the same as one in opendaylight::params
# TODO: Remove this possible source of bugs^^
+ 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')}
+
if os_release != '7.3' and sg_mode == 'stateful'
# Confirm sg_mode becomes learn
it {
odl_rest_port = options.fetch(:odl_rest_port, 8080)
log_levels = options.fetch(:log_levels, {})
enable_l3 = options.fetch(:enable_l3, 'no')
+ enable_ha = options.fetch(:enable_ha, false)
+ ha_node_ips = options.fetch(:ha_node_ips, [])
+ ha_node_index = options.fetch(:ha_node_index, '')
# Build script for consumption by Puppet apply
it 'should work idempotently with no errors' do
extra_features => #{extra_features},
odl_rest_port=> #{odl_rest_port},
enable_l3=> #{enable_l3},
+ enable_ha=> #{enable_ha},
+ ha_node_ips=> #{ha_node_ips},
+ ha_node_index=> #{ha_node_index},
log_levels=> #{log_levels},
}
EOS
end
end
+# Shared function for validations related to ODL OVSDB HA config
+def enable_ha_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^^
+ enable_ha = options.fetch(:enable_ha, false)
+ ha_node_ips = options.fetch(:ha_node_ips, [])
+ ha_node_index = options.fetch(:ha_node_index, '')
+ # HA_NODE_IPS size
+ ha_node_count = ha_node_ips.size
+
+ if enable_ha
+ # Confirm ODL OVSDB HA is enabled
+ if ha_node_count >=2
+ # Check for HA_NODE_COUNT >= 2
+ describe file('/opt/opendaylight/deploy/jolokia.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ end
+ else
+ # Check for HA_NODE_COUNT < 2
+ fail("Number of HA nodes less than 2: #{ha_node_count} and HA Enabled")
+ end
+ end
+end
+
# Shared function that handles validations specific to RPM-type installs
def rpm_validations()
rpm_repo = ENV['RPM_REPO']