Beaker tests, including tarball install ones
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper_acceptance.rb
index 0a8106251d693e4235a4b4940dbf796363f6c7a7..b0f29670847e2ea7faa7e8ce5b234b85d40a1075 100644 (file)
@@ -41,12 +41,18 @@ end
 # NB: These are a library of helper fns used by the Beaker tests
 #
 
+# NB: There are a large number of helper functions used in these tests.
+# They make this code much more friendly, but may need to be referenced.
+# The serverspec helpers (`should`, `be_running`...) are documented here:
+#   http://serverspec.org/resource_types.html
+
 def install_odl(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^^
   # Extract params if given, defaulting to odl class defaults if not
-  install_method = options.fetch(:install_method, 'rpm')
+  # 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'])
@@ -63,8 +69,13 @@ def install_odl(options = {})
 
     # Apply our Puppet manifest on the Beaker host
     apply_manifest(pp, :catch_failures => true)
-    # Run it twice to test for idempotency
-    apply_manifest(pp, :catch_changes  => 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)
+    end
   end
 end
 
@@ -77,7 +88,14 @@ def generic_validations()
     it { should be_directory }
     it { should be_owned_by 'odl' }
     it { should be_grouped_into 'odl' }
-    it { should be_mode '775' }
+  end
+
+  # Verify ODL systemd .service file
+  describe file('/usr/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
 
   # Verify ODL's systemd service
@@ -87,11 +105,6 @@ def generic_validations()
     it { should be_running }
   end
 
-  # OpenDaylight will appear as a Java process
-  describe process('java') do
-    it { should be_running }
-  end
-
   # Creation handled by RPM, or Puppet during tarball installs
   # TODO: It'd be nice to do this independently of install dir name
   describe user('odl') do
@@ -100,19 +113,27 @@ def generic_validations()
     it { should have_home_directory '/opt/opendaylight-0.2.2' }
   end
 
+  # Creation handled by RPM, or Puppet during tarball installs
+  describe group('odl') do
+    it { should exist }
+  end
+
   # This should not be the odl user's home dir
   describe file('/home/odl') do
     # Home dir shouldn't be created for odl user
     it { should_not be_directory }
   end
 
-  # Verify ODL systemd .service file
-  describe file('/usr/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' }
+  # Java 7 should be installed
+  describe package('java-1.7.0-openjdk') do
+    it { should be_installed }
+  end
+
+  # OpenDaylight will appear as a Java process
+  describe process('java') do
+    it { should be_running }
   end
+
 end
 
 # Shared function for validations related to the Karaf config file
@@ -132,7 +153,6 @@ def karaf_config_validations(options = {})
     it { should be_file }
     it { should be_owned_by 'odl' }
     it { should be_grouped_into 'odl' }
-    it { should be_mode '775' }
     its(:content) { should match /^featuresBoot=#{features.join(",")}/ }
   end
 end
@@ -148,3 +168,15 @@ def rpm_validations()
     it { should be_installed }
   end
 end
+
+# Shared function that handles validations specific to tarball-type installs
+def tarball_validations()
+  describe yumrepo('opendaylight') do
+    it { should_not exist }
+    it { should_not be_enabled }
+  end
+
+  describe package('opendaylight') do
+    it { should_not be_installed }
+  end
+end