Connect generic rspec tests to Ubuntu 14.04 tests
[integration/packaging/puppet-opendaylight.git] / spec / classes / opendaylight_spec.rb
index b18745ba2eb9e303419662e2246bcc8381a7d640..64622944765719db52b1473c127b056e7097ff1e 100644 (file)
@@ -21,8 +21,9 @@ describe 'opendaylight' do
               :operatingsystem => operatingsystem,
               :operatingsystemmajrelease => operatingsystemmajrelease,
             }}
-            # TODO: Call supported-OS-specific tests
-            it { should compile }
+            # Run shared tests applicable to all supported OSs
+            # Note that this function is defined in spec_helper
+            generic_tests
           end
         end
 
@@ -56,8 +57,9 @@ describe 'opendaylight' do
               :operatingsystem => operatingsystem,
               :operatingsystemmajrelease => operatingsystemmajrelease,
             }}
-            # TODO: Call supported-OS-specific tests
-            it { should compile }
+            # Run shared tests applicable to all supported OSs
+            # Note that this function is defined in spec_helper
+            generic_tests
           end
         end
 
@@ -77,8 +79,59 @@ describe 'opendaylight' do
       end
     end
 
+    # All tests for OSs in the Debian family (Ubuntu)
+    describe 'OS family Debian' do
+      osfamily = 'Debian'
+
+      # All tests for Ubuntu 14.04
+      describe 'Ubuntu' do
+        operatingsystem = 'Ubuntu'
+
+        # All tests for supported versions of Ubuntu
+        ['14.04'].each do |operatingsystemmajrelease|
+          context "#{operatingsystemmajrelease}" do
+            let(:facts) {{
+              :osfamily => osfamily,
+              :operatingsystem => operatingsystem,
+              :operatingsystemmajrelease => operatingsystemmajrelease,
+              :lsbdistcodename => 'trusty',
+              :path => ['/usr/local/bin', '/usr/bin', '/bin'],
+            }}
+
+            # Only the tarball method is supported for Debian-based installs
+            let(:params) {{
+                :install_method => 'tarball',
+            }}
+
+            # Run shared tests applicable to all supported OSs
+            # Note that this function is defined in spec_helper
+            # TODO: These are currently under development
+            generic_tests
+
+            # Run Ubuntu-specific tests
+            # Note that this function is defined in spec_helper
+            ubuntu_tests
+          end
+        end
+
+        # All tests for unsupported versions of Ubuntu
+        ['12.04', '12.10', '13.04', '13.10', '14.10', '15.04'].each do |operatingsystemmajrelease|
+          context "#{operatingsystemmajrelease}" do
+            let(:facts) {{
+              :osfamily => osfamily,
+              :operatingsystem => operatingsystem,
+              :operatingsystemmajrelease => operatingsystemmajrelease,
+            }}
+            # Run shared tests applicable to all unsupported OSs
+            # Note that this function is defined in spec_helper
+            unsupported_os_tests("Unsupported OS: #{operatingsystem} #{operatingsystemmajrelease}")
+          end
+        end
+      end
+    end
+
     # All tests for unsupported OS families
-    ['Debian', 'Suse', 'Solaris'].each do |osfamily|
+    ['Suse', 'Solaris'].each do |osfamily|
       context "OS family #{osfamily}" do
         let(:facts) {{
           :osfamily => osfamily,
@@ -93,7 +146,7 @@ describe 'opendaylight' do
 
   # All Karaf feature tests
   describe 'Karaf feature tests' do
-    # All Karaf feature tests assume CentOS 7
+    # Non-OS-type tests assume CentOS 7
     #   See issue #43 for reasoning:
     #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
     osfamily = 'RedHat'
@@ -101,10 +154,11 @@ describe 'opendaylight' do
     operatingsystemmajrelease = '7'
     # This is the CentOS 7 Yum repo URL
     yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
-    describe "using default features" do
+    describe 'using default features' do
       # NB: This list should be the same as the one in opendaylight::params
+      # TODO: Remove this possible source of bugs^^
       default_features = ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management']
-      context "and not passing extra features" do
+      context 'and not passing extra features' do
         let(:facts) {{
           :osfamily => osfamily,
           :operatingsystem => operatingsystem,
@@ -115,10 +169,14 @@ describe 'opendaylight' do
 
         # Run shared tests applicable to all supported OSs
         # Note that this function is defined in spec_helper
-        supported_os_tests(yum_repo, default_features)
+        generic_tests
+
+        # Run test that specialize in checking Karaf feature installs
+        # Note that this function is defined in spec_helper
+        karaf_feature_tests(default_features)
       end
 
-      context "and passing extra features" do
+      context 'and passing extra features' do
         let(:facts) {{
           :osfamily => osfamily,
           :operatingsystem => operatingsystem,
@@ -126,20 +184,24 @@ describe 'opendaylight' do
         }}
 
         # These are real but arbitrarily chosen features
-        extra_features = ["odl-base-all", "odl-ovsdb-all"]
+        extra_features = ['odl-base-all', 'odl-ovsdb-all']
         let(:params) {{
           :extra_features => extra_features,
         }}
 
         # Run shared tests applicable to all supported OSs
         # Note that this function is defined in spec_helper
-        supported_os_tests(yum_repo, default_features + extra_features)
+        generic_tests
+
+        # Run test that specialize in checking Karaf feature installs
+        # Note that this function is defined in spec_helper
+        karaf_feature_tests(default_features + extra_features)
       end
     end
 
-    describe "overriding default features" do
-      default_features = ["standard", "ssh"]
-      context "and not passing extra features" do
+    describe 'overriding default features' do
+      default_features = ['standard', 'ssh']
+      context 'and not passing extra features' do
         let(:facts) {{
           :osfamily => osfamily,
           :operatingsystem => operatingsystem,
@@ -152,10 +214,14 @@ describe 'opendaylight' do
 
         # Run shared tests applicable to all supported OSs
         # Note that this function is defined in spec_helper
-        supported_os_tests(yum_repo, default_features)
+        generic_tests
+
+        # Run test that specialize in checking Karaf feature installs
+        # Note that this function is defined in spec_helper
+        karaf_feature_tests(default_features)
       end
 
-      context "and passing extra features" do
+      context 'and passing extra features' do
         let(:facts) {{
           :osfamily => osfamily,
           :operatingsystem => operatingsystem,
@@ -163,7 +229,7 @@ describe 'opendaylight' do
         }}
 
         # These are real but arbitrarily chosen features
-        extra_features = ["odl-base-all", "odl-ovsdb-all"]
+        extra_features = ['odl-base-all', 'odl-ovsdb-all']
         let(:params) {{
           :default_features => default_features,
           :extra_features => extra_features,
@@ -171,7 +237,153 @@ describe 'opendaylight' do
 
         # Run shared tests applicable to all supported OSs
         # Note that this function is defined in spec_helper
-        supported_os_tests(yum_repo, default_features + extra_features)
+        generic_tests
+
+        # Run test that specialize in checking Karaf feature installs
+        # Note that this function is defined in spec_helper
+        karaf_feature_tests(default_features + extra_features)
+      end
+    end
+  end
+
+  # All install method tests
+  describe 'install method 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'
+    operatingsystemrelease = '7.0'
+    operatingsystemmajrelease = '7'
+    # This is the CentOS 7 Yum repo URL
+    yum_repo = 'https://copr-be.cloud.fedoraproject.org/results/dfarrell07/OpenDaylight/epel-7-$basearch/'
+
+    # All tests for RPM install method
+    context 'RPM' do
+      let(:facts) {{
+        :osfamily => osfamily,
+        :operatingsystem => operatingsystem,
+        :operatingsystemmajrelease => operatingsystemmajrelease,
+      }}
+
+      let(:params) {{
+          :install_method => 'rpm',
+      }}
+
+      # 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 Karaf feature installs
+      # Note that this function is defined in spec_helper
+      install_method_tests('rpm', yum_repo)
+    end
+
+    # All tests for tarball install method
+    describe 'tarball' do
+      describe 'using default tarball_url' do
+        tarball_url = 'https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.2.2-Helium-SR2/distribution-karaf-0.2.2-Helium-SR2.tar.gz'
+        context 'using default unitfile_url' do
+          unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
+          let(:facts) {{
+            :osfamily => osfamily,
+            :operatingsystem => operatingsystem,
+            :operatingsystemrelease => operatingsystemrelease,
+            :operatingsystemmajrelease => operatingsystemmajrelease,
+            :path => ['/usr/local/bin', '/usr/bin', '/bin'],
+          }}
+
+          let(:params) {{
+              :install_method => 'tarball',
+          }}
+
+          # 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 Karaf feature installs
+          # Note that this function is defined in spec_helper
+          install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
+        end
+
+        context 'overriding default unitfile_url' do
+          # Doesn't matter if this is valid, just that it honors what we pass
+          unitfile_url = 'fake_unitfile'
+          let(:facts) {{
+            :osfamily => osfamily,
+            :operatingsystem => operatingsystem,
+            :operatingsystemrelease => operatingsystemrelease,
+            :operatingsystemmajrelease => operatingsystemmajrelease,
+            :path => ['/usr/local/bin', '/usr/bin', '/bin'],
+          }}
+
+          let(:params) {{
+              :install_method => 'tarball',
+              :unitfile_url => unitfile_url,
+          }}
+
+          # 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 Karaf feature installs
+          # Note that this function is defined in spec_helper
+          install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
+        end
+      end
+
+      describe 'overriding default tarball_url' do
+        # Doesn't matter if this is valid, just that it honors what we pass
+        tarball_url = 'fake_tarball'
+        context 'using default unitfile_url' do
+          unitfile_url = 'https://github.com/dfarrell07/opendaylight-systemd/archive/master/opendaylight-unitfile.tar.gz'
+          let(:facts) {{
+            :osfamily => osfamily,
+            :operatingsystem => operatingsystem,
+            :operatingsystemrelease => operatingsystemrelease,
+            :operatingsystemmajrelease => operatingsystemmajrelease,
+            :path => ['/usr/local/bin', '/usr/bin', '/bin'],
+          }}
+
+          let(:params) {{
+              :install_method => 'tarball',
+              :tarball_url => tarball_url,
+          }}
+
+          # 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 Karaf feature installs
+          # Note that this function is defined in spec_helper
+          install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
+        end
+
+        context 'overriding default unitfile_url' do
+          # Doesn't matter if this is valid, just that it honors what we pass
+          unitfile_url = 'fake_unitfile'
+          let(:facts) {{
+            :osfamily => osfamily,
+            :operatingsystem => operatingsystem,
+            :operatingsystemrelease => operatingsystemrelease,
+            :operatingsystemmajrelease => operatingsystemmajrelease,
+            :path => ['/usr/local/bin', '/usr/bin', '/bin'],
+          }}
+
+          let(:params) {{
+              :install_method => 'tarball',
+              :tarball_url => tarball_url,
+              :unitfile_url => unitfile_url,
+          }}
+
+          # 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 Karaf feature installs
+          # Note that this function is defined in spec_helper
+          install_method_tests('tarball', yum_repo, tarball_url, unitfile_url)
+        end
       end
     end
   end