forked from puppetlabs/puppetlabs-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec_helper_acceptance.rb
80 lines (67 loc) · 2.83 KB
/
spec_helper_acceptance.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'
require 'beaker/task_helper'
run_puppet_install_helper
install_bolt_on(hosts) unless pe_install?
install_module_on(hosts)
install_module_dependencies_on(hosts)
RSpec.configure do |c|
c.filter_run :focus => true
c.run_all_when_everything_filtered = true
# apache on Ubuntu 10.04 and 12.04 doesn't like IPv6 VirtualHosts, so we skip ipv6 tests on those systems
if fact('operatingsystem') == 'Ubuntu' and (fact('operatingsystemrelease') == '10.04' or fact('operatingsystemrelease') == '12.04')
c.filter_run_excluding :ipv6 => true
end
# Readable test descriptions
c.formatter = :documentation
# detect the situation where PUP-5016 is triggered and skip the idempotency tests in that case
# also note how fact('puppetversion') is not available because of PUP-4359
if fact('osfamily') == 'Debian' && fact('operatingsystemmajrelease') == '8' && shell('puppet --version').stdout =~ /^4\.2/
c.filter_run_excluding :skip_pup_5016 => true
end
# Configure all nodes in nodeset
c.before :suite do
run_puppet_access_login(user: 'admin') if pe_install? && puppet_version =~ %r{(5\.\d\.\d)}
# net-tools required for netstat utility being used by be_listening
if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7'
pp = <<-EOS
package { 'net-tools': ensure => installed }
EOS
apply_manifest_on(agents, pp, :catch_failures => false)
end
if fact('osfamily') == 'Debian'
# Make sure snake-oil certs are installed.
shell 'apt-get install -y ssl-cert'
end
# Install module and dependencies
hosts.each do |host|
# Required for mod_passenger tests.
if fact('osfamily') == 'RedHat'
on host, puppet('module','install','stahnma/epel')
on host, puppet('module','install','puppetlabs/inifile')
#we need epel installed, so we can get plugins, wsgi, mime ...
pp = <<-EOS
class { 'epel': }
EOS
apply_manifest_on(host, pp, :catch_failures => true)
end
# Required for manifest to make mod_pagespeed repository available
if fact('osfamily') == 'Debian'
on host, puppet('module','install','puppetlabs-apt')
end
# Make sure selinux is disabled so the tests work.
on host, puppet('apply', '-e',
%{"exec { 'setenforce 0': path => '/bin:/sbin:/usr/bin:/usr/sbin', onlyif => 'which setenforce && getenforce | grep Enforcing', }"})
end
end
end
shared_examples "a idempotent resource" do
it 'should apply with no errors' do
apply_manifest(pp, :catch_failures => true)
end
it 'should apply a second time without changes', :skip_pup_5016 do
apply_manifest(pp, :catch_changes => true)
end
end