PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/puppet/modules/apache/spec/spec_helper_acceptance.rb

https://gitlab.com/tmountjr/vagrant-lamp
Ruby | 82 lines | 53 code | 16 blank | 13 comment | 19 complexity | bd3dc8d42f3774c2c5cea26df7488b07 MD5 | raw file
  1. require 'beaker-rspec/spec_helper'
  2. require 'beaker-rspec/helpers/serverspec'
  3. require 'beaker/puppet_install_helper'
  4. run_puppet_install_helper
  5. RSpec.configure do |c|
  6. c.filter_run :focus => true
  7. c.run_all_when_everything_filtered = true
  8. # apache on Ubuntu 10.04 and 12.04 doesn't like IPv6 VirtualHosts, so we skip ipv6 tests on those systems
  9. if fact('operatingsystem') == 'Ubuntu' and (fact('operatingsystemrelease') == '10.04' or fact('operatingsystemrelease') == '12.04')
  10. c.filter_run_excluding :ipv6 => true
  11. end
  12. # Project root
  13. proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
  14. # Readable test descriptions
  15. c.formatter = :documentation
  16. # detect the situation where PUP-5016 is triggered and skip the idempotency tests in that case
  17. # also note how fact('puppetversion') is not available because of PUP-4359
  18. if fact('osfamily') == 'Debian' && fact('operatingsystemmajrelease') == '8' && shell('puppet --version').stdout =~ /^4\.2/
  19. c.filter_run_excluding :skip_pup_5016 => true
  20. end
  21. # Configure all nodes in nodeset
  22. c.before :suite do
  23. # net-tools required for netstat utility being used by be_listening
  24. if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7'
  25. pp = <<-EOS
  26. package { 'net-tools': ensure => installed }
  27. EOS
  28. apply_manifest_on(agents, pp, :catch_failures => false)
  29. end
  30. if fact('osfamily') == 'Debian'
  31. # Make sure snake-oil certs are installed.
  32. shell 'apt-get install -y ssl-cert'
  33. end
  34. # Install module and dependencies
  35. hosts.each do |host|
  36. copy_module_to(host, :source => proj_root, :module_name => 'apache')
  37. on host, puppet('module','install','puppetlabs-stdlib')
  38. on host, puppet('module','install','puppetlabs-concat')
  39. # Required for mod_passenger tests.
  40. if fact('osfamily') == 'RedHat'
  41. on host, puppet('module','install','stahnma/epel')
  42. on host, puppet('module','install','puppetlabs/inifile')
  43. #we need epel installed, so we can get plugins, wsgi, mime ...
  44. pp = <<-EOS
  45. class { 'epel': }
  46. EOS
  47. apply_manifest_on(host, pp, :catch_failures => true)
  48. end
  49. # Required for manifest to make mod_pagespeed repository available
  50. if fact('osfamily') == 'Debian'
  51. on host, puppet('module','install','puppetlabs-apt')
  52. end
  53. # Make sure selinux is disabled so the tests work.
  54. on host, puppet('apply', '-e',
  55. %{"exec { 'setenforce 0': path => '/bin:/sbin:/usr/bin:/usr/sbin', onlyif => 'which setenforce && getenforce | grep Enforcing', }"})
  56. end
  57. end
  58. end
  59. shared_examples "a idempotent resource" do
  60. it 'should apply with no errors' do
  61. apply_manifest(pp, :catch_failures => true)
  62. end
  63. it 'should apply a second time without changes', :skip_pup_5016 do
  64. apply_manifest(pp, :catch_changes => true)
  65. end
  66. end