Don't do yum-specific checks for non-RH OSs
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper.rb
index b8dac8b6423c145646d758ee71bdd4b7aa261a19..7f4c44fc9c1d4863fb8d62b5c91e9ad95d065772 100644 (file)
@@ -69,12 +69,23 @@ def generic_tests()
     should contain_file('org.apache.karaf.features.cfg').with(
       'ensure'      => 'file',
       'path'        => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+      'owner'   => 'odl',
+      'group'   => 'odl',
     )
   }
 end
 
 # Shared tests that specialize in testing Karaf feature installs
-def karaf_feature_tests(features)
+def karaf_feature_tests(options = {})
+  # Extract params
+  # NB: This default list should be the same as the one in opendaylight::params
+  # TODO: Remove this possible source of bugs^^
+  default_features = options.fetch(:default_features, ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management'])
+  extra_features = options.fetch(:extra_features, [])
+
+  # The order of this list concat matters
+  features = default_features + extra_features
+
   # Confirm properties of other 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.
@@ -82,6 +93,8 @@ def karaf_feature_tests(features)
     should contain_file('org.apache.karaf.features.cfg').with(
       'ensure'      => 'file',
       'path'        => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+      'owner'   => 'odl',
+      'group'   => 'odl',
       'content'     => /^featuresBoot=#{features.join(",")}/
     )
   }
@@ -188,7 +201,7 @@ def tarball_install_tests(options = {})
     # Validations specific to Debain family OSs (Ubuntu)
     it {
       should contain_package('java').with(
-        'name' => 'java7-jdk',
+        'name' => 'openjdk-7-jdk',
       )
     }
     it {
@@ -199,6 +212,15 @@ def tarball_install_tests(options = {})
         'mode'    => '0644',
       )
     }
+    expected_msg = 'Debian has limited support, is less stable, less tested.'
+    it {
+      expect {
+        # This could be any check, most (all?) will raise warning
+        should contain_file('/etc/init/opendaylight.conf').to(
+          raise_warning(Puppet::Warning, /#{expected_msg}/)
+        )
+      }
+    }
   else
     fail("Unexpected osfamily #{osfamily}")
   end
@@ -210,8 +232,18 @@ end
 
 def rpm_install_tests(options = {})
   # Extract params
+  # Choose Yum URL based on OS (CentOS vs Fedora)
+  operatingsystem  = options.fetch(:operatingsystem, 'CentOS')
+  case operatingsystem
+  when 'CentOS'
+    yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
+  when 'Fedora'
+    yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/fedora-$releasever-$basearch/'
+  else
+    fail("Unknown operatingsystem: #{operatingsystem}")
+  end
+
   # Default to CentOS 7 Yum repo URL
-  yum_repo = options.fetch(:yum_repo, 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/')
 
   # Confirm presence of RPM-related resources
   it { should contain_yumrepo('opendaylight') }
@@ -240,16 +272,19 @@ def rpm_install_tests(options = {})
 end
 
 # Shared tests for unsupported OSs
-def unsupported_os_tests(expected_err_msg)
+def unsupported_os_tests(options = {})
+  # Extract params
+  expected_msg = options.fetch(:expected_msg)
+
   # Confirm that classes fail on unsupported OSs
-  it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
-  it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
-  it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
-  it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
+  it { expect { should contain_class('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_class('opendaylight::install') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_class('opendaylight::config') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_class('opendaylight::service') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
 
   # Confirm that other resources fail on unsupported OSs
-  it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
-  it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
-  it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
-  it { expect { should contain_file('org.apache.karaf.features.cfg') }.to raise_error(Puppet::Error, /#{expected_err_msg}/) }
+  it { expect { should contain_yumrepo('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_package('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_service('opendaylight') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
+  it { expect { should contain_file('org.apache.karaf.features.cfg') }.to raise_error(Puppet::Error, /#{expected_msg}/) }
 end