beaker 2.27.0 → 2.28.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.
Files changed (98) hide show
  1. checksums.yaml +8 -8
  2. data/HISTORY.md +378 -2
  3. data/README.md +1 -3
  4. data/acceptance/config/acceptance-options.rb +3 -0
  5. data/acceptance/fixtures/files/failing_shell_script.txt +3 -0
  6. data/acceptance/fixtures/files/retry_script.txt +14 -0
  7. data/acceptance/fixtures/files/shell_script_with_output.txt +3 -0
  8. data/acceptance/fixtures/files/simple_text_file.txt +3 -0
  9. data/acceptance/fixtures/files/sles-11-x86_64.repo +5 -0
  10. data/acceptance/lib/helpers/test_helper.rb +111 -0
  11. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +17 -0
  12. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +50 -0
  13. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +64 -0
  14. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +100 -0
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +201 -0
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +68 -0
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +48 -0
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +28 -0
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +142 -0
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/echo_on_test.rb +13 -0
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +67 -0
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +109 -0
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +42 -0
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +143 -0
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +242 -0
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +69 -0
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +53 -0
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +53 -0
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +54 -0
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +51 -0
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +92 -0
  32. data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +47 -0
  33. data/acceptance/tests/base/{host.rb → host_test.rb} +2 -0
  34. data/acceptance/tests/hypervisor/{communication.rb → communication_test.rb} +0 -0
  35. data/acceptance/tests/load_path_bootstrap.rb +10 -0
  36. data/acceptance/tests/puppet/{install_smoke.rb → install_smoke_test.rb} +0 -0
  37. data/beaker.gemspec +1 -1
  38. data/docs/Access-the-Live-Test-Console-with-Pry.md +305 -0
  39. data/docs/Argument-Processing-and-Precedence.md +325 -0
  40. data/docs/Beaker-Installation.md +59 -0
  41. data/docs/Beaker-Owners-and-Reviewers.md +16 -0
  42. data/docs/Beaker-Test-Tagging.md +76 -0
  43. data/docs/Beaker-with-Masterless-Puppet.md +42 -0
  44. data/docs/Creating-A-Test-Environment.md +91 -0
  45. data/docs/Docker-Support.md +129 -0
  46. data/docs/EC2-Support.md +77 -0
  47. data/docs/Example-Vagrant-Hosts-Files.md +66 -0
  48. data/docs/File-a-Beaker-Bug.md +3 -0
  49. data/docs/Google-Compute-Engine-Support.md +41 -0
  50. data/docs/How-To-Beaker.md +7 -0
  51. data/docs/How-To-Use-User-Password-Authentication-with-Beaker.md +53 -0
  52. data/docs/How-to-Write-a-Beaker-Test-for-a-Module.md +145 -0
  53. data/docs/Lets-Write-a-Test.md +73 -0
  54. data/docs/Openstack-Support.md +32 -0
  55. data/docs/Overview.md +31 -0
  56. data/docs/README.md +43 -0
  57. data/docs/Roles-What-Are-They.md +44 -0
  58. data/docs/Shared-Options-for-Executing-Beaker-Commands.md +43 -0
  59. data/docs/Solaris-Support.md +10 -0
  60. data/docs/The-Beaker-DSL.md +283 -0
  61. data/docs/The-Command-Line.md +24 -0
  62. data/docs/Types,-Puppet-4,-and-the-All-In-One-Agent.md +13 -0
  63. data/docs/VMWare-Fusion-Support.md +36 -0
  64. data/docs/Vagrant-Support.md +47 -0
  65. data/docs/beaker-vs.-beaker-rspec.md +87 -0
  66. data/docs/hosts/README.md +8 -0
  67. data/docs/hosts/eos.md +30 -0
  68. data/docs/hypervisors/README.md +8 -0
  69. data/docs/hypervisors/aws.md +143 -0
  70. data/docs/vSphere-Support.md +46 -0
  71. data/lib/beaker/dsl/helpers/host_helpers.rb +2 -4
  72. data/lib/beaker/dsl/helpers/puppet_helpers.rb +45 -11
  73. data/lib/beaker/dsl/install_utils/foss_utils.rb +20 -23
  74. data/lib/beaker/dsl/install_utils/module_utils.rb +4 -0
  75. data/lib/beaker/dsl/install_utils/pe_utils.rb +2 -6
  76. data/lib/beaker/dsl/patterns.rb +1 -1
  77. data/lib/beaker/host.rb +3 -0
  78. data/lib/beaker/host/eos.rb +56 -0
  79. data/lib/beaker/host/mac/pkg.rb +1 -1
  80. data/lib/beaker/host/unix/pkg.rb +36 -0
  81. data/lib/beaker/hypervisor/aws_sdk.rb +1 -1
  82. data/lib/beaker/hypervisor/vagrant.rb +3 -3
  83. data/lib/beaker/logger.rb +1 -0
  84. data/lib/beaker/options/presets.rb +5 -0
  85. data/lib/beaker/shared/host_manager.rb +7 -4
  86. data/lib/beaker/version.rb +1 -1
  87. data/spec/beaker/dsl/helpers/puppet_helpers_spec.rb +87 -0
  88. data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +53 -20
  89. data/spec/beaker/dsl/install_utils/module_utils_spec.rb +1 -1
  90. data/spec/beaker/dsl/install_utils/pe_utils_spec.rb +7 -14
  91. data/spec/beaker/host/eos_spec.rb +65 -0
  92. data/spec/beaker/host/unix/pkg_spec.rb +42 -0
  93. data/spec/beaker/hypervisor/aws_sdk_spec.rb +17 -56
  94. data/spec/beaker/hypervisor/vagrant_spec.rb +1 -1
  95. data/spec/beaker/logger_spec.rb +1 -1
  96. data/spec/mocks.rb +0 -13
  97. metadata +76 -6
  98. data/acceptance/tests/dsl/install_utils/clone_git_repo_on.rb +0 -50
@@ -0,0 +1,53 @@
1
+ require "helpers/test_helper"
2
+
3
+ test_name "dsl::helpers::host_helpers #run_script" do
4
+ step "#run_script fails when the local script cannot be found" do
5
+ assert_raises IOError do
6
+ run_script "/non/existent/testfile.sh"
7
+ end
8
+ end
9
+
10
+ step "#run_script fails when there is an error running the remote script" do
11
+ Dir.mktmpdir do |local_dir|
12
+ local_filename = File.join(local_dir, "testfile.sh")
13
+ local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
14
+
15
+ assert_raises Beaker::Host::CommandFailure do
16
+ run_script local_filename
17
+ end
18
+ end
19
+ end
20
+
21
+ step "#run_script passes along options when running the remote command" do
22
+ Dir.mktmpdir do |local_dir|
23
+ local_filename = File.join(local_dir, "testfile.sh")
24
+ local_filename, contents = create_local_file_from_fixture("failing_shell_script", local_dir, "testfile.sh", "a+x")
25
+
26
+ result = run_script local_filename, { :accept_all_exit_codes => true }
27
+ assert_equal 1, result.exit_code
28
+ end
29
+ end
30
+
31
+ step "#run_script runs the script on the remote host" do
32
+ Dir.mktmpdir do |local_dir|
33
+ local_filename = File.join(local_dir, "testfile.sh")
34
+ local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
35
+
36
+ results = run_script local_filename
37
+ assert_equal 0, results.exit_code
38
+ assert_equal "output\n", results.stdout
39
+ end
40
+ end
41
+
42
+ step "#run_script allows assertions in an optional block" do
43
+ Dir.mktmpdir do |local_dir|
44
+ local_filename = File.join(local_dir, "testfile.sh")
45
+ local_filename, contents = create_local_file_from_fixture("shell_script_with_output", local_dir, "testfile.sh", "a+x")
46
+
47
+ results = run_script local_filename do
48
+ assert_equal 0, exit_code
49
+ assert_equal "output\n", stdout
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ require "helpers/test_helper"
2
+
3
+ test_name "dsl::helpers::host_helpers #scp_from" do
4
+ if test_scp_error_on_close?
5
+ step "#scp_from fails if the local path cannot be found" do
6
+ remote_tmpdir = tmpdir_on default
7
+ remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
8
+
9
+ assert_raises Beaker::Host::CommandFailure do
10
+ scp_from default, remote_filename, "/non/existent/file.txt"
11
+ end
12
+ end
13
+
14
+ step "#scp_from fails if the remote file cannot be found" do
15
+ Dir.mktmpdir do |local_dir|
16
+ assert_raises Beaker::Host::CommandFailure do
17
+ scp_from default, "/non/existent/remote/file.txt", local_dir
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ step "#scp_from creates the file on the local system" do
24
+ Dir.mktmpdir do |local_dir|
25
+ remote_tmpdir = tmpdir_on default
26
+ remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
27
+
28
+ scp_from default, remote_filename, local_dir
29
+
30
+ local_filename = File.join(local_dir, "testfile.txt")
31
+ assert_equal contents, File.read(local_filename)
32
+ end
33
+ end
34
+
35
+ step "#scp_from CURRENTLY creates and repeatedly overwrites the file on the local system when given a hosts array" do
36
+ # NOTE: expect this behavior to be well-documented, or for overwriting a
37
+ # file repeatedly to generate an error
38
+
39
+ Dir.mktmpdir do |local_dir|
40
+ remote_tmpdir = tmpdir_on default
41
+ remote_filename = File.join(remote_tmpdir, "testfile.txt")
42
+ on hosts, "mkdir -p #{remote_tmpdir}"
43
+ results = on hosts, %Q{echo "${RANDOM}:${RANDOM}:${RANDOM}" > #{remote_filename}}
44
+
45
+ scp_from hosts, remote_filename, local_dir
46
+ remote_contents = on(hosts.last, "cat #{remote_filename}").stdout
47
+
48
+ local_filename = File.join(local_dir, "testfile.txt")
49
+ local_contents = File.read(local_filename)
50
+ assert_equal remote_contents, local_contents
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,54 @@
1
+ require "helpers/test_helper"
2
+
3
+ test_name "dsl::helpers::host_helpers #scp_to" do
4
+ step "#scp_to fails if the local file cannot be found" do
5
+ remote_tmpdir = tmpdir_on default
6
+ assert_raises IOError do
7
+ scp_to default, "/non/existent/file.txt", remote_tmpdir
8
+ end
9
+ end
10
+
11
+ if test_scp_error_on_close?
12
+ step "#scp_to fails if the remote path cannot be found" do
13
+ Dir.mktmpdir do |local_dir|
14
+ local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
15
+
16
+ # assert_raises Beaker::Host::CommandFailure do
17
+ assert_raises RuntimeError do
18
+ scp_to default, local_filename, "/non/existent/remote/file.txt"
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ step "#scp_to creates the file on the remote system" do
25
+ Dir.mktmpdir do |local_dir|
26
+ local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
27
+ remote_tmpdir = tmpdir_on default
28
+
29
+ scp_to default, local_filename, remote_tmpdir
30
+
31
+ remote_filename = File.join(remote_tmpdir, "testfile.txt")
32
+ remote_contents = on(default, "cat #{remote_filename}").stdout
33
+ assert_equal contents, remote_contents
34
+ end
35
+ end
36
+
37
+ step "#scp_to creates the file on all remote systems when a host array is provided" do
38
+ Dir.mktmpdir do |local_dir|
39
+ local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
40
+
41
+ remote_tmpdir = tmpdir_on default
42
+ on hosts, "mkdir -p #{remote_tmpdir}"
43
+ remote_filename = File.join(remote_tmpdir, "testfile.txt")
44
+
45
+ scp_to hosts, local_filename, remote_tmpdir
46
+
47
+ hosts.each do |host|
48
+ remote_contents = on(host, "cat #{remote_filename}").stdout
49
+ assert_equal contents, remote_contents
50
+ end
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,51 @@
1
+ require "helpers/test_helper"
2
+
3
+ test_name "dsl::helpers::host_helpers #shell" do
4
+ step "#shell raises an exception when remote command fails" do
5
+ assert_raises(Beaker::Host::CommandFailure) do
6
+ shell "/bin/nonexistent-command"
7
+ end
8
+ end
9
+
10
+ step "#shell makes command output available via `.stdout` on success" do
11
+ output = shell(%Q{echo "echo via on"}).stdout
12
+ assert_equal "echo via on\n", output
13
+ end
14
+
15
+ step "#shell makes command error output available via `.stderr` on success" do
16
+ output = shell("/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
17
+ assert_match /No such file/, output
18
+ end
19
+
20
+ step "#shell makes exit status available via `.exit_code`" do
21
+ status = shell(%Q{echo "echo via on"}).exit_code
22
+ assert_equal 0, status
23
+ end
24
+
25
+ step "#shell with :acceptable_exit_codes will not fail for named exit codes" do
26
+ result = shell "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
27
+ output = result.stderr
28
+ assert_match /No such file/, output
29
+ status = result.exit_code
30
+ assert_equal 127, status
31
+ end
32
+
33
+ step "#shell with :acceptable_exit_codes will fail for other exit codes" do
34
+ assert_raises(Beaker::Host::CommandFailure) do
35
+ shell %Q{echo "echo via on"}, :acceptable_exit_codes => [127]
36
+ end
37
+ end
38
+
39
+ step "#shell will pass :environment options to the remote host as ENV settings" do
40
+ result = shell "env", { :environment => { 'FOO' => 'bar' } }
41
+ output = result.stdout
42
+
43
+ assert_match /\bFOO=bar\b/, output
44
+ end
45
+
46
+ step "#shell allows assertions to be used in the optional block" do
47
+ shell %Q{echo "${RANDOM}:${RANDOM}"} do
48
+ assert_match /\d+:\d+/, stdout
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,92 @@
1
+ require "helpers/test_helper"
2
+
3
+ test_name "dsl::helpers::host_helpers #upgrade_package" do
4
+ # NOTE: vivid packages are not ready on nightlies.puppetlabs.com,
5
+ # see: https://tickets.puppetlabs.com/browse/CPR-173
6
+ # also: https://tickets.puppetlabs.com/browse/BKR-513
7
+ confine :except, :platform => /ubuntu.*15/
8
+
9
+ # NOTE: there does not appear to be a way to confine just to cygwin hosts
10
+ confine_block :to, :platform => /windows/ do
11
+
12
+ # NOTE: check_for_package on windows currently fails as follows:
13
+ #
14
+ # ArgumentError: wrong number of arguments (3 for 1..2)
15
+ #
16
+ # Would expect this to be documented better, and to fail with Beaker::Host::CommandFailure
17
+
18
+ step "#upgrade_package CURRENTLY fails on windows platforms with a RuntimeError" do
19
+ # NOTE: this is not a supported platform but would expect a Beaker::Host::CommandFailure
20
+ assert_raises RuntimeError do
21
+ upgrade_package default, "bash"
22
+ end
23
+ end
24
+ end
25
+
26
+ confine_block :to, :platform => /osx/ do
27
+
28
+ step "#upgrade_package CURRENTLY fails with a RuntimeError on OS X" do
29
+ # NOTE: documentation could be better on this method
30
+ assert_raises RuntimeError do
31
+ upgrade_package default, "bash"
32
+ end
33
+ end
34
+ end
35
+
36
+ confine_block :to, :platform => /solaris/ do
37
+
38
+ step "#upgrade_package CURRENTLY fails on solaris platforms" do
39
+ # NOTE: pkgutil doesn't appear to be installed by default -- documentation
40
+ # could be better here.
41
+ assert_raises Beaker::Host::CommandFailure do
42
+ upgrade_package default, "bash"
43
+ end
44
+ end
45
+ end
46
+
47
+ confine_block :except, :platform => /windows|solaris|osx/ do
48
+ confine_block :to, :platform => /centos|el-\d/ do
49
+
50
+ step "#upgrade_package CURRENTLY does not fail on CentOS if unknown package is specified" do
51
+ # NOTE: I would expect this to fail with an Beaker::Host::CommandFailure,
52
+ # but maybe it's because yum doesn't really care:
53
+ #
54
+ # > Loaded plugins: fastestmirror
55
+ # > Loading mirror speeds from cached hostfile
56
+ # > Setting up Update Process
57
+ # > No package non-existent-package-name available.
58
+ # > No Packages marked for Update
59
+
60
+ result = upgrade_package default, "non-existent-package-name"
61
+ assert_match /No Packages marked for Update/i, result
62
+ end
63
+ end
64
+
65
+ confine_block :except, :platform => /centos|el-\d/ do
66
+
67
+ step "#upgrade_package fails if package is not already installed" do
68
+ assert_raises Beaker::Host::CommandFailure do
69
+ upgrade_package default, "non-existent-package-name"
70
+ end
71
+ end
72
+ end
73
+
74
+ step "#upgrade_package succeeds if package is installed" do
75
+ # TODO: anyone have any bright ideas on how to portably install an old
76
+ # version of a package, to really test an upgrade?
77
+
78
+ install_package default, "rsync"
79
+ upgrade_package default, "rsync"
80
+ assert check_for_package(default, "rsync"), "package was not successfully installed/upgraded"
81
+ end
82
+
83
+ step "#upgrade_package CURRENTLY fails when given a host array" do
84
+ # NOTE: would expect this to work across hosts, or to be better documented,
85
+ # if not support, should raise Beaker::Host::CommandFailure
86
+
87
+ assert_raises NoMethodError do
88
+ upgrade_package hosts, "rsync"
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,47 @@
1
+ begin
2
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
3
+
4
+ require 'helpers/test_helper'
5
+
6
+ require 'beaker/acceptance/install_utils'
7
+ extend Beaker::Acceptance::InstallUtils
8
+ end
9
+
10
+ test_name 'Clone from git' do
11
+
12
+ PACKAGES = {
13
+ :redhat => [
14
+ 'git',
15
+ ],
16
+ :debian => [
17
+ ['git', 'git-core'],
18
+ ],
19
+ :solaris_11 => [
20
+ ['git', 'developer/versioning/git'],
21
+ ],
22
+ :solaris_10 => [
23
+ 'coreutils',
24
+ 'curl', # update curl to fix "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!" issue
25
+ 'git',
26
+ ],
27
+ :windows => [
28
+ 'git',
29
+ ],
30
+ :sles => [
31
+ 'git-core',
32
+ ]
33
+ }
34
+
35
+ install_packages_on(hosts, PACKAGES, :check_if_exists => true)
36
+
37
+ # implicitly tests build_giturl() and lookup_in_env()
38
+ hosts.each do |host|
39
+ on host, "echo #{GitHubSig} >> $HOME/.ssh/known_hosts"
40
+ testdir = tmpdir_on(host, File.basename(__FILE__))
41
+
42
+ step 'should be able to successfully clone a git repo' do
43
+ results = clone_git_repo_on(host, "#{testdir}", extract_repo_info_from(build_git_url('hiera')))
44
+ assert_match( %r{From.*github\.com[:/]puppetlabs/hiera}, result.output, 'Did not find clone')
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,5 @@
1
+ require "helpers/test_helper"
2
+
1
3
  test_name "confirm host object behave correctly"
2
4
 
3
5
  step "#port_open? : can determine if a port is open on hosts"
@@ -0,0 +1,10 @@
1
+ # Ensure that `$LOAD_PATH` is set up properly, in cases where the entire
2
+ # acceptance suite is being run, but the options file
3
+ # `acceptance/config/acceptance_options.rb` was not specified via the
4
+ # `--options-file` command-line argument.
5
+ begin
6
+ require 'helpers/test_helper'
7
+ rescue LoadError
8
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
9
+ require 'helpers/test_helper'
10
+ end
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  s.add_runtime_dependency 'aws-sdk', '~> 1.57'
53
53
  s.add_runtime_dependency 'docker-api'
54
54
  s.add_runtime_dependency 'fog-google', '~> 0.0.9' # dropped ruby 1.9 support in 0.1
55
- s.add_runtime_dependency 'fog', '~> 1.25'
55
+ s.add_runtime_dependency 'fog', ['~> 1.25', '< 1.35.0']
56
56
 
57
57
  # So fog doesn't always complain of unmet AWS dependencies
58
58
  s.add_runtime_dependency 'unf', '~> 0.1'
@@ -0,0 +1,305 @@
1
+ ## What's Pry?
2
+
3
+ [Pry](http://pryrepl.org/) is a powerful Ruby editing and debugging tool. Beaker uses Pry runtime invocation to create a developer console.
4
+
5
+ ## Set it up!
6
+
7
+ Pry is included in the Beaker 1.13+ development gems and is available by default.
8
+
9
+ Pre-1.13.0 add Pry with `gem install pry`, then add Pry to individual tests by adding `require 'pry'` as the first line in the Ruby test file.
10
+
11
+ ## Invoke the Developer Console
12
+
13
+ In a Beaker test file call `binding.pry` to invoke the console. Place it where you want access to the full, current Beaker environment.
14
+
15
+ ## Example
16
+ ### Example test trypry.rb
17
+ Here's a test file that exercises different ways of running commands on Beaker hosts. At the end of the main `hosts.each` loop I've included `binding.pry` to invoke the console.
18
+
19
+ ```
20
+ hosts.each do |h|
21
+ on h, "echo hello"
22
+ if h['platform'] =~ /windows/
23
+ scp_to h, "beaker.gemspec", "/cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/"
24
+ end
25
+ on(h, "echo test block") do |result|
26
+ puts "block result.stdout: #{result.stdout}"
27
+ puts "block result.raw_stdout: #{result.raw_stdout}"
28
+ end
29
+ on(h, "echo test block, built in functions") do
30
+ puts "built in function stdout: #{stdout}"
31
+ puts "built in function stderr: #{stderr}"
32
+ end
33
+
34
+ result = on(h, "echo no block")
35
+ puts "return var result.stdout: #{result.stdout}"
36
+ puts "return var result.raw_stdout: #{result.raw_stdout}"
37
+
38
+ binding.pry
39
+
40
+ end
41
+ ```
42
+
43
+ ### Sample output to the first `binding.pry` call:
44
+ ```
45
+ $ bundle exec beaker --debug --tests tests/trypry.rb --hosts configs/fusion/winfusion.cfg --no-provi
46
+ sion
47
+ {
48
+ "project": "Beaker",
49
+ "department": "anode",
50
+ "validate": true,
51
+ "jenkins_build_url": null,
52
+ "forge_host": "vulcan-acceptance.delivery.puppetlabs.net",
53
+ "log_level": "debug",
54
+ "trace_limit": 10,
55
+ "hosts_file": "configs/fusion/winfusion.cfg",
56
+ "options_file": null,
57
+ "type": "pe",
58
+ "provision": false,
59
+ "preserve_hosts": "never",
60
+ "root_keys": false,
61
+ "quiet": false,
62
+ "xml": false,
63
+ "color": true,
64
+ "dry_run": false,
65
+ "timeout": 300,
66
+ "fail_mode": "slow",
67
+ "timesync": false,
68
+ "repo_proxy": false,
69
+ "add_el_extras": false,
70
+ "add_master_entry": false,
71
+ "consoleport": 443,
72
+ "pe_dir": "http://neptune.puppetlabs.lan/3.2/ci-ready/",
73
+ "pe_version_file": "LATEST",
74
+ "pe_version_file_win": "LATEST-win",
75
+ "dot_fog": "/Users/anode/.fog",
76
+ "ec2_yaml": "config/image_templates/ec2.yaml",
77
+ "help": false,
78
+ "ssh": {
79
+ "config": false,
80
+ "paranoid": false,
81
+ "timeout": 300,
82
+ "auth_methods": [
83
+ "publickey"
84
+ ],
85
+ "port": 22,
86
+ "forward_agent": true,
87
+ "keys": [
88
+ "/Users/anode/.ssh/id_rsa"
89
+ ],
90
+ "user_known_hosts_file": "/Users/anode/.ssh/known_hosts"
91
+ },
92
+ "tests": [
93
+ "tests/trypry.rb"
94
+ ],
95
+ "command_line": "/Users/anode/beaker/.bundle/gems/bin/beaker --debug --tests tests/trypry.rb --hosts configs/fusion/winfusion.cfg --no-provision",
96
+ "HOSTS": {
97
+ "pe-centos6": {
98
+ "roles": [
99
+ "master",
100
+ "agent",
101
+ "dashboard",
102
+ "database"
103
+ ],
104
+ "platform": "el-6-i386",
105
+ "snapshot": "clean-w-keys",
106
+ "hypervisor": "fusion"
107
+ },
108
+ "w2k8r2": {
109
+ "roles": [
110
+ "agent"
111
+ ],
112
+ "platform": "windows-2008r2-x86_64",
113
+ "snapshot": "clean-w-keys",
114
+ "hypervisor": "fusion"
115
+ },
116
+ "w2k3r2": {
117
+ "roles": [
118
+ "agent"
119
+ ],
120
+ "platform": "windows-2003r2-x86_64",
121
+ "hypervisor": "fusion",
122
+ "snapshot": "clean-w-keys"
123
+ }
124
+ },
125
+ "nfs_server": "none",
126
+ "pe_ver": "3.2.2-6-gd1cae98",
127
+ "home": "/Users/anode",
128
+ "answers": {
129
+ "q_puppet_enterpriseconsole_auth_user_email": "admin@example.com",
130
+ "q_puppet_enterpriseconsole_auth_password": "~!@#$%^*-/ aZ",
131
+ "q_puppet_enterpriseconsole_smtp_host": null,
132
+ "q_puppet_enterpriseconsole_smtp_port": 25,
133
+ "q_puppet_enterpriseconsole_smtp_username": null,
134
+ "q_puppet_enterpriseconsole_smtp_password": null,
135
+ "q_puppet_enterpriseconsole_smtp_use_tls": "n",
136
+ "q_verify_packages": "y",
137
+ "q_puppetdb_password": "~!@#$%^*-/ aZ"
138
+ },
139
+ "helper": [],
140
+ "load_path": [],
141
+ "pre_suite": [],
142
+ "post_suite": [],
143
+ "install": [],
144
+ "modules": [],
145
+ "logger": "#<Beaker::Logger:0x007f925a6b4218>"
146
+ }
147
+ Hypervisor for pe-centos6 is none
148
+ Hypervisor for w2k8r2 is none
149
+ Hypervisor for w2k3r2 is none
150
+ Beaker::Hypervisor, found some none boxes to create
151
+
152
+ pe-centos6 10:55:27$ which curl
153
+ /usr/bin/curl
154
+
155
+ pe-centos6 executed in 0.14 seconds
156
+
157
+ pe-centos6 10:55:27$ which ntpdate
158
+ /usr/sbin/ntpdate
159
+
160
+ pe-centos6 executed in 0.01 seconds
161
+
162
+ w2k8r2 10:55:27$ which curl
163
+ /bin/curl
164
+
165
+ w2k8r2 executed in 0.42 seconds
166
+
167
+ w2k3r2 10:55:27$ which curl
168
+ /bin/curl
169
+
170
+ w2k3r2 executed in 0.29 seconds
171
+ No tests to run for suite 'pre_suite'
172
+ Begin tests/trypry.rb
173
+
174
+ pe-centos6 10:55:28$ echo hello
175
+ hello
176
+
177
+ pe-centos6 executed in 0.01 seconds
178
+
179
+ pe-centos6 10:55:28$ echo test block
180
+ test block
181
+
182
+ pe-centos6 executed in 0.01 seconds
183
+ block result.stdout: test block
184
+ block result.raw_stdout: test block
185
+
186
+ pe-centos6 10:55:28$ echo test block, built in functions
187
+ test block, built in functions
188
+
189
+ pe-centos6 executed in 0.00 seconds
190
+ built in function stdout: test block, built in functions
191
+ built in function stderr:
192
+
193
+ pe-centos6 10:55:28$ echo no block
194
+ no block
195
+
196
+ pe-centos6 executed in 0.00 seconds
197
+ return var result.stdout: no block
198
+ return var result.raw_stdout: no block
199
+
200
+ From: /Users/anode/beaker/tests/trypry.rb @ line 19 self.run_test:
201
+
202
+ 14:
203
+ 15: result = on(h, "echo no block")
204
+ 16: puts "return var result.stdout: #{result.stdout}"
205
+ 17: puts "return var result.raw_stdout: #{result.raw_stdout}"
206
+ 18:
207
+ => 19: binding.pry
208
+ 20:
209
+ 21: end
210
+
211
+ [1] pry(#<Beaker::TestCase>)>
212
+ ```
213
+ ### Using the console
214
+ At this point I have access to the console. I have full access to Beaker hosts, the Beaker DSL and Ruby.
215
+
216
+ Here's some sample console calls:
217
+ ```
218
+ [1] pry(#<Beaker::TestCase>)> hosts
219
+ => [pe-centos6, w2k8r2, w2k3r2]
220
+ [2] pry(#<Beaker::TestCase>)> on hosts[1], 'echo hello'
221
+
222
+ w2k8r2 10:54:11$ echo hello
223
+ hello
224
+
225
+ w2k8r2 executed in 0.07 seconds
226
+ => #<Beaker::Result:0x007f9f6b7a3408
227
+ @cmd=" echo hello ",
228
+ @exit_code=0,
229
+ @host="w2k8r2",
230
+ @output="hello\n",
231
+ @raw_output="hello\n",
232
+ @raw_stderr="",
233
+ @raw_stdout="hello\n",
234
+ @stderr="",
235
+ @stdout="hello\n">
236
+ [3] pry(#<Beaker::TestCase>)> on hosts[1], 'ls /cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/'
237
+
238
+ w2k8r2 10:56:15$ ls /cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/
239
+ Application Data
240
+ Desktop
241
+ Documents
242
+ Favorites
243
+ Microsoft
244
+ Package Cache
245
+ Start Menu
246
+ Templates
247
+ VMware
248
+ beaker.gemspec
249
+ ntuser.pol
250
+
251
+ w2k8r2 executed in 0.09 seconds
252
+ => #<Beaker::Result:0x007f925b227898
253
+ @cmd=
254
+ " ls /cygdrive/c/Documents\\ and\\ Settings/All\\ Users/Application\\ Data/ ",
255
+ @exit_code=0,
256
+ @host="w2k8r2",
257
+ @output=
258
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n",
259
+ @raw_output=
260
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n",
261
+ @raw_stderr="",
262
+ @raw_stdout=
263
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n",
264
+ @stderr="",
265
+ @stdout=
266
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n">
267
+ [4] pry(#<Beaker::TestCase>)> result = on hosts[1], 'ls /cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/'
268
+
269
+ w2k8r2 10:56:34$ ls /cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/
270
+ Application Data
271
+ Desktop
272
+ Documents
273
+ Favorites
274
+ Microsoft
275
+ Package Cache
276
+ Start Menu
277
+ Templates
278
+ VMware
279
+ beaker.gemspec
280
+ ntuser.pol
281
+
282
+ w2k8r2 executed in 0.08 seconds
283
+ => #<Beaker::Result:0x007f925a387018
284
+ @cmd=
285
+ " ls /cygdrive/c/Documents\\ and\\ Settings/All\\ Users/Application\\ Data/ ",
286
+ @exit_code=0,
287
+ @host="w2k8r2",
288
+ @output=
289
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n",
290
+ @raw_output=
291
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n",
292
+ @raw_stderr="",
293
+ @raw_stdout=
294
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n",
295
+ @stderr="",
296
+ @stdout=
297
+ "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol\n">
298
+ [5] pry(#<Beaker::TestCase>)> result.stdout.chomp
299
+ => "Application Data\nDesktop\nDocuments\nFavorites\nMicrosoft\nPackage Cache\nStart Menu\nTemplates\nVMware\nbeaker.gemspec\nntuser.pol"
300
+ ```
301
+ ### Continue regular test execution
302
+ Simply `exit` the console.
303
+ ```
304
+ [6] pry(#<Beaker::TestCase>)> exit
305
+ ```