]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #206 from apenney/beaker-rspec
authorAshley Penney <ashley.penney@puppetlabs.com>
Mon, 6 Jan 2014 23:04:43 +0000 (15:04 -0800)
committerAshley Penney <ashley.penney@puppetlabs.com>
Mon, 6 Jan 2014 23:04:43 +0000 (15:04 -0800)
Convert existing tests over to beakr-rspec.

13 files changed:
.nodeset.yml [deleted file]
Gemfile
spec/acceptance/apt_builddep_spec.rb [moved from spec/system/apt_builddep_spec.rb with 86% similarity]
spec/acceptance/apt_key_spec.rb [moved from spec/system/apt_key_spec.rb with 74% similarity]
spec/acceptance/apt_ppa_spec.rb [moved from spec/system/apt_ppa_spec.rb with 57% similarity]
spec/acceptance/apt_source_spec.rb [moved from spec/system/apt_source_spec.rb with 75% similarity]
spec/acceptance/class_spec.rb [moved from spec/system/class_spec.rb with 61% similarity]
spec/acceptance/nodesets/debian-70rc1-x64.yml [new file with mode: 0644]
spec/acceptance/nodesets/default.yml [new file with mode: 0644]
spec/acceptance/nodesets/ubuntu-server-12042-x64.yml [new file with mode: 0644]
spec/spec_helper_acceptance.rb [new file with mode: 0644]
spec/spec_helper_system.rb [deleted file]
spec/system/basic_spec.rb [deleted file]

diff --git a/.nodeset.yml b/.nodeset.yml
deleted file mode 100644 (file)
index ad056fe..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
----
-default_set: 'ubuntu-server-12042-x64'
-sets:
-  'debian-607-x64':
-    nodes:
-      "main.foo.vm":
-        prefab: 'debian-607-x64'
-  'debian-70rc1-x64':
-    nodes:
-      "main.foo.vm":
-        prefab: 'debian-70rc1-x64'
-  'ubuntu-server-10044-x64':
-    nodes:
-      "main.foo.vm":
-        prefab: 'ubuntu-server-10044-x64'
-  'ubuntu-server-12042-x64':
-    nodes:
-      "main.foo.vm":
-        prefab: 'ubuntu-server-12042-x64'
diff --git a/Gemfile b/Gemfile
index 15bd29daf026e8b89925e26d3e81074f0b8cfb48..b89b579d5d2ad9d5c8828bf608eb0347c0d76bac 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -4,9 +4,9 @@ group :development, :test do
   gem 'rake',                    :require => false
   gem 'rspec-puppet',            :require => false
   gem 'puppetlabs_spec_helper',  :require => false
-  gem 'rspec-system',            :require => false
-  gem 'rspec-system-puppet',     :require => false
-  gem 'rspec-system-serverspec', :require => false
+  gem 'serverspec',              :require => false
+  gem 'beaker',                  :require => false
+  gem 'beaker-rspec',            :require => false
 end
 
 if puppetversion = ENV['PUPPET_GEM_VERSION']
similarity index 86%
rename from spec/system/apt_builddep_spec.rb
rename to spec/acceptance/apt_builddep_spec.rb
index fa16ab42f5ffa912927116eb9b77ee0b0e9e1109..b61fca29550196008fc31073eb55ae1e8ea5effb 100644 (file)
@@ -1,4 +1,4 @@
-require 'spec_helper_system'
+require 'spec_helper_acceptance'
 
 describe 'apt::builddep' do
 
@@ -16,9 +16,7 @@ describe 'apt::builddep' do
       apt::builddep { 'glusterfs-server': }
       EOS
 
-      puppet_apply(pp) do |r|
-        r.exit_code.should_not == 1
-      end
+      apply_manifest(pp, :catch_failures => true)
     end
 
     describe 'should install g++ as a dependency' do
similarity index 74%
rename from spec/system/apt_key_spec.rb
rename to spec/acceptance/apt_key_spec.rb
index 4842cb5972ce5aacb6ccd33c2980f4de76d7cc36..5f69e25e0ba99a8515d45c52decaa047cefac831 100644 (file)
@@ -1,11 +1,11 @@
-require 'spec_helper_system'
+require 'spec_helper_acceptance'
 
 describe 'apt::key' do
 
   context 'reset' do
     it 'clean up keys' do
-      shell('apt-key del 4BD6EC30')
-      shell('apt-key del D50582E6')
+      shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
+      shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
     end
   end
 
@@ -24,20 +24,18 @@ describe 'apt::key' do
       }
       EOS
 
-      puppet_apply(pp) do |r|
-        r.exit_code.should_not == 1
-      end
+      apply_manifest(pp, :catch_failures => true)
     end
 
     describe 'keys should exist' do
       it 'finds puppetlabs key' do
         shell('apt-key list | grep 4BD6EC30') do |r|
-          r.exit_code.should be_zero
+          expect(r.exit_code).to be_zero
         end
       end
       it 'finds jenkins key' do
         shell('apt-key list | grep D50582E6') do |r|
-          r.exit_code.should be_zero
+          expect(r.exit_code).to be_zero
         end
       end
     end
similarity index 57%
rename from spec/system/apt_ppa_spec.rb
rename to spec/acceptance/apt_ppa_spec.rb
index 2e2baf5d2bccc606f5c00d8af7075cfd328490c0..5bee3c69ef6b037267e34200c0c67970428fb31e 100644 (file)
@@ -1,11 +1,11 @@
-require 'spec_helper_system'
+require 'spec_helper_acceptance'
 
 describe 'apt::ppa' do
 
   context 'reset' do
     it 'removes ppa' do
-      shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
-      shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
+      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
 
@@ -13,19 +13,15 @@ describe 'apt::ppa' do
     it 'should work with no errors' do
       pp = <<-EOS
       include '::apt'
-      apt::ppa { 'ppa:drizzle-developers/ppa': }
+      apt::ppa { 'ppa:canonical-kernel-team/ppa': }
       EOS
 
-      puppet_apply(pp) do |r|
-        r.exit_code.should_not == 1
-      end
+      apply_manifest(pp, :catch_failures => true)
     end
 
     describe 'contains the source file' do
-      it 'contains a drizzle ppa source' do
-        shell('ls /etc/apt/sources.list.d/drizzle-developers-ppa-*.list') do |r|
-          r.exit_code.should be_zero
-        end
+      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
@@ -43,15 +39,13 @@ describe 'apt::ppa' do
       apt::ppa { 'ppa:raravena80/collectd5': }
       EOS
 
-      puppet_apply(pp) do |r|
-        r.exit_code.should_not == 1
-      end
+      apply_manifest(pp, :catch_failures => true)
     end
   end
 
   context 'reset' do
     it 'removes added ppas' do
-      shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
+      shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
       shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
     end
   end
similarity index 75%
rename from spec/system/apt_source_spec.rb
rename to spec/acceptance/apt_source_spec.rb
index 6a445e13eff68d7e74b25bcc49de4fb1a271e104..044af57148ef0063246bd4504485961c1ac85624 100644 (file)
@@ -1,11 +1,11 @@
-require 'spec_helper_system'
+require 'spec_helper_acceptance'
 
 describe 'apt::source' do
 
   context 'reset' do
     it 'clean up puppetlabs repo' do
-      shell('apt-key del 4BD6EC30')
-      shell('rm /etc/apt/sources.list.d/puppetlabs.list')
+      shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
+      shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
     end
   end
 
@@ -21,15 +21,13 @@ describe 'apt::source' do
       }
       EOS
 
-      puppet_apply(pp) do |r|
-        r.exit_code.should_not == 1
-      end
+      apply_manifest(pp, :catch_failures => true)
     end
 
     describe 'key should exist' do
       it 'finds puppetlabs key' do
         shell('apt-key list | grep 4BD6EC30') do |r|
-          r.exit_code.should be_zero
+          expect(r.exit_code).to be_zero
         end
       end
     end
similarity index 61%
rename from spec/system/class_spec.rb
rename to spec/acceptance/class_spec.rb
index 7bb6b8d64ef0e80faf7790ee4348adc2f3b32e57..f228e4c4565f7b8d825b52ca83a421d2c007c142 100644 (file)
@@ -1,4 +1,4 @@
-require 'spec_helper_system'
+require 'spec_helper_acceptance'
 
 describe 'apt class' do
 
@@ -10,11 +10,8 @@ describe 'apt class' do
       EOS
 
       # Run it twice and test for idempotency
-      puppet_apply(pp) do |r|
-        r.exit_code.should_not == 1
-        r.refresh
-        r.exit_code.should be_zero
-      end
+      apply_manifest(pp, :catch_failures => true)
+      apply_manifest(pp, :catch_failures => true)
     end
   end
 end
diff --git a/spec/acceptance/nodesets/debian-70rc1-x64.yml b/spec/acceptance/nodesets/debian-70rc1-x64.yml
new file mode 100644 (file)
index 0000000..a1b59c0
--- /dev/null
@@ -0,0 +1,8 @@
+HOSTS:
+  debian-70rc1-x64:
+    roles:
+      - master
+    platform: debian-70rc1-x64
+    box : debian-70rc1-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box
+    hypervisor : vagrant
diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml
new file mode 100644 (file)
index 0000000..2b8fe4a
--- /dev/null
@@ -0,0 +1,8 @@
+HOSTS:
+  ubuntu-server-12042-x64:
+    roles:
+      - master
+    platform: ubuntu-server-12.04-amd64
+    box : ubuntu-server-12042-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
+    hypervisor : vagrant
diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
new file mode 100644 (file)
index 0000000..2b8fe4a
--- /dev/null
@@ -0,0 +1,8 @@
+HOSTS:
+  ubuntu-server-12042-x64:
+    roles:
+      - master
+    platform: ubuntu-server-12.04-amd64
+    box : ubuntu-server-12042-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
+    hypervisor : vagrant
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
new file mode 100644 (file)
index 0000000..0073e4d
--- /dev/null
@@ -0,0 +1,26 @@
+require 'beaker-rspec'
+
+hosts.each do |host|
+  # Install Puppet
+  install_package host, 'rubygems'
+  on host, 'gem install puppet --no-ri --no-rdoc'
+  on host, "mkdir -p #{host['distmoduledir']}"
+end
+
+RSpec.configure do |c|
+  # Project root
+  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+  # Readable test descriptions
+  c.formatter = :documentation
+
+  # Configure all nodes in nodeset
+  c.before :suite do
+    # Install module and dependencies
+    puppet_module_install(:source => proj_root, :module_name => 'apt')
+    hosts.each do |host|
+      shell('/bin/touch /etc/puppet/hiera.yaml')
+      shell('puppet module install puppetlabs-stdlib', { :acceptable_exit_codes => [0,1] })
+    end
+  end
+end
diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb
deleted file mode 100644 (file)
index 490a601..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-require 'rspec-system/spec_helper'
-require 'rspec-system-puppet/helpers'
-require 'rspec-system-serverspec/helpers'
-
-include RSpecSystemPuppet::Helpers
-
-include Serverspec::Helper::RSpecSystem
-include Serverspec::Helper::DetectOS
-
-RSpec.configure do |c|
-  # Project root
-  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
-  # Enable colour
-  c.tty = true
-
-  c.include RSpecSystemPuppet::Helpers
-
-  # This is where we 'setup' the nodes before running our tests
-  c.before :suite do
-    # May as well update here as this can only run on apt-get machines.
-    shell('apt-get update')
-    # Install puppet
-    puppet_install
-
-    # Install modules and dependencies
-    puppet_module_install(:source => proj_root, :module_name => 'apt')
-    shell('puppet module install puppetlabs-stdlib')
-  end
-end
diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb
deleted file mode 100644 (file)
index 3008356..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'spec_helper_system'
-
-describe 'basic tests:' do
-  # Using puppet_apply as a subject
-  context puppet_apply 'notice("foo")' do
-    its(:stdout) { should =~ /foo/ }
-    its(:stderr) { should be_empty }
-    its(:exit_code) { should be_zero }
-  end
-end