beaker 3.29.0 → 3.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWE2MmM4ZWMwNjg0M2ViZjUwNmJmMjFjOWIyNTdkN2M1MjNkMjEzNg==
4
+ ZjllZDM3MjczNGU1ODhiOGM2M2ZhZTIwMTVjNjQ1MzYzNWRlMTQ2YQ==
5
5
  data.tar.gz: !binary |-
6
- ZThlOTg3YTg5ZWRhMjIwZWFiYzA0MmE3ZWZmMzc4OTBiYTJjYTYwZA==
6
+ ZmE2ZDVjMDYxNjBhYzYzMTE1OWNjNDJkMTM1ZGU2YjBhNzNkZDA4MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzQ1NmYyMmM3MzhmMTJlOTZiOWJkOGE2MzlhMzkxMzE5NzI2NzJhODY1Y2Q1
10
- NDkxOTNmNDIwYzhlZjg1ZGRhNjg3MjEyODI4OGM0MjcyMjc3Mzc1Yzg4ZDEw
11
- Njc1ZTBkNjg2ODA3ZDU1MDM1ODQ5NDVkNzQxZWY0ZjI5YjNjZTQ=
9
+ MTNiY2RiNDA4ZGJmMmExOGNlNzIyZGYzMDUzMTk3Yjc5NmFhZTM2NjNhZWRi
10
+ MDE3MWYxZDgxODlkN2VkOGIxNDA0N2Q0ZmY1MGNhNjdiZTRiZTQxYzIzYjNj
11
+ ODNhYjcyZmE0M2ZhMjNjZDZjODU1OWM3YjRiNzY5NWU4NDYzYWQ=
12
12
  data.tar.gz: !binary |-
13
- ZTczYjM4ZmIyMWFiMGU2NmJiZjdjMzQ5NzI2NzZlZTY1YTU1MzA4ZjE5OGYw
14
- NzIwMzJmMWRjNGU2MTljNzIxNzlhZTEzYzVmZjYwNDlmY2NlMDYwNTE0NWMw
15
- MTJhZjU3OWVkNTMyZjcwODc1NjRkMzhlMTA0NTg2Zjc4MTYxNGQ=
13
+ YTQxOGZmNWNjOTJhOWY2ODQ4ZWNiMWRmMzg2MGE3ODI2M2U1M2JjNjU3MDBj
14
+ MmY3NTRkZjE1MWYzODIyOTc5OGNmMzNlZjVjYjQ5ZmNmZDdjZGM1NDM4Nzg0
15
+ MzllZDNjMzZmYmZkZWVkOGI3ODRjYWQzY2ExMjA0OTNlNjY1ZGY=
@@ -11,7 +11,21 @@ Tracking in this Changelog began for this project in version 3.25.0.
11
11
  If you're looking for changes from before this, refer to the project's
12
12
  git logs & PR history.
13
13
 
14
- # [Unreleased](https://github.com/puppetlabs/beaker/compare/3.29.0...master)
14
+ # [Unreleased](https://github.com/puppetlabs/beaker/compare/3.30.0...master)
15
+
16
+ # [3.30.0](https://github.com/puppetlabs/beaker/compare/3.29.0...3.30.0) - 2018-01-10
17
+
18
+ ### Changed
19
+
20
+ - Use `host.hostname` when combining options host_hash with host instance options
21
+
22
+ ### Removed
23
+
24
+ - `amazon` as a platform value
25
+
26
+ ### Added
27
+
28
+ - Load project options from .beaker.yml
15
29
 
16
30
  # [3.29.0](https://github.com/puppetlabs/beaker/compare/3.28.0...3.29.0) - 2017-11-16
17
31
 
@@ -3,7 +3,7 @@ module Beaker
3
3
  module InstallUtils
4
4
 
5
5
  PLATFORM_PATTERNS = {
6
- :redhat => /fedora|el|centos|amazon/,
6
+ :redhat => /fedora|el|centos/,
7
7
  :debian => /debian|ubuntu/,
8
8
  :debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/,
9
9
  :solaris_10 => /solaris-10/,
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
55
55
  # Optional provisioner specific support
56
56
  s.add_runtime_dependency 'beaker-docker', '~> 0.1'
57
57
  s.add_runtime_dependency 'beaker-aws', '~> 0.1'
58
+ s.add_runtime_dependency 'beaker-abs', '~> 0.4'
58
59
  s.add_runtime_dependency 'beaker-vmpooler', '~> 1.0'
59
60
  s.add_runtime_dependency 'beaker-google', '~> 0.1'
60
61
  s.add_runtime_dependency 'beaker-vagrant', '~> 0.1'
@@ -41,7 +41,6 @@ module Beaker
41
41
  return self
42
42
  end
43
43
 
44
-
45
44
  #add additional paths to the LOAD_PATH
46
45
  if not @options[:load_path].empty?
47
46
  @options[:load_path].each do |path|
@@ -257,7 +256,7 @@ module Beaker
257
256
  file_host_hash = h.merge(file_host_hash)
258
257
  @hosts.each do |host|
259
258
  if host_name.to_s == host.name.to_s
260
- newly_keyed_hosts_entries[host.reachable_name] = file_host_hash.merge(host.host_hash)
259
+ newly_keyed_hosts_entries[host.hostname] = file_host_hash.merge(host.host_hash)
261
260
  break
262
261
  end
263
262
  end
@@ -39,9 +39,10 @@ module Beaker
39
39
  logger.notify "\n* #{step_name}\n"
40
40
  set_current_step_name(step_name)
41
41
  if block_given?
42
- logger.step_in()
43
42
  begin
44
- yield
43
+ logger.with_indent do
44
+ yield
45
+ end
45
46
  rescue Exception => e
46
47
  if(@options.has_key?(:debug_errors) && @options[:debug_errors] == true)
47
48
  logger.info("Exception raised during step execution and debug-errors option is set, entering pry. Exception was: #{e.inspect}")
@@ -50,7 +51,6 @@ module Beaker
50
51
  end
51
52
  raise e
52
53
  end
53
- logger.step_out()
54
54
  end
55
55
  end
56
56
 
@@ -120,9 +120,9 @@ module Beaker
120
120
  logger.notify "\n#{my_name}\n"
121
121
  set_current_test_name(my_name)
122
122
  if block_given?
123
- logger.step_in()
124
- yield
125
- logger.step_out()
123
+ logger.with_indent do
124
+ yield
125
+ end
126
126
  end
127
127
  end
128
128
 
@@ -332,11 +332,11 @@ module Beaker
332
332
  # the options should come at the end of the method signature (rubyism)
333
333
  # and they shouldn't be ssh specific
334
334
 
335
- @logger.step_in()
336
335
  seconds = Benchmark.realtime {
337
- result = connection.execute(cmdline, options, output_callback)
336
+ @logger.with_indent do
337
+ result = connection.execute(cmdline, options, output_callback)
338
+ end
338
339
  }
339
- @logger.step_out()
340
340
 
341
341
  if not options[:silent]
342
342
  @logger.debug "\n#{log_prefix} executed in %0.2f seconds" % seconds
@@ -168,7 +168,7 @@ module Unix::Exec
168
168
  exec(Beaker::Command.new("service ssh restart"))
169
169
  when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|fedora-(1[4-9]|2[0-9])|archlinux-/
170
170
  exec(Beaker::Command.new("systemctl restart sshd.service"))
171
- when /el-|centos|fedora|redhat|amazon|oracle|scientific|eos/
171
+ when /el-|centos|fedora|redhat|oracle|scientific|eos/
172
172
  exec(Beaker::Command.new("/sbin/service sshd restart"))
173
173
  when /sles/
174
174
  exec(Beaker::Command.new("rcsshd restart"))
@@ -196,7 +196,7 @@ module Unix::Exec
196
196
  directory = create_tmpdir_on(self)
197
197
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
198
198
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
199
- when /el-|centos|fedora|redhat|amazon|oracle|scientific|eos/
199
+ when /el-|centos|fedora|redhat|oracle|scientific|eos/
200
200
  directory = create_tmpdir_on(self)
201
201
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
202
202
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
@@ -39,7 +39,7 @@ module Unix::Pkg
39
39
  when /el-4/
40
40
  @logger.debug("Package query not supported on rhel4")
41
41
  return false
42
- when /cisco|fedora|amazon|centos|eos|el-/
42
+ when /cisco|fedora|centos|eos|el-/
43
43
  result = execute("rpm -q #{name}", opts) { |result| result }
44
44
  when /ubuntu|debian|cumulus|huaweios/
45
45
  result = execute("dpkg -s #{name}", opts) { |result| result }
@@ -407,8 +407,8 @@ module Unix::Pkg
407
407
  when /^(solaris)$/
408
408
  release_path_end, release_file = solaris_puppet_agent_dev_package_info(
409
409
  puppet_collection, puppet_agent_version, opts )
410
- when /^(sles|aix|el|centos|oracle|redhat|amazon|scientific)$/
411
- variant = 'el' if variant.match(/(?:el|centos|oracle|redhat|amazon|scientific)/)
410
+ when /^(sles|aix|el|centos|oracle|redhat|scientific)$/
411
+ variant = 'el' if variant.match(/(?:el|centos|oracle|redhat|scientific)/)
412
412
  arch = 'ppc' if variant == 'aix' && arch == 'power'
413
413
  version = '7.1' if variant == 'aix' && version == '7.2'
414
414
  release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
@@ -444,7 +444,7 @@ module Beaker
444
444
  host.exec(Command.new("sudo su -c \"service ssh restart\""), {:pty => true})
445
445
  elsif host['platform'] =~ /arch|centos-7|el-7|redhat-7|fedora-(1[4-9]|2[0-9])/
446
446
  host.exec(Command.new("sudo -E systemctl restart sshd.service"), {:pty => true})
447
- elsif host['platform'] =~ /centos|el-|redhat|amazon|fedora|eos/
447
+ elsif host['platform'] =~ /centos|el-|redhat|fedora|eos/
448
448
  host.exec(Command.new("sudo -E /sbin/service sshd reload"), {:pty => true})
449
449
  elsif host['platform'] =~ /(free|open)bsd/
450
450
  host.exec(Command.new("sudo /etc/rc.d/sshd restart"))
@@ -463,7 +463,7 @@ module Beaker
463
463
  def disable_se_linux host, opts
464
464
  logger = opts[:logger]
465
465
  block_on host do |host|
466
- if host['platform'] =~ /centos|el-|redhat|amazon|fedora|eos/
466
+ if host['platform'] =~ /centos|el-|redhat|fedora|eos/
467
467
  @logger.debug("Disabling se_linux on #{host.name}")
468
468
  host.exec(Command.new("sudo su -c \"setenforce 0\""), {:pty => true})
469
469
  else
@@ -479,7 +479,7 @@ module Beaker
479
479
  def disable_iptables host, opts
480
480
  logger = opts[:logger]
481
481
  block_on host do |host|
482
- if host['platform'] =~ /centos|el-|redhat|amazon|fedora|eos/
482
+ if host['platform'] =~ /centos|el-|redhat|fedora|eos/
483
483
  logger.debug("Disabling iptables on #{host.name}")
484
484
  host.exec(Command.new("sudo su -c \"/etc/init.d/iptables stop\""), {:pty => true})
485
485
  else
@@ -502,7 +502,7 @@ module Beaker
502
502
  case host['platform']
503
503
  when /ubuntu/, /debian/, /cumulus/
504
504
  host.exec(Command.new("echo 'Acquire::http::Proxy \"#{opts[:package_proxy]}/\";' >> /etc/apt/apt.conf.d/10proxy"))
505
- when /^el-/, /centos/, /fedora/, /redhat/, /amazon/, /eos/
505
+ when /^el-/, /centos/, /fedora/, /redhat/, /eos/
506
506
  host.exec(Command.new("echo 'proxy=#{opts[:package_proxy]}/' >> /etc/yum.conf"))
507
507
  else
508
508
  logger.debug("Attempting to enable package manager proxy support on non-supported platform: #{host.name}: #{host['platform']}")
@@ -596,7 +596,7 @@ module Beaker
596
596
  #
597
597
  # @return [Boolean] if the host is el_based
598
598
  def el_based? host
599
- ['centos','redhat','amazon','scientific','el','oracle'].include?(host['platform'].variant)
599
+ ['centos','redhat','scientific','el','oracle'].include?(host['platform'].variant)
600
600
  end
601
601
 
602
602
  end
@@ -232,9 +232,19 @@ module Beaker
232
232
  end
233
233
  end
234
234
 
235
+ # Indent the step level for the duration of block.
236
+ def with_indent(&block)
237
+ old_line_prefix = self.line_prefix.dup
238
+ self.line_prefix << ' '
239
+ yield
240
+ ensure
241
+ self.line_prefix = old_line_prefix
242
+ end
243
+
235
244
  # Sets the step level appropriately for logging to be indented correctly
236
245
  #
237
246
  # @return nil
247
+ # @deprecated use {Logger#with_indent}
238
248
  def step_in
239
249
  self.line_prefix = self.line_prefix + ' '
240
250
  end
@@ -242,6 +252,7 @@ module Beaker
242
252
  # Sets the step level appropriately for logging to be indented correctly
243
253
  #
244
254
  # @return nil
255
+ # @deprecated use {Logger#with_indent}
245
256
  def step_out
246
257
  self.line_prefix = self.line_prefix.chop.chop
247
258
  end
@@ -206,7 +206,8 @@ module Beaker
206
206
  # 4. options file values
207
207
  # 5. subcommand options, if executing beaker subcommands
208
208
  # 6. subcommand options from $HOME/.beaker/subcommand_options.yaml
209
- # 7. default or preset values are given the lowest priority
209
+ # 7. project values in .beaker.yml
210
+ # 8. default or preset values are given the lowest priority
210
211
  #
211
212
  # @param [Array] args ARGV or a provided arguments array
212
213
  # @raise [ArgumentError] Raises error on bad input
@@ -217,18 +218,25 @@ module Beaker
217
218
  cmd_line_options[:command_line] = ([$0] + args).join(' ')
218
219
  @attribution = @attribution.merge(tag_sources(cmd_line_options, "flag"))
219
220
 
221
+ # Merge options in reverse precedence order. First project options,
222
+ # then global options from $HOME/.beaker/subcommand_options.yaml,
223
+ # then subcommand options in the project.
220
224
  subcommand_options_file = Beaker::Subcommands::SubcommandUtil::SUBCOMMAND_OPTIONS
221
- options_files = {"homedir" => "#{ENV['HOME']}/#{subcommand_options_file}", "subcommand" => subcommand_options_file}
222
-
223
- # Global subcommand options from $HOME/.beaker/subcommand_options.yaml are first to get merged into presets
224
- # Subcommands are the second to get merged into presets
225
- options_files.each do |src, path|
226
- opts = Beaker::Options::SubcommandOptionsParser.parse_subcommand_options(args, path)
225
+ {
226
+ "project" => ".beaker.yml",
227
+ "homedir" => "#{ENV['HOME']}/#{subcommand_options_file}",
228
+ "subcommand" => subcommand_options_file,
229
+ }.each_pair do |src, path|
230
+ opts = if src == "project"
231
+ Beaker::Options::SubcommandOptionsParser.parse_options_file(path)
232
+ else
233
+ Beaker::Options::SubcommandOptionsParser.parse_subcommand_options(args, path)
234
+ end
227
235
  @attribution = @attribution.merge(tag_sources(opts, src))
228
236
  @options.merge!(opts)
229
237
  end
230
238
 
231
- file_options = Beaker::Options::OptionsFileParser.parse_options_file(cmd_line_options[:options_file])
239
+ file_options = Beaker::Options::OptionsFileParser.parse_options_file(cmd_line_options[:options_file] || options[:options_file])
232
240
  @attribution = @attribution.merge(tag_sources(file_options, "options_file"))
233
241
 
234
242
  # merge together command line and file_options
@@ -4,8 +4,8 @@ module Beaker
4
4
 
5
5
  PERF_PACKAGES = ['sysstat']
6
6
  # SLES does not treat sysstat as a service that can be started
7
- PERF_SUPPORTED_PLATFORMS = /debian|ubuntu|redhat|amazon|centos|oracle|scientific|fedora|el|eos|cumulus|sles/
8
- PERF_START_PLATFORMS = /debian|ubuntu|redhat|amazon|centos|oracle|scientific|fedora|el|eos|cumulus/
7
+ PERF_SUPPORTED_PLATFORMS = /debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus|sles/
8
+ PERF_START_PLATFORMS = /debian|ubuntu|redhat|centos|oracle|scientific|fedora|el|eos|cumulus/
9
9
 
10
10
  # Create the Perf instance and runs setup_perf_on_host on all hosts if --collect-perf-data
11
11
  # was used as an option on the Baker command line invocation. Instances of this class do not
@@ -50,7 +50,7 @@ module Beaker
50
50
  @logger.perf_output("Enabling aggressive sysstat polling")
51
51
  if host['platform'] =~ /debian|ubuntu/
52
52
  host.exec(Command.new('sed -i s/5-55\\\/10/*/ /etc/cron.d/sysstat'))
53
- elsif host['platform'] =~ /centos|el|fedora|oracle|redhats|amazon|scientific/
53
+ elsif host['platform'] =~ /centos|el|fedora|oracle|redhats|scientific/
54
54
  host.exec(Command.new('sed -i s/*\\\/10/*/ /etc/cron.d/sysstat'))
55
55
  end
56
56
  end
@@ -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 = /^(huaweios|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|amazon|scientific|sles|ubuntu|windows|solaris|aix|archlinux|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|archlinux|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
7
7
  # Platform version numbers vs. codenames conversion hash
8
8
  PLATFORM_VERSION_CODES =
9
9
  { :debian => { "stretch" => "9",
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.29.0'
3
+ STRING = '3.30.0'
4
4
  end
5
5
  end
@@ -47,6 +47,7 @@ module Beaker
47
47
 
48
48
  let(:cli) {
49
49
  allow(File).to receive(:exists?).and_return(true)
50
+ allow(File).to receive(:exists?).with('.beaker.yml').and_return(false)
50
51
  Beaker::CLI.new.parse_options
51
52
  }
52
53
 
@@ -61,7 +62,7 @@ module Beaker
61
62
  end
62
63
  end
63
64
 
64
- context '#combined_instance_and_options_hosts' do
65
+ describe '#combined_instance_and_options_hosts' do
65
66
  let (:options_host) { {'HOSTS' => {'ubuntu' => {:options_attribute => 'options'}} }}
66
67
  let (:instance_host ) {
67
68
  [Beaker::Host.create('ubuntu', {:platform => 'host'}, {} )]
@@ -78,6 +79,26 @@ module Beaker
78
79
  expect(merged_host['ubuntu'][:options_attribute]).to eq('options')
79
80
  expect(merged_host['ubuntu'][:platform]).to eq('host')
80
81
  end
82
+
83
+ context 'when hosts share IP addresses' do
84
+ let (:options_host) do
85
+ {'HOSTS' => {'host1' => {:options_attribute => 'options'},
86
+ 'host2' => {:options_attribute => 'options'}}}
87
+ end
88
+ let (:instance_host ) do
89
+ [Beaker::Host.create('host1',
90
+ {:platform => 'host', :ip => '127.0.0.1'}, {} ),
91
+ Beaker::Host.create('host2',
92
+ {:platform => 'host', :ip => '127.0.0.1'}, {} )]
93
+ end
94
+
95
+ it 'creates separate entries for each host' do
96
+ expected_hosts = instance_host.map(&:hostname)
97
+ merged_hosts = cli.combined_instance_and_options_hosts
98
+
99
+ expect(merged_hosts.keys).to eq(expected_hosts)
100
+ end
101
+ end
81
102
  end
82
103
 
83
104
  context 'execute!' do
@@ -28,10 +28,9 @@ describe ClassMixedWithDSLStructure do
28
28
  end
29
29
 
30
30
  it 'yields if a block is given' do
31
- expect( subject ).to receive( :logger ).and_return( logger ).exactly(3).times
31
+ expect( subject ).to receive( :logger ).and_return( logger ).exactly(2).times
32
32
  allow( subject ).to receive( :set_current_step_name )
33
- expect( logger ).to receive( :step_in )
34
- expect( logger ).to receive( :step_out )
33
+ allow( logger ).to receive(:with_indent) { |&block| block.call }
35
34
  expect( logger ).to receive( :notify )
36
35
  expect( subject ).to receive( :foo )
37
36
  subject.step 'blah' do
@@ -130,10 +129,9 @@ describe ClassMixedWithDSLStructure do
130
129
 
131
130
  it 'yields if a block is given' do
132
131
  subject.instance_variable_set(:@options, options)
133
- expect( subject ).to receive( :logger ).and_return( logger ).exactly(3).times
132
+ expect( subject ).to receive( :logger ).and_return( logger ).exactly(2).times
134
133
  expect( logger ).to receive( :notify )
135
- expect( logger ).to receive( :step_in )
136
- expect( logger ).to receive( :step_out )
134
+ allow( logger ).to receive(:with_indent) { |&block| block.call }
137
135
  expect( subject ).to receive( :foo )
138
136
  subject.manual_test 'blah' do
139
137
  subject.foo
@@ -164,10 +162,9 @@ describe ClassMixedWithDSLStructure do
164
162
  end
165
163
 
166
164
  it 'yields if a block is given' do
167
- expect( subject ).to receive( :logger ).and_return( logger ).exactly(3).times
165
+ expect( subject ).to receive( :logger ).and_return( logger ).exactly(2).times
168
166
  expect( logger ).to receive( :notify )
169
- expect( logger ).to receive( :step_in )
170
- expect( logger ).to receive( :step_out )
167
+ allow( logger ).to receive(:with_indent) { |&block| block.call }
171
168
  expect( subject ).to receive( :foo )
172
169
  subject.test_name 'blah' do
173
170
  subject.foo
@@ -383,4 +380,4 @@ describe ClassMixedWithDSLStructure do
383
380
  end
384
381
  end
385
382
 
386
- end
383
+ end
@@ -85,7 +85,7 @@ describe Beaker do
85
85
  ]
86
86
  end
87
87
 
88
- ['centos','el-','redhat','fedora','amazon','eos'].each do | rhel_like |
88
+ ['centos','el-','redhat','fedora','eos'].each do | rhel_like |
89
89
  it_should_behave_like 'enables_root_login', rhel_like, [
90
90
  "sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\"",
91
91
  "sudo -E /sbin/service sshd reload"
@@ -209,8 +209,7 @@ module Beaker
209
209
  logger = double(:logger)
210
210
  allow( logger ).to receive(:host_output)
211
211
  allow( logger ).to receive(:debug)
212
- allow( logger ).to receive(:step_in)
213
- allow( logger ).to receive(:step_out)
212
+ allow( logger ).to receive(:with_indent) { |&block| block.call }
214
213
  host.instance_variable_set :@logger, logger
215
214
  conn = double(:connection)
216
215
  allow( conn ).to receive(:execute).and_return(result)
@@ -47,11 +47,19 @@ module Beaker
47
47
  end
48
48
 
49
49
  context '#prefix_log_line' do
50
- def prefix_log_line_test_compare_helper(in_test, out_answer, step_in_loop=1)
51
- logger.line_prefix = ''
52
- step_in_loop.times { logger.step_in() }
53
- expect( logger.prefix_log_line(in_test) ).to be === out_answer
50
+ around :each do |example|
54
51
  logger.line_prefix = ''
52
+ begin
53
+ example.run
54
+ ensure
55
+ logger.line_prefix = ''
56
+ end
57
+ end
58
+
59
+ def prefix_log_line_test_compare_helper(in_test, out_answer)
60
+ logger.with_indent do
61
+ expect( logger.prefix_log_line(in_test) ).to be === out_answer
62
+ end
55
63
  end
56
64
 
57
65
  it 'can be successfully called with a arrays' do
@@ -81,68 +89,70 @@ module Beaker
81
89
  it 'can be nested' do
82
90
  line_arg = "\n\nwhy should this matter"
83
91
  answer = " \n \n why should this matter"
84
- prefix_log_line_test_compare_helper(line_arg, answer, 3)
92
+ logger.with_indent do
93
+ logger.with_indent do
94
+ logger.with_indent do
95
+ expect( logger.prefix_log_line(line_arg) ).to be === answer
96
+ end
97
+ end
98
+ end
85
99
  end
86
100
  end
87
101
 
88
- context '#step_* methods' do
89
- it 'steps in correctly (simple case)' do
90
- logger.line_prefix = ''
91
- logger.step_in()
92
- expect( logger.line_prefix ).to be === ' '
102
+ context 'when indenting' do
103
+ around :each do |example|
93
104
  logger.line_prefix = ''
105
+ begin
106
+ example.run
107
+ ensure
108
+ logger.line_prefix = ''
109
+ end
94
110
  end
95
111
 
96
- it 'sets length correctly in mixed scenario ' do
97
- logger.line_prefix = ''
98
- logger.step_in()
99
- logger.step_in()
100
- logger.step_out()
101
- logger.step_in()
102
- logger.step_in()
103
- logger.step_out()
104
- expect( logger.line_prefix ).to be === ' '
105
- logger.line_prefix = ''
112
+ it 'steps in correctly (simple case)' do
113
+ logger.with_indent do
114
+ expect( logger.line_prefix ).to be === ' '
115
+ end
106
116
  end
107
117
 
108
- it 'can be unevenly stepped out, will remain at base: 0' do
109
- logger.line_prefix = ''
110
- logger.step_in()
111
- 10.times { logger.step_out() }
112
- expect( logger.line_prefix ).to be === ''
118
+ it 'sets length correctly in mixed scenario ' do
119
+ logger.with_indent do
120
+ logger.with_indent {}
121
+ logger.with_indent do
122
+ logger.with_indent {}
123
+ expect( logger.line_prefix ).to be === ' '
124
+ end
125
+ end
113
126
  end
114
127
 
115
128
  it 'can handle arbitrary strings as prefixes' do
116
- logger.line_prefix = ''
117
129
  logger.line_prefix = 'Some string:'
118
130
  expect( logger.line_prefix ).to be === 'Some string:'
119
- logger.line_prefix = ''
120
131
  end
121
132
 
122
133
  it 'can handle stepping in with arbitrary strings' do
123
- logger.line_prefix = ''
124
134
  logger.line_prefix = 'Some string:'
125
- logger.step_in()
126
- logger.step_in()
127
- expect( logger.line_prefix ).to be === 'Some string: '
128
- logger.line_prefix = ''
135
+ logger.with_indent do
136
+ logger.with_indent do
137
+ expect( logger.line_prefix ).to be === 'Some string: '
138
+ end
139
+ end
129
140
  end
130
141
 
131
- it 'can handle stepping out with arbitrary strings' do
132
- logger.line_prefix = ''
142
+ it 'can handle stepping in and out with arbitrary strings' do
133
143
  logger.line_prefix = 'Some string:'
134
- 10.times { logger.step_out() }
135
- expect( logger.line_prefix ).to be === ''
136
- logger.line_prefix = ''
144
+ 10.times { logger.with_indent {} }
145
+ expect( logger.line_prefix ).to be === 'Some string:'
137
146
  end
138
147
 
139
- it 'can handle stepping in and out with arbitrary strings' do
140
- logger.line_prefix = ''
148
+ it 'restores the original prefix if an argument is raised' do
141
149
  logger.line_prefix = 'Some string:'
142
- 10.times { logger.step_in() }
143
- 10.times { logger.step_out() }
144
- expect( logger.line_prefix ).to be === 'Some string:'
145
- logger.line_prefix = ''
150
+ expect do
151
+ logger.with_indent do
152
+ raise "whoops"
153
+ end
154
+ end.to raise_error(RuntimeError, 'whoops')
155
+ expect(logger.line_prefix).to eq('Some string:')
146
156
  end
147
157
  end
148
158
 
@@ -154,6 +154,12 @@ module Beaker
154
154
  :auth_methods => 'auth_home_123'
155
155
  }
156
156
  }}
157
+ let(:project_file) {@project_file || {
158
+ :level => 'seventh',
159
+ :ssh => {
160
+ :auth_methods => 'auth_project_123'
161
+ }
162
+ }}
157
163
  let(:presets) { {
158
164
  :level => 'lowest',
159
165
  :ssh => {
@@ -183,11 +189,13 @@ module Beaker
183
189
  allow(OptionsFileParser).to receive(:parse_options_file).and_return(opt_file)
184
190
  allow(parser).to receive(:parse_hosts_options).and_return(host_file)
185
191
 
186
- allow(SubcommandOptionsParser).to receive(:parse_subcommand_options).and_return(homedir_file, subcommand_file)
192
+ allow(SubcommandOptionsParser).to receive(:parse_options_file).with(".beaker.yml").and_return(project_file)
193
+ allow(SubcommandOptionsParser).to receive(:parse_subcommand_options).with(anything, "#{ENV['HOME']}/.beaker/subcommand_options.yaml").and_return(homedir_file)
194
+ allow(SubcommandOptionsParser).to receive(:parse_subcommand_options).with(anything, Pathname(".beaker/subcommand_options.yaml")).and_return(subcommand_file)
187
195
  end
188
196
 
189
197
  it 'presets have the lowest priority' do
190
- @env = @argv = @host_file = @opt_file = @subcommand_file = @homedir_file = {}
198
+ @env = @argv = @host_file = @opt_file = @subcommand_file = @homedir_file = @project_file = {}
191
199
  mock_out_parsing
192
200
 
193
201
  opts = parser.parse_args([])
@@ -196,6 +204,18 @@ module Beaker
196
204
  expect(attribution[:level]).to be == 'preset'
197
205
  end
198
206
 
207
+ it 'project options should have seventh priority' do
208
+ @env = @argv = @host_file = @opt_file = @subcommand_file = @homedir_file = {}
209
+ mock_out_parsing
210
+
211
+ opts = parser.parse_args([])
212
+ attribution = parser.attribution
213
+ expect(opts[:ssh][:auth_methods]).to be == 'auth_project_123'
214
+ expect(attribution[:ssh][:auth_methods]).to be == 'project'
215
+ expect(opts[:level]).to be == 'seventh'
216
+ expect(attribution[:level]).to be == 'project'
217
+ end
218
+
199
219
  it 'home directory options should have sixth priority' do
200
220
  @env = @argv = @host_file = @opt_file = @subcommand_file = {}
201
221
  mock_out_parsing
@@ -266,6 +286,28 @@ module Beaker
266
286
  expect(attribution[:level]).to be == 'env'
267
287
  end
268
288
 
289
+ it "loads the options file from a project file" do
290
+ mock_out_parsing
291
+
292
+ project_file[:options_file] = 'my_options_file.rb'
293
+ allow(OptionsFileParser).to receive(:parse_options_file).with('my_options_file.rb').and_return(ssh: {config: true})
294
+
295
+ output = parser.parse_args([])
296
+ attribution = parser.attribution
297
+ expect(output[:ssh][:config]).to be true
298
+ expect(attribution[:ssh][:config]).to eq('options_file')
299
+ end
300
+
301
+ it "loads project file options with the init subcommand" do
302
+ @env = @argv = @host_file = @opt_file = @subcommand_file = @homedir_file = {}
303
+ mock_out_parsing
304
+
305
+ output = parser.parse_args(%w[init --hosts redhat7-64ma])
306
+ attribution = parser.attribution
307
+ expect(output[:level]).to eq('seventh')
308
+ expect(attribution[:level]).to eq('project')
309
+ end
310
+
269
311
  end
270
312
 
271
313
  it "can correctly combine arguments from different sources" do
@@ -293,7 +335,6 @@ module Beaker
293
335
  args = ["-h", hosts_path, "--log-level", "debug", "--fail-mode", "nope"]
294
336
  expect { parser.parse_args(args) }.to raise_error(ArgumentError)
295
337
  end
296
-
297
338
  end
298
339
 
299
340
  describe '#parse_hosts_options' do
@@ -146,7 +146,6 @@ module PlatformHelpers
146
146
  'fedora',
147
147
  'redhat',
148
148
  'oracle',
149
- 'amazon',
150
149
  'scientific',
151
150
  'eos'].concat(FEDORASYSTEMV)
152
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.29.0
4
+ version: 3.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-16 00:00:00.000000000 Z
11
+ date: 2018-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -346,6 +346,20 @@ dependencies:
346
346
  - - ~>
347
347
  - !ruby/object:Gem::Version
348
348
  version: '0.1'
349
+ - !ruby/object:Gem::Dependency
350
+ name: beaker-abs
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - ~>
354
+ - !ruby/object:Gem::Version
355
+ version: '0.4'
356
+ type: :runtime
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - ~>
361
+ - !ruby/object:Gem::Version
362
+ version: '0.4'
349
363
  - !ruby/object:Gem::Dependency
350
364
  name: beaker-vmpooler
351
365
  requirement: !ruby/object:Gem::Requirement