2 require 'beaker-puppet'
4 require 'beaker/puppet_install_helper'
5 require 'beaker/module_install_helper'
6 require 'beaker-task_helper'
7 require 'beaker/i18n_helper'
8 require 'beaker-task_helper'
10 run_puppet_install_helper
11 configure_type_defaults_on(hosts)
12 install_bolt_on(hosts) unless pe_install?
13 install_module_on(hosts)
14 install_module_dependencies_on(hosts)
16 UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze
19 ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)}
21 # This method allows a block to be passed in and if an exception is raised
22 # that matches the 'error_matcher' matcher, the block will wait a set number
23 # of seconds before retrying.
25 # - max_retry_count - Max number of retries
26 # - retry_wait_interval_secs - Number of seconds to wait before retry
27 # - error_matcher - Matcher which the exception raised must match to allow retry
29 # retry_on_error_matching(3, 5, /OpenGPG Error/) do
30 # apply_manifest(pp, :catch_failures => true)
32 def retry_on_error_matching(max_retry_count = MAX_RETRY_COUNT, retry_wait_interval_secs = RETRY_WAIT, error_matcher = ERROR_MATCHER)
35 puts "retry_on_error_matching: try #{try}" unless try.zero?
38 rescue StandardError => e
39 raise unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher)
40 sleep retry_wait_interval_secs
45 RSpec.configure do |c|
46 File.expand_path(File.join(File.dirname(__FILE__), '..'))
48 # Readable test descriptions
49 c.formatter = :documentation
51 # Configure all nodes in nodeset
53 run_puppet_access_login(user: 'admin') if pe_install? && (Gem::Version.new(puppet_version) >= Gem::Version.new('5.0.0'))
56 # This will be removed, this is temporary to test localisation.
57 if (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') &&
58 (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5') &&
59 Gem::Version.new(puppet_version) < Gem::Version.new('5.2.0'))
60 on(host, 'mkdir /opt/puppetlabs/puppet/share/locale/ja')
61 on(host, 'touch /opt/puppetlabs/puppet/share/locale/ja/puppet.po')
63 if fact('osfamily') == 'Debian'
64 # install language on debian systems
65 install_language_on(host, 'ja_JP.utf-8') if not_controller(host)
66 # This will be removed, this is temporary to test localisation.
68 # Required for binding tests.
69 if fact('osfamily') == 'RedHat'
70 if fact('operatingsystemmajrelease') =~ %r{7} || fact('operatingsystem') =~ %r{Fedora}
71 shell('yum install -y bzip2')
74 on host, puppet('module', 'install', 'stahnma/epel')