beaker 2.39.0 → 2.40.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -133,7 +133,7 @@ module Beaker
133
133
  curl_retries = host['master-start-curl-retries'] || options['master-start-curl-retries']
134
134
  logger.debug "Setting curl retries to #{curl_retries}"
135
135
 
136
- if options[:is_puppetserver]
136
+ if options[:is_puppetserver] || host[:is_puppetserver]
137
137
  confdir = host.puppet('master')['confdir']
138
138
  vardir = host.puppet('master')['vardir']
139
139
 
@@ -266,7 +266,7 @@ module Beaker
266
266
  elsif host['platform'] =~ /fedora-(\d+)/
267
267
  relver = $1
268
268
  install_puppet_from_rpm_on(host, opts.merge(:release => relver, :family => 'fedora'))
269
- elsif host['platform'] =~ /(ubuntu|debian|cumulus)/
269
+ elsif host['platform'] =~ /(ubuntu|debian|cumulus|huaweios)/
270
270
  install_puppet_from_deb_on(host, opts)
271
271
  elsif host['platform'] =~ /windows/
272
272
  relver = opts[:version]
@@ -336,7 +336,7 @@ module Beaker
336
336
  when /el-|fedora|sles|centos|cisco_/
337
337
  package_name = 'puppet-agent'
338
338
  package_name << "-#{opts[:puppet_agent_version]}" if opts[:puppet_agent_version]
339
- when /debian|ubuntu|cumulus/
339
+ when /debian|ubuntu|cumulus|huaweios/
340
340
  package_name = 'puppet-agent'
341
341
  package_name << "=#{opts[:puppet_agent_version]}-1#{host['platform'].codename}" if opts[:puppet_agent_version]
342
342
  when /windows/
@@ -696,22 +696,48 @@ module Beaker
696
696
  add_role(host, 'aio') #we are installing agent, so we want aio role
697
697
 
698
698
  variant, version, arch, codename = host['platform'].to_array
699
- agent_version = opts[:puppet_agent_version] || 'latest'
700
- pkg_name = "puppet-agent-#{agent_version}*"
701
- if agent_version == 'latest'
702
- dmg_name = "puppet-agent-#{agent_version}.dmg"
703
- on host, "curl -O #{opts[:mac_download_url]}/#{dmg_name}"
704
- else
705
- dmg_name = "puppet-agent-#{agent_version}-osx-#{version}-x86_64.dmg"
706
- on host, "curl -O #{opts[:mac_download_url]}/#{opts[:puppet_collection]}/#{dmg_name}"
699
+
700
+ download_url = "#{opts[:mac_download_url]}/#{version}/#{opts[:puppet_collection]}/#{arch}"
701
+
702
+ latest = get_latest_puppet_agent_build_from_url(download_url)
703
+
704
+ agent_version = opts[:puppet_agent_version] || latest
705
+ unless agent_version.length > 0
706
+ raise "no puppet-agent version specified or found on at #{download_url}"
707
707
  end
708
708
 
709
+ pkg_name = "puppet-agent-#{agent_version}*"
710
+ dmg_name = "puppet-agent-#{agent_version}-1.osx#{version}.dmg"
711
+ on host, "curl -O #{download_url}/#{dmg_name}"
712
+
709
713
  host.install_package(pkg_name)
710
714
 
711
715
  configure_type_defaults_on( host )
712
716
  end
713
717
  end
714
718
 
719
+ # Returns the latest puppet-agent version number from a given url.
720
+ #
721
+ # @param [String] url URL containing list of puppet-agent packages.
722
+ # Example: https://downloads.puppetlabs.com/mac/10.11/PC1/x86_64
723
+ #
724
+ # @return [String] version puppet-agent version number (e.g. 1.4.1)
725
+ # Empty string if none found.
726
+ # @api private
727
+ def get_latest_puppet_agent_build_from_url(url)
728
+ require 'nokogiri'
729
+ require 'open-uri'
730
+ page = Nokogiri::HTML(open("#{url}/?C=M;O=A"))
731
+ agents = page.css('a').children.select{ |link| link.to_s.include? 'puppet-agent' }
732
+ re = /puppet-agent-(.*)-1/
733
+ latest_match = agents[-1].to_s.match re
734
+ if latest_match
735
+ latest = latest_match[1]
736
+ else
737
+ latest = ''
738
+ end
739
+ end
740
+
715
741
  # Installs Puppet and dependencies from OpenBSD packages
716
742
  #
717
743
  # @param [Host, Array<Host>, String, Symbol] hosts The host to install packages on
@@ -766,7 +792,7 @@ module Beaker
766
792
  gempkg = case host['platform']
767
793
  when /solaris-11/ then 'ruby-18'
768
794
  when /ubuntu-14/ then 'ruby'
769
- when /solaris-10|ubuntu|debian|el-|cumulus/ then 'rubygems'
795
+ when /solaris-10|ubuntu|debian|el-|cumulus|huaweios/ then 'rubygems'
770
796
  when /openbsd/ then 'ruby'
771
797
  else
772
798
  raise "install_puppet() called with default_action " +
@@ -782,7 +808,7 @@ module Beaker
782
808
  on host, 'ln -s /opt/csw/bin/gem /usr/bin/gem'
783
809
  end
784
810
 
785
- if host['platform'] =~ /debian|ubuntu|solaris|cumulus/
811
+ if host['platform'] =~ /debian|ubuntu|solaris|cumulus|huaweios/
786
812
  gem_env = YAML.load( on( host, 'gem environment' ).stdout )
787
813
  gem_paths_array = gem_env['RubyGems Environment'].find {|h| h['GEM PATHS'] != nil }['GEM PATHS']
788
814
  path_with_gem = 'export PATH=' + gem_paths_array.join(':') + ':${PATH}'
@@ -866,7 +892,7 @@ module Beaker
866
892
  { :package_proxy => opts[:package_proxy] } )
867
893
  end
868
894
 
869
- when /^(debian|ubuntu|cumulus)$/
895
+ when /^(debian|ubuntu|cumulus|huaweios)$/
870
896
  deb = "puppetlabs-release%s-%s.deb" % [repo_name, codename]
871
897
 
872
898
  remote = URI.join( opts[:release_apt_repo_url], deb )
@@ -907,7 +933,7 @@ module Beaker
907
933
  end
908
934
  scp_to( host, repo, to_path )
909
935
 
910
- on( host, 'apt-get update' ) if host['platform'] =~ /ubuntu-|debian-|cumulus-/
936
+ on( host, 'apt-get update' ) if host['platform'] =~ /ubuntu-|debian-|cumulus-|huaweios-/
911
937
  nil
912
938
  end
913
939
 
@@ -942,7 +968,7 @@ module Beaker
942
968
  repo_configs_dir = nil,
943
969
  opts = options )
944
970
  variant, version, arch, codename = host['platform'].to_array
945
- if variant !~ /^(fedora|el|centos|debian|ubuntu|cumulus|cisco_nexus|cisco_ios_xr)$/
971
+ if variant !~ /^(fedora|el|centos|debian|ubuntu|cumulus|huaweios|cisco_nexus|cisco_ios_xr)$/
946
972
  raise "No repository installation step for #{variant} yet..."
947
973
  end
948
974
  repo_configs_dir ||= 'tmp/repo_configs'
@@ -974,7 +1000,7 @@ module Beaker
974
1000
  # @note This method is paired to be run directly after {#install_puppetlabs_dev_repo}
975
1001
  #
976
1002
  def install_packages_from_local_dev_repo( host, package_name )
977
- if host['platform'] =~ /debian|ubuntu|cumulus/
1003
+ if host['platform'] =~ /debian|ubuntu|cumulus|huaweios/
978
1004
  find_filename = '*.deb'
979
1005
  find_command = 'dpkg -i'
980
1006
  elsif host['platform'] =~ /fedora|el|centos/
@@ -1039,7 +1065,7 @@ module Beaker
1039
1065
  onhost_copy_base = opts[:copy_dir_external]
1040
1066
 
1041
1067
  case variant
1042
- when /^(fedora|el|centos|debian|ubuntu|cumulus|cisco_nexus|cisco_ios_xr)$/
1068
+ when /^(fedora|el|centos|debian|ubuntu|cumulus|huaweios|cisco_nexus|cisco_ios_xr)$/
1043
1069
  sha = opts[:puppet_agent_sha] || opts[:puppet_agent_version]
1044
1070
  opts[:dev_builds_repos] ||= [ opts[:puppet_collection] ]
1045
1071
  install_puppetlabs_dev_repo( host, 'puppet-agent', sha, nil, opts )
@@ -1073,8 +1099,8 @@ module Beaker
1073
1099
  when /^windows$/
1074
1100
  result = on host, "echo #{onhost_copied_file}"
1075
1101
  onhost_copied_file = result.raw_output.chomp
1076
- opts = { :debug => host[:pe_debug] || opts[:pe_debug] }
1077
- install_msi_on(host, onhost_copied_file, {}, opts)
1102
+ msi_opts = { :debug => host[:pe_debug] || opts[:pe_debug] }
1103
+ install_msi_on(host, onhost_copied_file, {}, msi_opts)
1078
1104
  when /^osx$/
1079
1105
  host.install_package("puppet-agent-#{opts[:puppet_agent_version]}*")
1080
1106
  when /^solaris$/
@@ -1177,7 +1203,7 @@ module Beaker
1177
1203
  cmdline_args = ''
1178
1204
  # query packages
1179
1205
  case host[:platform]
1180
- when /cumulus/
1206
+ when /cumulus|huaweios/
1181
1207
  pkgs = on(host, "dpkg-query -l | awk '{print $2}' | grep -E '(^pe-|puppet)'", :acceptable_exit_codes => [0,1]).stdout.chomp.split(/\n+/)
1182
1208
  when /aix/
1183
1209
  pkgs = on(host, "rpm -qa | grep -E '(^pe-|puppet)'", :acceptable_exit_codes => [0,1]).stdout.chomp.split(/\n+/)
@@ -140,6 +140,15 @@ exit /B %errorlevel%
140
140
  # if puppet service does not exist, pe-puppet is queried and that exit code is used
141
141
  # therefore, this command will always exit 0 if either service is installed
142
142
  on host, Command.new("sc query puppet || sc query pe-puppet", [], { :cmdexe => true })
143
+
144
+ # emit the misc/versions.txt file which contains component versions for
145
+ # puppet, facter, hiera, pxp-agent, packaging and vendored Ruby
146
+ [
147
+ "\"%ProgramFiles%\\Puppet Labs\\puppet\\misc\\versions.txt\"",
148
+ "\"%ProgramFiles(x86)%\\Puppet Labs\\puppet\\misc\\versions.txt\""
149
+ ].each do |path|
150
+ on host, Command.new("if exist #{path} type #{path}", [], { :cmdexe => true })
151
+ end
143
152
  end
144
153
  end
145
154
 
@@ -324,7 +324,8 @@ module Beaker
324
324
  # exit codes at the host level and then raising...
325
325
  # is it necessary to break execution??
326
326
  if options[:accept_all_exit_codes] && options[:acceptable_exit_codes]
327
- @logger.warn ":accept_all_exit_codes & :acceptable_exit_codes set. :accept_all_exit_codes overrides, but they shouldn't both be set at once"
327
+ @logger.warn ":accept_all_exit_codes & :acceptable_exit_codes set. :acceptable_exit_codes overrides, but they shouldn't both be set at once"
328
+ options[:accept_all_exit_codes] = false
328
329
  end
329
330
  if !options[:accept_all_exit_codes] && !result.exit_code_in?(Array(options[:acceptable_exit_codes] || [0, nil]))
330
331
  raise CommandFailure, "Host '#{self}' exited with #{result.exit_code} running:\n #{cmdline}\nLast #{@options[:trace_limit]} lines of output were:\n#{result.formatted_output(@options[:trace_limit])}"
@@ -164,7 +164,7 @@ module Unix::Exec
164
164
  # @return [Result] result of restarting the SSH service
165
165
  def ssh_service_restart
166
166
  case self['platform']
167
- when /debian|ubuntu|cumulus/
167
+ when /debian|ubuntu|cumulus|huaweios/
168
168
  exec(Beaker::Command.new("service ssh restart"))
169
169
  when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7/
170
170
  exec(Beaker::Command.new("systemctl restart sshd.service"))
@@ -188,7 +188,7 @@ module Unix::Exec
188
188
  # (from {#ssh_service_restart}).
189
189
  def ssh_permit_user_environment
190
190
  case self['platform']
191
- when /debian|ubuntu|cumulus/
191
+ when /debian|ubuntu|cumulus|huaweios/
192
192
  directory = create_tmpdir_on(self)
193
193
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
194
194
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
@@ -41,7 +41,7 @@ module Unix::File
41
41
  case self['platform']
42
42
  when /fedora|el-|centos/
43
43
  '/etc/yum.repos.d/'
44
- when /debian|ubuntu|cumulus/
44
+ when /debian|ubuntu|cumulus|huaweios/
45
45
  '/etc/apt/sources.list.d'
46
46
  else
47
47
  msg = "package config dir unknown for platform '#{self['platform']}'"
@@ -83,8 +83,8 @@ module Unix::File
83
83
  version,
84
84
  arch
85
85
  ]
86
- when /debian|ubuntu|cumulus/
87
- codename = variant if variant == 'cumulus'
86
+ when /debian|ubuntu|cumulus|huaweios/
87
+ codename = variant if variant == 'cumulus' || variant == 'huaweios'
88
88
  repo_filename << "%s.list" % [ codename ]
89
89
  else
90
90
  msg = "#repo_filename: repo filename pattern not known for platform '#{self['platform']}'"
@@ -103,7 +103,7 @@ module Unix::File
103
103
  case self['platform']
104
104
  when /fedora|el-|centos/
105
105
  'rpm'
106
- when /debian|ubuntu|cumulus/
106
+ when /debian|ubuntu|cumulus|huaweios/
107
107
  'deb'
108
108
  else
109
109
  msg = "#repo_type: repo type not known for platform '#{self['platform']}'"
@@ -34,7 +34,7 @@ module Unix::Pkg
34
34
  return false
35
35
  when /cisco|fedora|centos|eos|el-/
36
36
  result = execute("rpm -q #{name}", opts) { |result| result }
37
- when /ubuntu|debian|cumulus/
37
+ when /ubuntu|debian|cumulus|huaweios/
38
38
  result = execute("dpkg -s #{name}", opts) { |result| result }
39
39
  when /solaris-11/
40
40
  result = execute("pkg info #{name}", opts) { |result| result }
@@ -54,7 +54,7 @@ module Unix::Pkg
54
54
  # If apt has not been updated since the last repo deployment it is
55
55
  # updated. Otherwise this is a noop
56
56
  def update_apt_if_needed
57
- if self['platform'] =~ /debian|ubuntu|cumulus/
57
+ if self['platform'] =~ /debian|ubuntu|cumulus|huaweios/
58
58
  if @apt_needs_update
59
59
  execute("apt-get update")
60
60
  @apt_needs_update = false
@@ -78,7 +78,7 @@ module Unix::Pkg
78
78
  name = "#{name}-#{version}"
79
79
  end
80
80
  execute("yum -y #{cmdline_args} install #{name}", opts)
81
- when /ubuntu|debian|cumulus/
81
+ when /ubuntu|debian|cumulus|huaweios/
82
82
  if version
83
83
  name = "#{name}=#{version}"
84
84
  end
@@ -152,7 +152,7 @@ module Unix::Pkg
152
152
  execute("dnf -y #{cmdline_args} remove #{name}", opts)
153
153
  when /cisco|fedora|centos|eos|el-/
154
154
  execute("yum -y #{cmdline_args} remove #{name}", opts)
155
- when /ubuntu|debian|cumulus/
155
+ when /ubuntu|debian|cumulus|huaweios/
156
156
  execute("apt-get purge #{cmdline_args} -y #{name}", opts)
157
157
  when /solaris-11/
158
158
  execute("pkg #{cmdline_args} uninstall #{name}", opts)
@@ -180,7 +180,7 @@ module Unix::Pkg
180
180
  execute("dnf -y #{cmdline_args} update #{name}", opts)
181
181
  when /cisco|fedora|centos|eos|el-/
182
182
  execute("yum -y #{cmdline_args} update #{name}", opts)
183
- when /ubuntu|debian|cumulus/
183
+ when /ubuntu|debian|cumulus|huaweios/
184
184
  update_apt_if_needed
185
185
  execute("apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}", opts)
186
186
  when /solaris-11/
@@ -257,7 +257,7 @@ module Unix::Pkg
257
257
  @logger.debug("Package repo deploy is not supported on rhel4")
258
258
  when /fedora|centos|eos|el-/
259
259
  deploy_yum_repo(path, name, version)
260
- when /ubuntu|debian|cumulus/
260
+ when /ubuntu|debian|cumulus|huaweios/
261
261
  deploy_apt_repo(path, name, version)
262
262
  when /sles/
263
263
  deploy_zyp_repo(path, name, version)
@@ -317,6 +317,9 @@ module Unix::Pkg
317
317
  raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]
318
318
 
319
319
  variant, version, arch, codename = self['platform'].to_array
320
+
321
+ version = version.split('.')[0] # packages are only published for major versions
322
+
320
323
  platform_error = "Incorrect platform '#{variant}' for #solaris_puppet_agent_dev_package_info"
321
324
  raise ArgumentError, platform_error if variant != 'solaris'
322
325
 
@@ -488,6 +491,9 @@ module Unix::Pkg
488
491
  # @return [Beaker::Result] Result of installation command execution
489
492
  def solaris_install_local_package(package_path, noask_directory = nil)
490
493
  variant, version, arch, codename = self['platform'].to_array
494
+
495
+ version = version.split('.')[0] # packages are only published for major versions
496
+
491
497
  error_message = nil
492
498
  unless variant == 'solaris'
493
499
  error_message = "Can not call solaris_install_local_package for the "
@@ -53,6 +53,11 @@ module Beaker
53
53
  @cmd_options[:post_suite] = value
54
54
  end
55
55
 
56
+ opts.on '--pre-cleanup /PRE-CLEANUP/DIR/PATH,/OPTIONAL/ADDITONAL/DIR/PATHS,/PATH/TO/FILE.rb',
57
+ 'Path to project specific steps to be run before cleaning up VMs (will always run)' do |value|
58
+ @cmd_options[:pre_cleanup] = value
59
+ end
60
+
56
61
  opts.on '--[no-]provision',
57
62
  'Do not provision vm images before testing',
58
63
  '(default: true)' do |bool|
@@ -7,9 +7,9 @@ module Beaker
7
7
  GITREPO = 'git://github.com/puppetlabs'
8
8
  #These options can have the form of arg1,arg2 or [arg] or just arg,
9
9
  #should default to []
10
- LONG_OPTS = [:helper, :load_path, :tests, :pre_suite, :post_suite, :install, :modules]
10
+ LONG_OPTS = [:helper, :load_path, :tests, :pre_suite, :post_suite, :install, :pre_cleanup, :modules]
11
11
  #These options expand out into an array of .rb files
12
- RB_FILE_OPTS = [:tests, :pre_suite, :post_suite]
12
+ RB_FILE_OPTS = [:tests, :pre_suite, :post_suite, :pre_cleanup]
13
13
 
14
14
  PARSE_ERROR = Psych::SyntaxError
15
15
 
@@ -167,7 +167,7 @@ module Beaker
167
167
  :add_el_extras => false,
168
168
  :epel_url => "http://mirrors.kernel.org/fedora-epel",
169
169
  :epel_arch => "i386",
170
- :epel_7_pkg => "epel-release-7-5.noarch.rpm",
170
+ :epel_7_pkg => "epel-release-7-6.noarch.rpm",
171
171
  :epel_6_pkg => "epel-release-6-8.noarch.rpm",
172
172
  :epel_5_pkg => "epel-release-5-4.noarch.rpm",
173
173
  :consoleport => 443,
@@ -3,7 +3,7 @@ module Beaker
3
3
  # all String methods while adding several platform-specific use cases.
4
4
  class Platform < String
5
5
  # Supported platforms
6
- PLATFORMS = /^(cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|scientific|sles|ubuntu|windows|solaris|aix|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
6
+ PLATFORMS = /^(huaweios|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|scientific|sles|ubuntu|windows|solaris|aix|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
7
7
  # Platform version numbers vs. codenames conversion hash
8
8
  PLATFORM_VERSION_CODES =
9
9
  { :debian => { "jessie" => "8",
@@ -43,6 +43,7 @@ module Beaker
43
43
  # Creates the Platform object. Checks to ensure that the platform String
44
44
  # provided meets the platform formatting rules. Platforms name must be of
45
45
  # the format /^OSFAMILY-VERSION-ARCH.*$/ where OSFAMILY is one of:
46
+ # * huaweios
46
47
  # * cisco_nexus
47
48
  # * cisco_ios_xr
48
49
  # * freebsd
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '2.39.0'
3
+ STRING = '2.40.0'
4
4
  end
5
5
  end
@@ -21,6 +21,20 @@ module Beaker
21
21
  end
22
22
 
23
23
  describe "test fail mode" do
24
+ it 'runs pre_cleanup after a failed pre_suite if using slow fail_mode' do
25
+ options = cli.instance_variable_get(:@options)
26
+ options[:fail_mode] = 'slow'
27
+ cli.instance_variable_set(:@options, options)
28
+ allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_throw("bad test")
29
+ allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode])
30
+ allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
31
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
32
+
33
+ expect( cli ).to receive(:run_suite).exactly( 2 ).times
34
+ expect{ cli.execute! }.to raise_error
35
+
36
+ end
37
+
24
38
  it 'continues testing after failed test if using slow fail_mode' do
25
39
  options = cli.instance_variable_get(:@options)
26
40
  options[:fail_mode] = 'slow'
@@ -28,8 +42,9 @@ module Beaker
28
42
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
29
43
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
30
44
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
45
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
31
46
 
32
- expect( cli ).to receive(:run_suite).exactly( 3 ).times
47
+ expect( cli ).to receive(:run_suite).exactly( 4 ).times
33
48
  expect{ cli.execute! }.to raise_error
34
49
 
35
50
  end
@@ -40,9 +55,9 @@ module Beaker
40
55
  cli.instance_variable_set(:@options, options)
41
56
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
42
57
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
43
- allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
58
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
44
59
 
45
- expect( cli ).to receive(:run_suite).exactly( 2 ).times
60
+ expect( cli ).to receive(:run_suite).exactly( 3 ).times
46
61
  expect{ cli.execute! }.to raise_error
47
62
 
48
63
  end
@@ -56,7 +71,7 @@ module Beaker
56
71
  cli.instance_variable_set(:@options, options)
57
72
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
58
73
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
59
- allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
74
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
60
75
 
61
76
  netmanager = double(:netmanager)
62
77
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -74,6 +89,7 @@ module Beaker
74
89
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
75
90
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
76
91
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
92
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
77
93
 
78
94
  netmanager = double(:netmanager)
79
95
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -94,6 +110,7 @@ module Beaker
94
110
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
95
111
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
96
112
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
113
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
97
114
  cli.instance_variable_set(:@hosts, {})
98
115
 
99
116
  netmanager = double(:netmanager)
@@ -112,6 +129,7 @@ module Beaker
112
129
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
113
130
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
114
131
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
132
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
115
133
 
116
134
  netmanager = double(:netmanager)
117
135
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -128,6 +146,7 @@ module Beaker
128
146
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
129
147
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
130
148
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
149
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
131
150
 
132
151
  netmanager = double(:netmanager)
133
152
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -145,6 +164,7 @@ module Beaker
145
164
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
146
165
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
147
166
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
167
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
148
168
 
149
169
  netmanager = double(:netmanager)
150
170
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -162,6 +182,7 @@ module Beaker
162
182
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
163
183
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_throw("bad test")
164
184
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
185
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
165
186
 
166
187
  netmanager = double(:netmanager)
167
188
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -182,6 +203,7 @@ module Beaker
182
203
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
183
204
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
184
205
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
206
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
185
207
 
186
208
  netmanager = double(:netmanager)
187
209
  cli.instance_variable_set(:@network_manager, netmanager)
@@ -211,6 +233,7 @@ module Beaker
211
233
  options[:hosts_file] = 'sample.cfg'
212
234
  options[:pre_suite] = ['pre1', 'pre2', 'pre3']
213
235
  options[:post_suite] = ['post1']
236
+ options[:pre_cleanup] = ['preclean1']
214
237
  options[:tests] = ['test1', 'test2']
215
238
 
216
239
  cli.instance_variable_set(:@options, options)
@@ -221,6 +244,7 @@ module Beaker
221
244
  expect(hosts_yaml['CONFIG'][:tests]).to be == []
222
245
  expect(hosts_yaml['CONFIG'][:pre_suite]).to be == []
223
246
  expect(hosts_yaml['CONFIG'][:post_suite]).to be == []
247
+ expect(hosts_yaml['CONFIG'][:pre_cleanup]).to be == []
224
248
  end
225
249
  end
226
250
 
@@ -235,6 +259,7 @@ module Beaker
235
259
  allow( cli ).to receive(:run_suite).with(:pre_suite, :fast).and_return(true)
236
260
  allow( cli ).to receive(:run_suite).with(:tests, options[:fail_mode]).and_return(true)
237
261
  allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
262
+ allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
238
263
 
239
264
  hosts = [
240
265
  make_host('petey', { :hypervisor => 'peterPan' }),