1 require 'beaker-rspec/spec_helper'
2 require 'beaker-rspec/helpers/serverspec'
3 require 'beaker/puppet_install_helper'
4 require 'beaker/module_install_helper'
6 run_puppet_install_helper
7 install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i
8 install_module_on(hosts)
9 install_module_dependencies_on(hosts)
11 UNSUPPORTED_PLATFORMS = ['AIX','windows','Solaris','Suse']
14 # Provide ability to remove indentation from strings, for the purpose of
15 # left justifying heredoc blocks.
17 gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "")
24 # An empty argument will be skipped, so return empty quotes.
25 return "''" if str.empty?
29 # Treat multibyte characters as is. It is caller's responsibility
30 # to encode the string in the right encoding for the shell
32 str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1")
34 # A LF cannot be escaped with a backslash because a backslash + LF
35 # combo is regarded as line continuation and simply ignored.
36 str.gsub!(/\n/, "'\n'")
41 def psql(psql_cmd, user = 'postgres', exit_codes = [0,1], &block)
42 psql = "psql #{psql_cmd}"
43 shell("su #{shellescape(user)} -c #{shellescape(psql)}", :acceptable_exit_codes => exit_codes, &block)
46 RSpec.configure do |c|
47 # Readable test descriptions
48 c.formatter = :documentation
50 # Configure all nodes in nodeset
52 # Set up selinux if appropriate.
53 if fact('osfamily') == 'RedHat' && fact('selinux') == 'true'
55 if $::osfamily == 'RedHat' and $::selinux == 'true' {
56 $semanage_package = $::operatingsystemmajrelease ? {
57 '5' => 'policycoreutils',
58 default => 'policycoreutils-python',
61 package { $semanage_package: ensure => installed }
62 exec { 'set_postgres':
63 command => 'semanage port -a -t postgresql_port_t -p tcp 5433',
64 path => '/bin:/usr/bin/:/sbin:/usr/sbin',
65 subscribe => Package[$semanage_package],
70 apply_manifest_on(agents, pp, :catch_failures => false)
73 # net-tools required for netstat utility being used by be_listening
74 if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7'
76 package { 'net-tools': ensure => installed }
79 apply_manifest_on(agents, pp, :catch_failures => false)
83 on host, "/bin/touch #{host['puppetpath']}/hiera.yaml"
84 on host, 'chmod 755 /root'
85 if fact_on(host, 'osfamily') == 'Debian'
86 on host, "echo \"en_US ISO-8859-1\nen_NG.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\n\" > /etc/locale.gen"
87 on host, '/usr/sbin/locale-gen'
88 on host, '/usr/sbin/update-locale'