forked from puppetlabs/puppetlabs-haproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec_helper_acceptance.rb
67 lines (61 loc) · 2.39 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
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
run_puppet_install_helper
UNSUPPORTED_PLATFORMS = ['Darwin', 'Suse','windows','AIX','Solaris']
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 => 'haproxy')
hosts.each do |host|
on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module','install','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] }
if fact('osfamily') == 'RedHat'
on host, puppet('module','install','stahnma/epel'), { :acceptable_exit_codes => [0,1] }
end
if fact('operatingsystem') == 'Debian'
on host, puppet('module','install','puppetlabs-apt'), { :acceptable_exit_codes => [0,1] }
apply_manifest(%{
include apt
include apt::backports
})
end
if ! UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))
pp = <<-EOS
$netcat = $::osfamily ? {
'RedHat' => $::operatingsystemmajrelease ? {
'7' => 'nmap-ncat',
default => 'nc',
},
'Debian' => 'netcat-openbsd',
}
package { $netcat: ensure => present, }
package { 'screen': ensure => present, }
if $::osfamily == 'RedHat' {
class { 'epel': }
service { 'iptables': ensure => stopped, }
exec { 'setenforce Permissive':
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
onlyif => 'getenforce | grep Enforcing',
}
if $::operatingsystemmajrelease == '7' {
# For `netstat` for serverspec
package { 'net-tools': ensure => present, }
}
}
EOS
apply_manifest(pp, :catch_failures => true)
['5556','5557'].each do |port|
shell(%{echo 'while :; do echo "HTTP/1.1 200 OK\r\n\r\nResponse on #{port}" | nc -l #{port} ; done' > /root/script-#{port}.sh})
shell(%{/usr/bin/screen -dmS script-#{port} sh /root/script-#{port}.sh})
sleep 1
shell(%{netstat -tnl|grep ':#{port}'})
end
end
end
end
end