]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Fixes to make the tests run under Debian as well as Ubuntu.
authorAshley Penney <ashley.penney@puppetlabs.com>
Thu, 9 Jan 2014 23:26:32 +0000 (18:26 -0500)
committerAshley Penney <ashley.penney@puppetlabs.com>
Thu, 9 Jan 2014 23:26:32 +0000 (18:26 -0500)
spec/acceptance/apt_ppa_spec.rb
spec/acceptance/apt_source_spec.rb
spec/acceptance/backports_spec.rb
spec/acceptance/force_spec.rb
spec/acceptance/release_spec.rb
spec/acceptance/unattended_upgrade_spec.rb

index f9369802431a18c86feb27a6d794187946ab182a..c0d216107de96913cebfaae9de713df8eff30958 100644 (file)
@@ -1,61 +1,20 @@
 require 'spec_helper_acceptance'
 
-describe 'apt::ppa' do
+if fact('operatingsystem') == 'Ubuntu'
+  describe 'apt::ppa' do
 
-  context 'reset' do
-    it 'removes ppa' do
-      shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
-      shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
-    end
-  end
-
-  context 'adding a ppa that doesnt exist' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include '::apt'
-      apt::ppa { 'ppa:canonical-kernel-team/ppa': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe 'contains the source file' do
-      it 'contains a kernel ppa source' do
-        shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
+    context 'reset' do
+      it 'removes ppa' do
+        shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
+        shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
       end
     end
-  end
-
-  context 'readding a removed ppa.' do
-    it 'setup' do
-      shell('add-apt-repository -y ppa:raravena80/collectd5')
-      # This leaves a blank file
-      shell('add-apt-repository --remove ppa:raravena80/collectd5')
-    end
-
-    it 'should readd it successfully' do
-      pp = <<-EOS
-      include '::apt'
-      apt::ppa { 'ppa:raravena80/collectd5': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-  end
 
-  context 'reset' do
-    it 'removes added ppas' do
-      shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
-      shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
-    end
-  end
-
-  context 'ensure' do
-    context 'present' do
-      it 'works without failure' do
+    context 'adding a ppa that doesnt exist' do
+      it 'should work with no errors' do
         pp = <<-EOS
         include '::apt'
-        apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present }
+        apt::ppa { 'ppa:canonical-kernel-team/ppa': }
         EOS
 
         apply_manifest(pp, :catch_failures => true)
@@ -67,72 +26,115 @@ describe 'apt::ppa' do
         end
       end
     end
-  end
 
-  context 'ensure' do
-    context 'absent' do
-      it 'works without failure' do
+    context 'readding a removed ppa.' do
+      it 'setup' do
+        shell('add-apt-repository -y ppa:raravena80/collectd5')
+        # This leaves a blank file
+        shell('add-apt-repository --remove ppa:raravena80/collectd5')
+      end
+
+      it 'should readd it successfully' do
         pp = <<-EOS
         include '::apt'
-        apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
+        apt::ppa { 'ppa:raravena80/collectd5': }
         EOS
 
         apply_manifest(pp, :catch_failures => true)
       end
+    end
 
-      describe 'doesnt contain the source file' do
-        it 'fails' do
-          shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
-        end
+    context 'reset' do
+      it 'removes added ppas' do
+        shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
+        shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
       end
     end
-  end
 
-  context 'release' do
-    context 'precise' do
-      it 'works without failure' do
-        pp = <<-EOS
-        include '::apt'
-        apt::ppa { 'ppa:canonical-kernel-team/ppa':
-          ensure  => present,
-          release => precise,
-        }
-        EOS
+    context 'ensure' do
+      context 'present' do
+        it 'works without failure' do
+          pp = <<-EOS
+          include '::apt'
+          apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present }
+          EOS
 
-        shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
+          apply_manifest(pp, :catch_failures => true)
+        end
+
+        describe 'contains the source file' do
+          it 'contains a kernel ppa source' do
+            shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
+          end
+        end
       end
+    end
+
+    context 'ensure' do
+      context 'absent' do
+        it 'works without failure' do
+          pp = <<-EOS
+          include '::apt'
+          apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
+          EOS
 
-      describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
-        it { should be_file }
+          apply_manifest(pp, :catch_failures => true)
+        end
+
+        describe 'doesnt contain the source file' do
+          it 'fails' do
+            shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
+          end
+        end
       end
     end
-  end
 
-  context 'options' do
-    context '-y' do
-      it 'works without failure' do
-        pp = <<-EOS
-        include '::apt'
-        apt::ppa { 'ppa:canonical-kernel-team/ppa':
-          ensure  => present,
-          release => precise,
-          options => '-y',
-        }
-        EOS
+    context 'release' do
+      context 'precise' do
+        it 'works without failure' do
+          pp = <<-EOS
+          include '::apt'
+          apt::ppa { 'ppa:canonical-kernel-team/ppa':
+            ensure  => present,
+            release => precise,
+          }
+          EOS
+
+          shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
+          apply_manifest(pp, :catch_failures => true)
+        end
 
-        shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
+        describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
+          it { should be_file }
+        end
       end
+    end
+
+    context 'options' do
+      context '-y' do
+        it 'works without failure' do
+          pp = <<-EOS
+          include '::apt'
+          apt::ppa { 'ppa:canonical-kernel-team/ppa':
+            ensure  => present,
+            release => precise,
+            options => '-y',
+          }
+          EOS
+
+          shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
+          apply_manifest(pp, :catch_failures => true)
+        end
 
-      describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
-        it { should be_file }
+        describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
+          it { should be_file }
+        end
       end
     end
-  end
 
-  context 'reset' do
-    it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
-  end
+    context 'reset' do
+      it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
+    end
 
+  end
 end
index 273add56fa69fb7d00e4c7d2340cf1c1dba5a70e..6b026b88c958ae918e7bf3b3ad26ccf5d2f14d91 100644 (file)
@@ -255,6 +255,7 @@ describe 'apt::source' do
         apt::source { 'puppetlabs':
           ensure     => present,
           location   => 'http://apt.puppetlabs.com',
+          release    => 'precise',
           repos      => 'main',
           key        => '4BD6EC30',
           key_source  => 'http://apt.puppetlabs.com/pubkey.gpg',
index ffb14ce62854b99719087368463e22348f630f55..80e2093848c6114ddd5676a8bd88befb713db97e 100644 (file)
@@ -1,5 +1,13 @@
 require 'spec_helper_acceptance'
 
+codename = fact('lsbdistcodename')
+case fact('operatingsystem')
+when 'Ubuntu'
+  repos = 'main universe multiverse restricted'
+when 'Debian'
+  repos = 'main contrib non-free'
+end
+
 describe 'apt::backports class' do
   context 'defaults' do
     it 'should work with no errors' do
@@ -14,7 +22,7 @@ describe 'apt::backports class' do
   context 'release' do
     it 'should work with no errors' do
       pp = <<-EOS
-      class { 'apt::backports': release => 'precise' }
+      class { 'apt::backports': release => '#{codename}' }
       EOS
 
       apply_manifest(pp, :catch_failures => true)
@@ -22,7 +30,7 @@ describe 'apt::backports class' do
 
     describe file('/etc/apt/sources.list.d/backports.list') do
       it { should be_file }
-      it { should contain 'precise-backports main universe multiverse restricted' }
+      it { should contain "#{codename}-backports #{repos}" }
     end
   end
 
@@ -37,7 +45,7 @@ describe 'apt::backports class' do
 
     describe file('/etc/apt/sources.list.d/backports.list') do
       it { should be_file }
-      it { should contain 'deb http://localhost/ubuntu precise-backports main universe multiverse restricted' }
+      it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" }
     end
   end
 
index f7e374be3a29facf6da77e0f859cd732d0d5fcb7..c364d5fe157fdb05ea4b7e2fa6ff235841e3ee8d 100644 (file)
@@ -1,5 +1,7 @@
 require 'spec_helper_acceptance'
 
+codename = fact('lsbdistcodename')
+
 describe 'apt::force define' do
   context 'defaults' do
     it 'should work with no errors' do
@@ -21,12 +23,12 @@ describe 'apt::force define' do
     it 'should work with no errors' do
       pp = <<-EOS
       include apt
-      apt::force { 'vim': release => 'precise' }
+      apt::force { 'vim': release => '#{codename}' }
       EOS
 
       shell('apt-get remove -y vim')
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/apt-get -y -t precise install vim/)
+        expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
       end
     end
 
@@ -57,7 +59,7 @@ describe 'apt::force define' do
     it 'should work with no errors' do
       pp = <<-EOS
       include apt
-      apt::force { 'tomcat7': timeout => '1' }
+      apt::force { 'vim': timeout => '1' }
       EOS
 
       shell('apt-get clean')
index 44491e3ef96ad5c8f15ce4b104b860d8c0bcf059..81d7ca0c4d7c33eb241cfa7708f68e0b3b4126bf 100644 (file)
@@ -17,4 +17,10 @@ describe 'apt::release class' do
     end
   end
 
+  context 'reset' do
+    it 'cleans up' do
+      shell('rm -rf /etc/apt/apt.conf.d/01release')
+    end
+  end
+
 end
index 287e5ec8e825d39ebd1cd643bb6f187d33c5c54c..a0349d40d7ca303e48c4229e47ed7a0cfed64302 100644 (file)
@@ -8,6 +8,10 @@ describe 'apt::unattended_upgrades class' do
       include apt::unattended_upgrades
       EOS
 
+      # Attempted workaround for problems seen on debian with
+      # something holding the package database open.
+      #shell('killall -9 apt-get')
+      #shell('killall -9 dpkg')
       apply_manifest(pp, :catch_failures => true)
     end