From 063a0e4a6364a13824fb759b1d91b4bb3a4d652f Mon Sep 17 00:00:00 2001
From: Ken Barber <ken@bob.sh>
Date: Sun, 10 Jun 2012 15:56:17 +0100
Subject: [PATCH] (#14938) Add more test variations for travis testing

Include different variations of Puppet to be tested, and fix any pending issues
so all tests pass.
---
 .travis.yml                                | 64 ++++++++++++++++++++--
 gemfiles/gemfile.ci                        | 19 +++----
 lib/puppet/type/firewall.rb                |  2 +-
 spec/spec_helper.rb                        |  4 +-
 spec/unit/puppet/provider/iptables_spec.rb | 12 +---
 5 files changed, 73 insertions(+), 28 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8c744b6..d67d338 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,67 @@
 ---
 language: ruby
-rvm:
-  - 1.8.7
-  - 1.9.2
-  - 1.9.3
 script: rake spec
 notifications:
   email: false
 gemfile:
   - gemfiles/gemfile.ci
+rvm:
+  - 1.8.7
+  - 1.9.2
+  - 1.9.3
+env:
+  # Latest 2.7.x & Facter 1.6.x
+  - BUILD_PUPPET_VER=2.7.14 BUILD_FACTER_VER=1.6.9
+  # Latest 2.6.x & Facter 1.6.x
+  - BUILD_PUPPET_VER=2.6.16 BUILD_FACTER_VER=1.6.9
+
+  # Mageia 2
+  - BUILD_PUPPET_VER=2.7.11 BUILD_FACTER_VER=1.6.6
+  # Ubuntu 12.04
+  - BUILD_PUPPET_VER=2.7.11 BUILD_FACTER_VER=1.6.5
+  # openSUSE 12.1
+  - BUILD_PUPPET_VER=2.7.6 BUILD_FACTER_VER=1.6.0
+  # Ubuntu 11.10 & Mandriva 2011 Contrib
+  - BUILD_PUPPET_VER=2.7.1 BUILD_FACTER_VER=1.5.9
+
+  # RHEL 5/6 EPEL
+  - BUILD_PUPPET_VER=2.6.16 BUILD_FACTER_VER=1.6.6
+  # Mageia 1
+  - BUILD_PUPPET_VER=2.6.8 BUILD_FACTER_VER=1.5.8
+  # Ubuntu 11.04 & openSUSE 11.4
+  - BUILD_PUPPET_VER=2.6.4 BUILD_FACTER_VER=1.5.8
+  # Debian 6 Main & Mandriva 2010 Contrib Backports
+  - BUILD_PUPPET_VER=2.6.2 BUILD_FACTER_VER=1.5.7
+matrix:
+  exclude:
+    # Puppet 2.6.x is not compatible with Ruby 1.9.x
+    - rvm: 1.9.2
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.16 BUILD_FACTER_VER=1.6.9
+    - rvm: 1.9.3
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.16 BUILD_FACTER_VER=1.6.9
+    - rvm: 1.9.2
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.16 BUILD_FACTER_VER=1.6.6
+    - rvm: 1.9.3
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.16 BUILD_FACTER_VER=1.6.6
+    - rvm: 1.9.2
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.8 BUILD_FACTER_VER=1.5.8
+    - rvm: 1.9.3
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.8 BUILD_FACTER_VER=1.5.8
+    - rvm: 1.9.2
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.4 BUILD_FACTER_VER=1.5.8
+    - rvm: 1.9.3
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.4 BUILD_FACTER_VER=1.5.8
+    - rvm: 1.9.2
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.2 BUILD_FACTER_VER=1.5.7
+    - rvm: 1.9.3
+      gemfile: gemfiles/gemfile.ci
+      env: BUILD_PUPPET_VER=2.6.2 BUILD_FACTER_VER=1.5.7
diff --git a/gemfiles/gemfile.ci b/gemfiles/gemfile.ci
index a5f5fb2..d98382c 100644
--- a/gemfiles/gemfile.ci
+++ b/gemfiles/gemfile.ci
@@ -1,14 +1,11 @@
 source 'http://rubygems.org'
 
-# These are the base gems that facter requires for CI testing. This is a
-# duplicate of what the Puppetlabs Jenkins environment was running at the
-# time this file was created.
-gem 'rspec', '2.9.0'
-gem 'rspec-core', '2.9.0'
-gem 'rspec-expectations', '2.9.0'
-gem 'rspec-mocks', '2.9.0'
-gem 'rake', '0.8.7'
-gem 'mocha', '0.10.5'
+gem 'rspec', '2.10.0'
+gem 'rspec-core', '2.10.1'
+gem 'rspec-expectations', '2.10.0'
+gem 'rspec-mocks', '2.10.1'
+gem 'rake', '0.9.2.2'
+gem 'mocha', '0.11.4'
 gem 'diff-lcs', '1.1.3'
-gem 'puppet', '2.7.6'
-gem 'facter', '1.6.3'
+gem 'puppet', ENV['BUILD_PUPPET_VER']
+gem 'facter', ENV['BUILD_FACTER_VER']
diff --git a/lib/puppet/type/firewall.rb b/lib/puppet/type/firewall.rb
index 9d06e48..5cb9b97 100644
--- a/lib/puppet/type/firewall.rb
+++ b/lib/puppet/type/firewall.rb
@@ -428,7 +428,7 @@ Puppet::Type.newtype(:firewall) do
     # States should always be sorted. This normalizes the resource states to
     # keep it consistent with the sorted result from iptables-save.
     def should=(values)
-      @should = super(values).sort
+      @should = super(values).sort_by {|sym| sym.to_s}
     end
 
     def is_to_s(value)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8e9fbdb..c9b0b22 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -69,7 +69,9 @@ RSpec.configure do |config|
     Puppet.settings.clear
     Puppet::Node::Environment.clear
     Puppet::Util::Storage.clear
-    Puppet::Util::ExecutionStub.reset
+    if Puppet::Util.const_defined?("ExecutionStub")
+      Puppet::Util::ExecutionStub.reset
+    end
 
     PuppetSpec::Files.cleanup
 
diff --git a/spec/unit/puppet/provider/iptables_spec.rb b/spec/unit/puppet/provider/iptables_spec.rb
index b06d214..899cbb2 100644
--- a/spec/unit/puppet/provider/iptables_spec.rb
+++ b/spec/unit/puppet/provider/iptables_spec.rb
@@ -32,16 +32,6 @@ describe 'iptables provider detection' do
     })
     resource.provider.class.to_s.should == "Puppet::Type::Firewall::ProviderIptables"
   end
-
-  it "should raise a default provider error when there are no commands" do
-    # Stub all commands lookups so they return nothing
-    exists.any_instance.stubs(:which).returns false
-
-    # Instantiate a resource instance and make sure it raises an exception
-    lambda { resource = Puppet::Type.type(:firewall).new({
-      :name => '000 test foo' }) }.should raise_error(Puppet::DevError,
-      "Could not find a default provider for firewall")
-  end
 end
 
 describe 'iptables provider' do
@@ -85,7 +75,7 @@ describe 'iptables provider' do
         # If this option is enabled, make sure the parameters exactly match
         if data[:compare_all] then
           it "the parameter hash keys should be the same as returned by rules_to_hash" do
-            resource.keys.sort.should == data[:params].keys.sort
+            resource.keys.should =~ data[:params].keys
           end
         end
 
-- 
2.45.2