+ 'path' => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ )
+ }
+ it {
+ should contain_file_line('featuresBoot').with(
+ 'path' => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+ 'line' => "featuresBoot=#{features_csv}",
+ 'match' => '^featuresBoot=.*$',
+ )
+ }
+end
+
+# Shared tests that specialize in testing ODL's REST port config
+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)
+
+ # 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('jetty.xml').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/jetty.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /Property name="jetty.port" default="#{odl_rest_port}"/
+ )
+ }
+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')
+ }
+ else
+ # Verify each custom log level config entry
+ log_levels.each_pair do |logger, level|
+ it {
+ should contain_file_line("logger-#{logger}").with(
+ 'ensure' => 'present',
+ 'path' => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+ 'line' => "log4j.logger.#{logger}=#{level}",
+ )
+ }
+ end
+ end
+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_db_modules = options.fetch(:ha_db_modules, { 'default' => false })
+ # HA_NODE_IPS size
+ ha_node_count = ha_node_ips.size
+
+ if (enable_ha) && (ha_node_count < 2)
+ # 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 = {})
+ # Extract params
+ rpm_repo = options.fetch(:rpm_repo, 'opendaylight-6-testing')
+ java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+
+ # Default to CentOS 7 Yum repo URL
+
+ # Confirm presence of RPM-related resources
+ it { should contain_yumrepo(rpm_repo) }
+ it { should contain_package('opendaylight') }
+
+ # Confirm relationships between RPM-related resources
+ it { should contain_package('opendaylight').that_requires("Yumrepo[#{rpm_repo}]") }
+ it { should contain_yumrepo(rpm_repo).that_comes_before('Package[opendaylight]') }
+
+ # Confirm properties of RPM-related resources
+ # 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_yumrepo(rpm_repo).with(
+ 'enabled' => '1',
+ 'gpgcheck' => '0',
+ 'descr' => 'OpenDaylight SDN Controller',
+ 'baseurl' => "http://cbs.centos.org/repos/nfv7-#{rpm_repo}/$basearch/os/",
+ )
+ }
+ it {
+ should contain_package('opendaylight').with(
+ '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 = {})
+ # Extract params
+ deb_repo = options.fetch(:deb_repo, 'ppa:odl-team/carbon')
+
+ # Confirm the presence of Deb-related resources
+ it { should contain_apt__ppa(deb_repo) }
+ it { should contain_package('opendaylight') }
+
+ # Confirm relationships between Deb-related resources
+ it { should contain_package('opendaylight').that_requires("Apt::Ppa[#{deb_repo}]") }
+ it { should contain_apt__ppa(deb_repo).that_comes_before('Package[opendaylight]') }
+
+ # Confirm presence of Deb-related resources
+ it {
+ should contain_package('opendaylight').with(
+ 'ensure' => 'present',