Update Fedora versions supported, testing levels
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper_acceptance.rb
index beb7364abacf959d813e01bde4291b65186373db..f911b3d40e965d73d19a99c35beb386339b3090a 100644 (file)
@@ -7,6 +7,8 @@ unless ENV['BEAKER_provision'] == 'no'
     # Install Puppet
     if host.is_pe?
       install_pe
+    elsif host.name == "ubuntu-16-docker" || host.name == "ubuntu-16"
+      install_puppet_agent_on(host, puppet_collection: "pc1")
     else
       install_puppet
     end
@@ -28,10 +30,8 @@ RSpec.configure do |c|
     hosts.each do |host|
       # Install stdlib, a dependency of the odl mod
       on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0] }
-      # Install archive, a dependency of the odl mod use for tarball-type installs
-      on host, puppet('module', 'install', 'camptocamp-archive'), { :acceptable_exit_codes => [0] }
-      # Install Java Puppet mod, a dependency of the tarball install method
-      on host, puppet('module', 'install', 'puppetlabs-java'), { :acceptable_exit_codes => [0] }
+      # Install apt, a dependency of the deb install method
+      on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0] }
     end
   end
 end
@@ -46,28 +46,44 @@ end
 #   http://serverspec.org/resource_types.html
 
 def install_odl(options = {})
+  # Install params are passed via environment var, set in Rakefile
+  # Changing the installed version of ODL via `puppet apply` is not supported
+  # by puppet-odl, so it's not possible to vary these params in the same
+  # Beaker test run. Do a different run passing different env vars.
+  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
-  # Default install method is passed via environment var, set in Rakefile
-  install_method = options.fetch(:install_method, ENV['INSTALL_METHOD'])
   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)
   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, 0)
 
   # Build script for consumption by Puppet apply
   it 'should work idempotently with no errors' do
     pp = <<-EOS
     class { 'opendaylight':
-      install_method => #{install_method},
+      rpm_repo => '#{rpm_repo}',
+      deb_repo => '#{deb_repo}',
       default_features => #{default_features},
       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
@@ -75,13 +91,12 @@ def install_odl(options = {})
     # Apply our Puppet manifest on the Beaker host
     apply_manifest(pp, :catch_failures => true)
 
-    # The tarball extract isn't idempotent, can't do this check
-    # See: https://github.com/dfarrell07/puppet-opendaylight/issues/45#issuecomment-78135725
-    if install_method != 'tarball'
-      # Run it twice to test for idempotency
-      apply_manifest(pp, :catch_changes  => true)
+    # Not checking for idempotence because of false failures
+    # related to package manager cache updates outputting to
+    # stdout and different IDs for the puppet manifest apply.
+    # I think this is a limitation in how Beaker can check
+    # for changes, not a problem with the Puppet module.
     end
-  end
 end
 
 # Shared function that handles generic validations
@@ -98,10 +113,10 @@ def generic_validations()
   describe service('opendaylight') do
     it { should be_enabled }
     it { should be_enabled.with_level(3) }
-    it { should be_running }
+    it { should be_running.under('systemd') }
   end
 
-  # Creation handled by RPM, or Puppet during tarball installs
+  # Creation handled by RPM or Deb
   describe user('odl') do
     it { should exist }
     it { should belong_to_group 'odl' }
@@ -114,7 +129,7 @@ def generic_validations()
     it { should have_home_directory '/opt/opendaylight' }
   end
 
-  # Creation handled by RPM, or Puppet during tarball installs
+  # Creation handled by RPM or Deb
   describe group('odl') do
     it { should exist }
   end
@@ -151,14 +166,7 @@ def generic_validations()
     it { should be_grouped_into 'odl' }
   end
 
-  # Should contain ODL OVSDB L3 enable/disable config file
-  describe file('/opt/opendaylight/etc/custom.properties') do
-    it { should be_file }
-    it { should be_owned_by 'odl' }
-    it { should be_grouped_into 'odl' }
-  end
-
-  if ['centos-7', 'centos-7-docker', 'fedora-22'].include? ENV['RS_SET']
+  if ['centos-7', 'centos-7-docker'].include? ENV['RS_SET']
     # Validations for modern Red Hat family OSs
 
     # Verify ODL systemd .service file
@@ -173,21 +181,23 @@ def generic_validations()
     describe package('java-1.8.0-openjdk') do
       it { should be_installed }
     end
-  elsif ['ubuntu-1404', 'ubuntu-1404-docker'].include? ENV['RS_SET']
-    # Ubuntu-specific validations
 
-    # Verify ODL Upstart config file
-    describe file('/etc/init/opendaylight.conf') do
+  # Ubuntu 16.04 specific validation
+  elsif ['ubuntu-16', 'ubuntu-16-docker'].include? ENV['RS_SET']
+
+    # Verify ODL systemd .service file
+    describe file('/lib/systemd/system/opendaylight.service') do
       it { should be_file }
       it { should be_owned_by 'root' }
       it { should be_grouped_into 'root' }
       it { should be_mode '644' }
     end
 
-    # Java 7 should be installed
-    describe package('openjdk-7-jdk') do
+    # Java 8 should be installed
+    describe package('openjdk-8-jre-headless') do
       it { should be_installed }
     end
+
   else
     fail("Unexpected RS_SET (host OS): #{ENV['RS_SET']}")
   end
@@ -269,30 +279,34 @@ def log_level_validations(options = {})
         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 /^log4j.logger.#{logger} = #{level}/ }
       end
     end
   end
 end
 
-# Shared function for validations related to ODL OVSDB L3 config
-def enable_l3_validations(options = {})
+# 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_l3 = options.fetch(:enable_l3, 'no')
-
-  describe file('/opt/opendaylight/etc/custom.properties') do
-    it { should be_file }
-    it { should be_owned_by 'odl' }
-    it { should be_grouped_into 'odl' }
-    its(:content) { should match /ovsdb.l3.fwd.enabled=#{enable_l3}/ }
+  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_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
 end
 
 # Shared function that handles validations specific to RPM-type installs
 def rpm_validations()
-  describe yumrepo('opendaylight-4-testing') do
+  rpm_repo = ENV['RPM_REPO']
+
+  describe yumrepo(rpm_repo) do
     it { should exist }
     it { should be_enabled }
   end
@@ -302,17 +316,17 @@ def rpm_validations()
   end
 end
 
-# Shared function that handles validations specific to tarball-type installs
-def tarball_validations()
-  describe package('opendaylight') do
-    it { should_not be_installed }
+# Shared function that handles validations specific to Deb-type installs
+def deb_validations()
+  deb_repo = ENV['DEB_REPO']
+  # Check ppa
+  # Docs: http://serverspec.org/resource_types.html#ppa
+  describe ppa(deb_repo) do
+    it { should exist }
+    it { should be_enabled }
   end
 
-  # Repo checks break (not fail) when yum doesn't make sense (Ubuntu)
-  if ['centos-7', 'fedora-22'].include? ENV['RS_SET']
-    describe yumrepo('opendaylight-4-testing') do
-      it { should_not exist }
-      it { should_not be_enabled }
-    end
+  describe package('opendaylight') do
+    it { should be_installed }
   end
 end