beaker 3.35.0 → 3.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +32 -9
  3. data/CHANGELOG.md +15 -1
  4. data/CONTRIBUTING.md +37 -31
  5. data/DOCUMENTING.md +68 -44
  6. data/README.md +14 -31
  7. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
  8. data/beaker.gemspec +1 -1
  9. data/docs/README.md +5 -12
  10. data/docs/concepts/beaker_libraries.md +2 -2
  11. data/docs/concepts/glossary.md +11 -0
  12. data/docs/concepts/style_guide.md +24 -91
  13. data/docs/concepts/test_tagging.md +3 -10
  14. data/docs/concepts/testing_beaker_itself.md +3 -2
  15. data/docs/concepts/ticket_process.md +17 -45
  16. data/docs/how_to/archive_sut_files.md +7 -33
  17. data/docs/how_to/change_terminal_output_coloring.md +7 -4
  18. data/docs/how_to/confine.md +5 -16
  19. data/docs/how_to/debug_beaker_tests.md +14 -6
  20. data/docs/how_to/hosts/README.md +2 -5
  21. data/docs/how_to/hosts/archlinux.md +4 -2
  22. data/docs/how_to/hosts/cisco.md +9 -30
  23. data/docs/how_to/hosts/eos.md +5 -14
  24. data/docs/how_to/hypervisors/README.md +9 -31
  25. data/docs/how_to/install_puppet.md +16 -51
  26. data/docs/how_to/platform_specific_tag_confines.md +11 -31
  27. data/docs/how_to/preserve_hosts.md +13 -54
  28. data/docs/how_to/rake_tasks.md +1 -4
  29. data/docs/how_to/recipes.md +9 -2
  30. data/docs/how_to/run_in_parallel.md +10 -10
  31. data/docs/how_to/ssh_agent_forwarding.md +8 -13
  32. data/docs/how_to/ssh_connection_preference.md +10 -10
  33. data/docs/how_to/test_arbitrary_beaker_versions.md +5 -12
  34. data/docs/how_to/the_beaker_dsl.md +44 -21
  35. data/docs/how_to/upgrade_from_2_to_3.md +13 -53
  36. data/docs/how_to/use_hocon_helpers.md +10 -28
  37. data/docs/how_to/use_user_password_authentication.md +13 -10
  38. data/docs/how_to/write_a_beaker_test_for_a_module.md +6 -2
  39. data/docs/tutorials/README.md +14 -55
  40. data/docs/tutorials/creating_a_test_environment.md +47 -52
  41. data/docs/tutorials/installation.md +57 -21
  42. data/docs/tutorials/lets_write_a_test.md +8 -1
  43. data/docs/tutorials/quick_start_rake_tasks.md +63 -62
  44. data/docs/tutorials/subcommands.md +19 -32
  45. data/docs/tutorials/test_run.md +14 -16
  46. data/docs/tutorials/test_suites.md +14 -43
  47. data/docs/tutorials/the_command_line.md +14 -2
  48. data/lib/beaker/host/unix/pkg.rb +9 -2
  49. data/lib/beaker/host_prebuilt_steps.rb +1 -1
  50. data/lib/beaker/shared/host_manager.rb +6 -3
  51. data/lib/beaker/version.rb +1 -1
  52. data/spec/beaker/host/unix/pkg_spec.rb +66 -17
  53. data/spec/beaker/host/unix_spec.rb +4 -4
  54. data/spec/beaker/host_prebuilt_steps_spec.rb +10 -6
  55. data/spec/beaker/hypervisor/hypervisor_spec.rb +2 -2
  56. data/spec/beaker/shared/host_manager_spec.rb +8 -0
  57. metadata +9 -2
@@ -1,13 +1,19 @@
1
1
  # The Command Line
2
+
2
3
  * Using the gem
3
4
 
4
- $ beaker --log-level debug --hosts sample.cfg --tests test.rb
5
+ ```console
6
+ $ beaker --log-level debug --hosts sample.cfg --tests test.rb
7
+ ```
5
8
 
6
9
  * Using latest git
7
10
 
8
- $ bundle exec beaker --log-level debug --hosts sample.cfg --tests test.rb
11
+ ```console
12
+ $ bundle exec beaker --log-level debug --hosts sample.cfg --tests test.rb
13
+ ```
9
14
 
10
15
  ## Useful options
16
+
11
17
  * `-h, --hosts FILE `, the hosts that you are going to be testing with
12
18
  * `--log-level debug`, for providing verbose logging and full stacktraces on failure
13
19
  * `--[no-]provision`, indicates if beaker should provision new boxes upon test execution. If `no` is selected then beaker will attempt to connect to the hosts as defined in `--hosts FILE` without first creating/running them through their hypervisors
@@ -15,11 +21,17 @@
15
21
  * `--parse-only`, read and parse all command line options, environment options and file options; report the parsed options and exit.
16
22
 
17
23
  ## The Rest
24
+
18
25
  See all options with
26
+
19
27
  * Using the gem
20
28
 
29
+ ```console
21
30
  $ beaker --help
31
+ ```
22
32
 
23
33
  * Using latest git
24
34
 
35
+ ```console
25
36
  $ bundle exec beaker --help
37
+ ```
@@ -417,8 +417,15 @@ module Unix::Pkg
417
417
  puppet_collection, puppet_agent_version, opts )
418
418
  when /^(sles|aix|el|centos|oracle|redhat|scientific)$/
419
419
  variant = 'el' if variant.match(/(?:el|centos|oracle|redhat|scientific)/)
420
- arch = 'ppc' if variant == 'aix' && arch == 'power'
421
- version = '7.1' if variant == 'aix' && version == '7.2'
420
+ if variant == 'aix'
421
+ arch = 'ppc' if arch == 'power'
422
+ version_x, version_y = /^(\d+)\.(\d+)/.match(puppet_agent_version).captures.map(&:to_i)
423
+ if version_x < 5 || version_x == 5 && version_y < 99 # 5.99.z indicates pre-release puppet6
424
+ version = '7.1' if version == '7.2'
425
+ else
426
+ version = '6.1'
427
+ end
428
+ end
422
429
  release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
423
430
  release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.rpm"
424
431
  else
@@ -258,7 +258,7 @@ module Beaker
258
258
  if result.exit_code == 1
259
259
  url_base = opts[:epel_url]
260
260
  url_base = opts[:epel_url_archive] if host['platform'].version == '5'
261
- host.exec(Command.new("rpm -i#{debug_opt} #{url_base}/epel-release-latest-#{host['platform'].version}.noarch.rpm"))
261
+ host.install_package_with_rpm("#{url_base}/epel-release-latest-#{host['platform'].version}.noarch.rpm", '--replacepkgs', { :package_proxy => opts[:package_proxy] })
262
262
  #update /etc/yum.repos.d/epel.repo for new baseurl
263
263
  host.exec(Command.new("sed -i -e 's;#baseurl.*$;baseurl=#{Regexp.escape("#{url_base}/#{host['platform'].version}")}/\$basearch;' /etc/yum.repos.d/epel.repo"))
264
264
  #remove mirrorlist
@@ -33,9 +33,10 @@ module Beaker
33
33
  #@param [Array<Host>] hosts The hosts to examine
34
34
  #@param [String] role The host returned will have this role in its role list
35
35
  #@return [Host] The single host with the desired role in its roles list
36
- #@raise [ArgumentError] Raised if more than one host has the given role defined, or if no host has the
37
- # role defined.
36
+ #@raise [ArgumentError] Raised if more than one host has the given role defined, if no host has the
37
+ # role defined, or if role = nil since hosts_with_role(nil) returns all hosts.
38
38
  def only_host_with_role(hosts, role)
39
+ raise ArgumentError, "role cannot be nil." if role.nil?
39
40
  a_host = hosts_with_role(hosts, role)
40
41
  case
41
42
  when a_host.length == 0
@@ -53,8 +54,10 @@ module Beaker
53
54
  # @param [String] role The host returned will have this role in its role list
54
55
  # @return [Host] The single host with the desired role in its roles list
55
56
  # or nil if no host is found
56
- # @raise [ArgumentError] Raised if more than one host has the given role defined
57
+ # @raise [ArgumentError] Raised if more than one host has the given role defined,
58
+ # or if role = nil since hosts_with_role(nil) returns all hosts.
57
59
  def find_at_most_one_host_with_role(hosts, role)
60
+ raise ArgumentError, "role cannot be nil." if role.nil?
58
61
  role_hosts = hosts_with_role(hosts, role)
59
62
  host_with_role = nil
60
63
  case role_hosts.length
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.35.0'
3
+ STRING = '3.36.0'
4
4
  end
5
5
  end
@@ -288,26 +288,75 @@ module Beaker
288
288
  end
289
289
 
290
290
  describe '#puppet_agent_dev_package_info' do
291
- puppet_collection = 'PC1'
292
- puppet_agent_version = '1.2.3'
293
- platforms = { 'solaris-10-x86_64' => ["solaris/10/#{puppet_collection}", "puppet-agent-#{puppet_agent_version}-1.i386.pkg.gz"],
294
- 'solaris-11-x86_64' => ["solaris/11/#{puppet_collection}", "puppet-agent@#{puppet_agent_version},5.11-1.i386.p5p"],
295
- 'sles-11-x86_64' => ["sles/11/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.sles11.x86_64.rpm"],
296
- 'aix-5.3-power' => ["aix/5.3/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix5.3.ppc.rpm"],
297
- 'el-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
298
- 'centos-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
299
- 'oracle-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
300
- 'redhat-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
301
- 'scientific-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"]
302
- }
303
- platforms.each do |p, v|
304
- it "accomodates platform #{p} without erroring" do
305
- platform = Beaker::Platform.new(p)
306
- @opts = {'platform' => platform}
291
+ let(:download_opts) {{download_url: 'http://trust.me'}}
292
+
293
+ # These platforms are consistent across puppet collections
294
+ shared_examples 'consistent platforms' do |puppet_collection, puppet_agent_version|
295
+ platforms = { 'solaris-10-x86_64' => ["solaris/10/#{puppet_collection}", "puppet-agent-#{puppet_agent_version}-1.i386.pkg.gz"],
296
+ 'solaris-11-x86_64' => ["solaris/11/#{puppet_collection}", "puppet-agent@#{puppet_agent_version},5.11-1.i386.p5p"],
297
+ 'sles-11-x86_64' => ["sles/11/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.sles11.x86_64.rpm"],
298
+ 'aix-6.1-power' => ["aix/6.1/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix6.1.ppc.rpm"],
299
+ 'el-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
300
+ 'centos-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
301
+ 'oracle-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
302
+ 'redhat-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
303
+ 'scientific-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
304
+ }
305
+ platforms.each do |p, v|
306
+ it "accomodates platform #{p} without erroring" do
307
+ @opts = {'platform' => Beaker::Platform.new(p)}
308
+ allow( instance ).to receive(:link_exists?).and_return(true)
309
+ expect( instance.puppet_agent_dev_package_info(puppet_collection, puppet_agent_version, download_opts) ).to eq(v)
310
+ end
311
+ end
312
+ end
313
+
314
+ # AIX platform/package pairs differ accross collections
315
+ shared_examples 'aix platform' do |package_version, platform_version, puppet_collection, puppet_agent_version|
316
+ it "selects AIX #{package_version} packages for AIX #{platform_version}" do
317
+ @opts = { 'platform' => Beaker::Platform.new("aix-#{platform_version}-power") }
307
318
  allow( instance ).to receive(:link_exists?).and_return(true)
308
- expect( instance.puppet_agent_dev_package_info( puppet_collection, puppet_agent_version, { :download_url => 'http://trust.me' } )).to eq(v)
319
+ expect( instance.puppet_agent_dev_package_info(puppet_collection, puppet_agent_version, download_opts) )
320
+ .to eq(["aix/#{package_version}/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix#{package_version}.ppc.rpm"])
309
321
  end
310
322
  end
323
+
324
+ context 'with puppet-agent 1.y.z' do
325
+ puppet_collection = 'PC1'
326
+ puppet_agent_version = '1.2.3'
327
+
328
+ include_examples 'consistent platforms', puppet_collection, puppet_agent_version
329
+ include_examples 'aix platform', '5.3', '5.3', puppet_collection, puppet_agent_version
330
+ include_examples 'aix platform', '7.1', '7.1', puppet_collection, puppet_agent_version
331
+ include_examples 'aix platform', '7.1', '7.2', puppet_collection, puppet_agent_version
332
+ end
333
+
334
+ context 'with puppet-agent 5.y.z' do
335
+ puppet_collection = 'puppet5'
336
+ puppet_agent_version = '5.4.3'
337
+
338
+ include_examples 'consistent platforms', puppet_collection, puppet_agent_version
339
+ include_examples 'aix platform', '7.1', '7.1', puppet_collection, puppet_agent_version
340
+ include_examples 'aix platform', '7.1', '7.2', puppet_collection, puppet_agent_version
341
+ end
342
+
343
+ context 'with puppet-agent 5.99.z' do
344
+ puppet_collection = 'puppet6'
345
+ puppet_agent_version = '5.99.0'
346
+
347
+ include_examples 'consistent platforms', puppet_collection, puppet_agent_version
348
+ include_examples 'aix platform', '6.1', '7.1', puppet_collection, puppet_agent_version
349
+ include_examples 'aix platform', '6.1', '7.2', puppet_collection, puppet_agent_version
350
+ end
351
+
352
+ context 'with puppet6' do
353
+ puppet_collection = 'puppet6'
354
+ puppet_agent_version = '6.6.6'
355
+
356
+ include_examples 'consistent platforms', puppet_collection, puppet_agent_version
357
+ include_examples 'aix platform', '6.1', '7.1', puppet_collection, puppet_agent_version
358
+ include_examples 'aix platform', '6.1', '7.2', puppet_collection, puppet_agent_version
359
+ end
311
360
  end
312
361
 
313
362
  describe '#upgrade_package' do
@@ -171,11 +171,11 @@ module Unix
171
171
  end
172
172
 
173
173
  it 'sets the arch correctly on aix-power platforms' do
174
- @platform = 'aix-14-power'
174
+ @platform = 'aix-6.1-power'
175
175
  release_path_end, release_file = host.puppet_agent_dev_package_info(
176
- 'pa_collection', 'pa_version2' )
177
- expect( release_path_end ).to be === "aix/14/pa_collection/ppc"
178
- expect( release_file ).to be === "puppet-agent-pa_version2-1.aix14.ppc.rpm"
176
+ 'pa_collection', '6.0.0' )
177
+ expect( release_path_end ).to be === "aix/6.1/pa_collection/ppc"
178
+ expect( release_file ).to be === "puppet-agent-6.0.0-1.aix6.1.ppc.rpm"
179
179
  end
180
180
  end
181
181
 
@@ -318,9 +318,11 @@ describe Beaker do
318
318
  expect( Beaker::Command ).to receive( :new ).with(
319
319
  "rpm -qa | grep epel-release"
320
320
  ).exactly( 2 ).times
321
- expect( Beaker::Command ).to receive( :new ).with(
322
- "rpm -i http://archive.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm"
323
- ).exactly( 2 ).times
321
+ hosts.each do |host|
322
+ expect(host).to receive( :install_package_with_rpm ).with(
323
+ "http://archive.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm", "--replacepkgs", {:package_proxy => false}
324
+ ).once
325
+ end
324
326
  expect( Beaker::Command ).to receive( :new ).with(
325
327
  "sed -i -e 's;#baseurl.*$;baseurl=http://archive\\.fedoraproject\\.org/pub/archive/epel/5/$basearch;' /etc/yum.repos.d/epel.repo"
326
328
  ).exactly( 2 ).times
@@ -345,9 +347,11 @@ describe Beaker do
345
347
  expect( Beaker::Command ).to receive( :new ).with(
346
348
  "rpm -qa | grep epel-release"
347
349
  ).exactly( 4 ).times
348
- expect( Beaker::Command ).to receive( :new ).with(
349
- "rpm -i http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm"
350
- ).exactly( 4 ).times
350
+ hosts.each do |host|
351
+ expect(host).to receive( :install_package_with_rpm ).with(
352
+ "http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm", "--replacepkgs", {:package_proxy => false}
353
+ ).once
354
+ end
351
355
  expect( Beaker::Command ).to receive( :new ).with(
352
356
  "sed -i -e 's;#baseurl.*$;baseurl=http://dl\\.fedoraproject\\.org/pub/epel/6/$basearch;' /etc/yum.repos.d/epel.repo"
353
357
  ).exactly( 4 ).times
@@ -30,11 +30,11 @@ module Beaker
30
30
  end
31
31
 
32
32
  it "gives highest precedence to preference specified in host file followed by hypervisor" do
33
- hosts[0].options[:ssh_preference] = ['set', 'in', 'hostfile']
33
+ hosts[0].options[:ssh_preference] = [:set, :in, :hostfile]
34
34
  hypervisor.create('none', hosts, make_opts())
35
35
  allow(hypervisor).to receive(:connection_preference).and_return([:hypervisor, :pref])
36
36
  hypervisor.set_ssh_connection_preference(hosts, hypervisor)
37
- expect(hosts[0][:ssh_connection_preference]).to eq(['set', 'in', 'hostfile', :hypervisor, :pref, :ip, :vmhostname, :hostname])
37
+ expect(hosts[0][:ssh_connection_preference]).to eq([:set, :in, :hostfile, :hypervisor, :pref, :ip, :vmhostname, :hostname])
38
38
  end
39
39
 
40
40
  end
@@ -98,6 +98,10 @@ module Beaker
98
98
  expect{ host_handler.only_host_with_role( hosts, 'surprise' ) }.to raise_error(ArgumentError)
99
99
 
100
100
  end
101
+
102
+ it "throws an error when role = nil" do
103
+ expect{ host_handler.find_at_most_one_host_with_role( hosts, nil ) }.to raise_error(ArgumentError)
104
+ end
101
105
  end
102
106
 
103
107
  context "#find_at_most_one_host_with_role" do
@@ -118,6 +122,10 @@ module Beaker
118
122
  expect( host_handler.find_at_most_one_host_with_role( hosts, 'surprise' ) ).to be_nil
119
123
 
120
124
  end
125
+
126
+ it "throws an error when role = nil" do
127
+ expect{ host_handler.find_at_most_one_host_with_role( hosts, nil ) }.to raise_error(ArgumentError)
128
+ end
121
129
  end
122
130
 
123
131
  context "#run_block_on" do
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.35.0
4
+ version: 3.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -45,6 +45,9 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.6'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 0.14.0
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,6 +55,9 @@ dependencies:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0.6'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.14.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: simplecov
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -579,6 +585,7 @@ files:
579
585
  - docs/concepts/argument_processing_and_precedence.md
580
586
  - docs/concepts/beaker_libraries.md
581
587
  - docs/concepts/beaker_vs_beaker_rspec.md
588
+ - docs/concepts/glossary.md
582
589
  - docs/concepts/masterless_puppet.md
583
590
  - docs/concepts/roles_what_are_they.md
584
591
  - docs/concepts/shared_options_for_executing_beaker_commands.md