]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
(MAINT) Adds an acceptance test for RHEL 7
authorPeter Souter <peter.souter@puppetlabs.com>
Wed, 11 Mar 2015 18:06:43 +0000 (18:06 +0000)
committerPeter Souter <peter.souter@puppetlabs.com>
Thu, 12 Mar 2015 08:57:44 +0000 (08:57 +0000)
Lets us check the logic around making sure RHEL 7 changing service is working

spec/acceptance/nodesets/centos-7-x64.yml [new file with mode: 0644]
spec/acceptance/rhel7_spec.rb [new file with mode: 0644]
spec/spec_helper_acceptance.rb

diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml
new file mode 100644 (file)
index 0000000..f20fe44
--- /dev/null
@@ -0,0 +1,11 @@
+HOSTS:
+  centos-7-x64:
+    roles:
+      - master
+    platform: el-7-x86_64
+    box : puppetlabs/centos-7.0-64-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-7.0-64-virtualbox-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
+  log_level: verbose
\ No newline at end of file
diff --git a/spec/acceptance/rhel7_spec.rb b/spec/acceptance/rhel7_spec.rb
new file mode 100644 (file)
index 0000000..5754ada
--- /dev/null
@@ -0,0 +1,30 @@
+require 'spec_helper_acceptance'
+
+describe 'firewall on RHEL7', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) || !is_rhel7( !is_rhel7( fact('osfamily'), fact('operatingsystem'), fact('operatingsystemrelease') ) ) do
+  before :all do
+    iptables_flush_all_tables
+  end
+
+  it 'should run successfully' do
+    pp = "
+    class { 'firewall': 
+      remove_firewalld => true,
+    }
+    ->
+    resources { 'firewall':
+      purge   => true,
+    }
+    ->
+    firewall { '555 - test':
+      proto  => tcp,
+      port   => '555',
+      action => accept,
+    }
+    "
+
+    # Run it twice and test for idempotency
+    apply_manifest(pp, :catch_failures => true, :debug => true)
+    expect(apply_manifest(pp, :catch_failures => true, :debug => true).exit_code).to be_zero
+  end
+
+end
index b9af876416c223ddfd088d5a738656b0790e507a..28910a286503d0c87fbd4bc0b7c765a669e2ebe5 100644 (file)
@@ -12,6 +12,21 @@ def ip6tables_flush_all_tables
   end
 end
 
+def is_rhel7(osfamily, operatingsystem, operatingsystemrelease)
+  if osfamily == 'RedHat'
+    case operatingsystem
+    when 'Amazon'
+      false
+    when 'Fedora'
+      operatingsystemrelease >= '7.0'
+    else
+      operatingsystemrelease >= '15'
+    end
+  else
+    false
+  end
+end
+
 unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
   # This will install the latest available package on el and deb based
   # systems fail on windows and osx, and install via gem on other *nixes