beaker 4.42.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +26 -13
  5. data/.rubocop.yml +23 -10
  6. data/.rubocop_todo.yml +34 -10
  7. data/CHANGELOG.md +16 -61
  8. data/Gemfile +12 -7
  9. data/HISTORY.md +605 -0
  10. data/Rakefile +99 -111
  11. data/acceptance/config/acceptance-options.rb +1 -1
  12. data/acceptance/config/base/acceptance-options.rb +2 -2
  13. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  14. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  15. data/acceptance/fixtures/module/Rakefile +1 -1
  16. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  17. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  18. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  19. data/acceptance/lib/helpers/test_helper.rb +6 -5
  20. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  21. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  22. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  23. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  41. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  42. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  43. data/acceptance/tests/base/host/file_test.rb +2 -2
  44. data/acceptance/tests/base/host/group_test.rb +0 -1
  45. data/acceptance/tests/base/host/host_test.rb +66 -63
  46. data/acceptance/tests/base/host/packages.rb +1 -2
  47. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  48. data/acceptance/tests/base/host/user_test.rb +0 -1
  49. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  50. data/acceptance/tests/base/test_suite/export.rb +6 -9
  51. data/acceptance/tests/install/from_file.rb +2 -4
  52. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  53. data/acceptance/tests/subcommands/destroy.rb +19 -21
  54. data/acceptance/tests/subcommands/exec.rb +0 -1
  55. data/acceptance/tests/subcommands/init.rb +2 -3
  56. data/acceptance/tests/subcommands/provision.rb +0 -1
  57. data/beaker.gemspec +4 -7
  58. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  59. data/docs/how_to/debug_beaker_tests.md +12 -12
  60. data/docs/how_to/hosts/eos.md +2 -12
  61. data/docs/how_to/install_puppet.md +0 -18
  62. data/docs/how_to/the_beaker_dsl.md +0 -2
  63. data/lib/beaker/cli.rb +59 -68
  64. data/lib/beaker/command.rb +20 -28
  65. data/lib/beaker/command_factory.rb +3 -2
  66. data/lib/beaker/dsl/assertions.rb +6 -18
  67. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  68. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  69. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  70. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  71. data/lib/beaker/dsl/helpers.rb +2 -4
  72. data/lib/beaker/dsl/outcomes.rb +13 -15
  73. data/lib/beaker/dsl/patterns.rb +1 -3
  74. data/lib/beaker/dsl/roles.rb +17 -20
  75. data/lib/beaker/dsl/structure.rb +53 -65
  76. data/lib/beaker/dsl/test_tagging.rb +7 -10
  77. data/lib/beaker/dsl/wrappers.rb +15 -16
  78. data/lib/beaker/dsl.rb +2 -3
  79. data/lib/beaker/host/aix/exec.rb +1 -1
  80. data/lib/beaker/host/aix/file.rb +0 -1
  81. data/lib/beaker/host/aix/group.rb +1 -1
  82. data/lib/beaker/host/aix/user.rb +1 -1
  83. data/lib/beaker/host/aix.rb +3 -4
  84. data/lib/beaker/host/cisco.rb +27 -39
  85. data/lib/beaker/host/eos.rb +4 -30
  86. data/lib/beaker/host/freebsd/exec.rb +1 -1
  87. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  88. data/lib/beaker/host/freebsd.rb +9 -12
  89. data/lib/beaker/host/mac/exec.rb +4 -4
  90. data/lib/beaker/host/mac/group.rb +7 -7
  91. data/lib/beaker/host/mac/pkg.rb +3 -106
  92. data/lib/beaker/host/mac/user.rb +2 -2
  93. data/lib/beaker/host/mac.rb +8 -9
  94. data/lib/beaker/host/pswindows/exec.rb +66 -70
  95. data/lib/beaker/host/pswindows/file.rb +3 -5
  96. data/lib/beaker/host/pswindows/group.rb +3 -3
  97. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  98. data/lib/beaker/host/pswindows/user.rb +3 -3
  99. data/lib/beaker/host/pswindows.rb +4 -3
  100. data/lib/beaker/host/unix/exec.rb +81 -83
  101. data/lib/beaker/host/unix/file.rb +41 -46
  102. data/lib/beaker/host/unix/group.rb +1 -1
  103. data/lib/beaker/host/unix/pkg.rb +138 -401
  104. data/lib/beaker/host/unix/user.rb +2 -2
  105. data/lib/beaker/host/unix.rb +8 -11
  106. data/lib/beaker/host/windows/exec.rb +17 -17
  107. data/lib/beaker/host/windows/file.rb +3 -3
  108. data/lib/beaker/host/windows/group.rb +3 -3
  109. data/lib/beaker/host/windows/pkg.rb +3 -54
  110. data/lib/beaker/host/windows/user.rb +3 -3
  111. data/lib/beaker/host/windows.rb +12 -12
  112. data/lib/beaker/host.rb +76 -133
  113. data/lib/beaker/host_prebuilt_steps.rb +88 -196
  114. data/lib/beaker/hypervisor/noop.rb +2 -4
  115. data/lib/beaker/hypervisor.rb +44 -61
  116. data/lib/beaker/local_connection.rb +2 -4
  117. data/lib/beaker/logger.rb +68 -76
  118. data/lib/beaker/logger_junit.rb +21 -25
  119. data/lib/beaker/network_manager.rb +39 -42
  120. data/lib/beaker/options/command_line_parser.rb +12 -23
  121. data/lib/beaker/options/hosts_file_parser.rb +16 -25
  122. data/lib/beaker/options/options_file_parser.rb +3 -6
  123. data/lib/beaker/options/options_hash.rb +2 -7
  124. data/lib/beaker/options/parser.rb +86 -102
  125. data/lib/beaker/options/presets.rb +114 -123
  126. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  127. data/lib/beaker/options/validator.rb +26 -31
  128. data/lib/beaker/perf.rb +25 -30
  129. data/lib/beaker/platform.rb +27 -39
  130. data/lib/beaker/result.rb +7 -6
  131. data/lib/beaker/shared/error_handler.rb +8 -10
  132. data/lib/beaker/shared/fog_credentials.rb +5 -9
  133. data/lib/beaker/shared/host_manager.rb +36 -41
  134. data/lib/beaker/shared/options_resolver.rb +3 -7
  135. data/lib/beaker/shared/repetition.rb +2 -4
  136. data/lib/beaker/shared/semvar.rb +37 -41
  137. data/lib/beaker/shared/timed.rb +0 -3
  138. data/lib/beaker/shared.rb +1 -1
  139. data/lib/beaker/ssh_connection.rb +38 -47
  140. data/lib/beaker/subcommand.rb +17 -24
  141. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  142. data/lib/beaker/tasks/quick_start.rb +4 -9
  143. data/lib/beaker/tasks/rake_task.rb +25 -27
  144. data/lib/beaker/tasks/test.rb +4 -4
  145. data/lib/beaker/test_case.rb +16 -28
  146. data/lib/beaker/test_suite.rb +35 -39
  147. data/lib/beaker/test_suite_result.rb +45 -47
  148. data/lib/beaker/version.rb +1 -1
  149. data/lib/beaker.rb +6 -7
  150. data/spec/beaker/cli_spec.rb +121 -142
  151. data/spec/beaker/command_spec.rb +55 -59
  152. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  153. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  154. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  155. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  156. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  157. data/spec/beaker/dsl/roles_spec.rb +125 -130
  158. data/spec/beaker/dsl/structure_spec.rb +172 -161
  159. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  160. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  161. data/spec/beaker/host/aix_spec.rb +14 -14
  162. data/spec/beaker/host/cisco_spec.rb +84 -94
  163. data/spec/beaker/host/eos_spec.rb +15 -36
  164. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  165. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  166. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  167. data/spec/beaker/host/mac/group_spec.rb +48 -57
  168. data/spec/beaker/host/mac/user_spec.rb +54 -63
  169. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  170. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  171. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  172. data/spec/beaker/host/pswindows_spec.rb +13 -13
  173. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  174. data/spec/beaker/host/unix/file_spec.rb +65 -78
  175. data/spec/beaker/host/unix/pkg_spec.rb +150 -411
  176. data/spec/beaker/host/unix_spec.rb +11 -207
  177. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  178. data/spec/beaker/host/windows/file_spec.rb +18 -19
  179. data/spec/beaker/host/windows/group_spec.rb +10 -12
  180. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  181. data/spec/beaker/host/windows/user_spec.rb +17 -23
  182. data/spec/beaker/host/windows_spec.rb +39 -39
  183. data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
  184. data/spec/beaker/host_spec.rb +204 -284
  185. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  186. data/spec/beaker/localhost_connection_spec.rb +10 -11
  187. data/spec/beaker/logger_junit_spec.rb +19 -30
  188. data/spec/beaker/logger_spec.rb +153 -136
  189. data/spec/beaker/network_manager_spec.rb +23 -23
  190. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  191. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  192. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  193. data/spec/beaker/options/options_hash_spec.rb +4 -6
  194. data/spec/beaker/options/parser_spec.rb +167 -167
  195. data/spec/beaker/options/presets_spec.rb +7 -9
  196. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  197. data/spec/beaker/options/validator_spec.rb +10 -11
  198. data/spec/beaker/perf_spec.rb +18 -21
  199. data/spec/beaker/platform_spec.rb +25 -55
  200. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  201. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  202. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  203. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  204. data/spec/beaker/shared/repetition_spec.rb +17 -24
  205. data/spec/beaker/shared/semvar_spec.rb +21 -26
  206. data/spec/beaker/ssh_connection_spec.rb +76 -83
  207. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  208. data/spec/beaker/subcommand_spec.rb +75 -77
  209. data/spec/beaker/test_case_spec.rb +25 -50
  210. data/spec/beaker/test_suite_spec.rb +147 -154
  211. data/spec/helpers.rb +39 -45
  212. data/spec/matchers.rb +8 -7
  213. data/spec/mocks.rb +1 -6
  214. data/spec/spec_helper.rb +0 -1
  215. metadata +8 -24
  216. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  217. data/acceptance/tests/base/external_resources_test.rb +0 -31
  218. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -1,5 +1,4 @@
1
1
  test_name 'use the destroy subcommand' do
2
-
3
2
  def delete_root_folder_contents
4
3
  on default, 'rm -rf /root/* /root/.beaker'
5
4
  end
@@ -24,26 +23,25 @@ test_name 'use the destroy subcommand' do
24
23
  end
25
24
 
26
25
  step 'ensure that `beaker destroy` destroys vmpooler configuration' do
27
- delete_root_folder_contents
28
- result = on(default, "beaker init --hosts centos6-64")
29
- assert_match(/Writing configured options to disk/, result.stdout)
30
- assert_equal(0, result.exit_code, "`beaker init` should return a zero exit code")
31
- step 'ensure destroy fails to run against an unprovisioned environment' do
32
- result = on(default, "beaker destroy", :accept_all_exit_codes => true)
33
- assert_match(/Please provision an environment/, result.stdout)
34
- assert_equal(1, result.exit_code, "`beaker destroy` should return a non zero exit code")
35
- end
36
- step 'ensure provision provisions, validates, and configures new hosts' do
37
- result = on(default, "beaker provision")
38
- assert_match(/Using available host/, result.stdout)
39
- assert_equal(0, result.exit_code, "`beaker provision` should return a zero exit code")
40
- end
41
- step 'ensure destroy will destroy a provisioned environment' do
42
- result = on(default, 'beaker destroy')
43
- assert_match(/Handing/, result.stdout)
44
- assert_equal(0, result.exit_code, "`beaker destroy` should return a zero exit code")
45
- end
26
+ delete_root_folder_contents
27
+ result = on(default, "beaker init --hosts centos6-64")
28
+ assert_match(/Writing configured options to disk/, result.stdout)
29
+ assert_equal(0, result.exit_code, "`beaker init` should return a zero exit code")
30
+ step 'ensure destroy fails to run against an unprovisioned environment' do
31
+ result = on(default, "beaker destroy", :accept_all_exit_codes => true)
32
+ assert_match(/Please provision an environment/, result.stdout)
33
+ assert_equal(1, result.exit_code, "`beaker destroy` should return a non zero exit code")
34
+ end
35
+ step 'ensure provision provisions, validates, and configures new hosts' do
36
+ result = on(default, "beaker provision")
37
+ assert_match(/Using available host/, result.stdout)
38
+ assert_equal(0, result.exit_code, "`beaker provision` should return a zero exit code")
39
+ end
40
+ step 'ensure destroy will destroy a provisioned environment' do
41
+ result = on(default, 'beaker destroy')
42
+ assert_match(/Handing/, result.stdout)
43
+ assert_equal(0, result.exit_code, "`beaker destroy` should return a zero exit code")
44
+ end
46
45
  delete_root_folder_contents
47
46
  end
48
-
49
47
  end
@@ -1,5 +1,4 @@
1
1
  test_name 'use the exec subcommand' do
2
-
3
2
  def delete_root_folder_contents
4
3
  on default, 'rm -rf /root/* /root/.beaker'
5
4
  end
@@ -1,5 +1,4 @@
1
1
  test_name 'use the init subcommand' do
2
-
3
2
  SubcommandUtil = Beaker::Subcommands::SubcommandUtil
4
3
  def delete_root_folder_contents
5
4
  on default, 'rm -rf /root/* /root/.beaker'
@@ -17,8 +16,8 @@ test_name 'use the init subcommand' do
17
16
  subcommand_state = on(default, "cat #{SubcommandUtil::SUBCOMMAND_STATE}").stdout
18
17
  parsed_options = YAML.parse(subcommand_options).to_ruby
19
18
  assert(parsed_options["HOSTS"].count == 1)
20
- assert(parsed_options.class == Hash)
21
- assert(YAML.parse(subcommand_state).to_ruby.class == Hash)
19
+ assert(parsed_options.instance_of?(Hash))
20
+ assert(YAML.parse(subcommand_state).to_ruby.instance_of?(Hash))
22
21
  end
23
22
 
24
23
  step 'ensure beaker init saves beaker-run arguments to the subcommand_options.yaml' do
@@ -1,5 +1,4 @@
1
1
  test_name 'use the provision subcommand' do
2
-
3
2
  SubcommandUtil = Beaker::Subcommands::SubcommandUtil
4
3
 
5
4
  def delete_root_folder_contents
data/beaker.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'beaker/version'
@@ -14,17 +13,15 @@ Gem::Specification.new do |s|
14
13
  s.license = 'Apache-2.0'
15
14
 
16
15
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
17
  s.require_paths = ["lib"]
20
18
 
21
- s.required_ruby_version = Gem::Requirement.new('>= 2.4')
19
+ s.required_ruby_version = Gem::Requirement.new('>= 2.7')
22
20
 
23
21
  # Testing dependencies
24
- s.add_development_dependency 'fakefs', '~> 1.0'
22
+ s.add_development_dependency 'fakefs', '~> 2.4'
25
23
  s.add_development_dependency 'rake', '~> 13.0'
26
24
  s.add_development_dependency 'rspec', '~> 3.0'
27
- s.add_development_dependency 'rspec-its'
28
25
 
29
26
  # Documentation dependencies
30
27
  s.add_development_dependency 'yard', '~> 0.9.11'
@@ -40,7 +37,7 @@ Gem::Specification.new do |s|
40
37
  s.add_runtime_dependency 'net-scp', '>= 1.2', '< 5.0'
41
38
  s.add_runtime_dependency 'net-ssh', '>= 5.0'
42
39
 
43
- s.add_runtime_dependency 'in-parallel', '>= 0.1', '< 2'
40
+ s.add_runtime_dependency 'in-parallel', '>= 0.1', '< 2.0'
44
41
  s.add_runtime_dependency 'rsync', '~> 1.0.9'
45
42
  s.add_runtime_dependency 'thor', ['>= 1.0.1', '< 2.0']
46
43
 
@@ -149,8 +149,6 @@ Usage: beaker [options...]
149
149
  (default: false)
150
150
  --repo-proxy Proxy packaging repositories on ubuntu, debian, cumulus and solaris-11
151
151
  (default: false)
152
- --add-el-extras Add Extra Packages for Enterprise Linux (EPEL) repository to el-* hosts
153
- (default: false)
154
152
  --package-proxy URL Set proxy url for package managers (yum and apt)
155
153
  --[no-]validate Validate that SUTs are correctly provisioned before running tests
156
154
  (default: true)
@@ -217,7 +215,7 @@ Values already included in Beaker as defaults for required arguments.
217
215
  :preserve_hosts => 'never',
218
216
  :root_keys => false,
219
217
  :quiet => false,
220
- :project_root => File.expand_path(File.join(File.dirname(__FILE__), "../")),
218
+ :project_root => File.expand_path(File.join(__dir__, "../")),
221
219
  :xml_dir => 'junit',
222
220
  :xml_file => 'beaker_junit.xml',
223
221
  :xml_time => 'beaker_times.xml',
@@ -234,17 +232,10 @@ Values already included in Beaker as defaults for required arguments.
234
232
  :fail_mode => 'slow',
235
233
  :accept_all_exit_codes => false,
236
234
  :timesync => false,
237
- :disable_iptables => false,
238
235
  :set_env => true,
239
236
  :disable_updates => true,
240
237
  :repo_proxy => false,
241
238
  :package_proxy => false,
242
- :add_el_extras => false,
243
- :epel_url => "http://mirrors.kernel.org/fedora-epel",
244
- :epel_arch => "i386",
245
- :epel_7_pkg => "epel-release-7-6.noarch.rpm",
246
- :epel_6_pkg => "epel-release-6-8.noarch.rpm",
247
- :epel_5_pkg => "epel-release-5-4.noarch.rpm",
248
239
  :consoleport => 443,
249
240
  :pe_dir => '/opt/enterprise/dists',
250
241
  :pe_version_file => 'LATEST',
@@ -267,18 +267,18 @@ Now try `beaker run -t test.rb --debug-errors` This will enter a pry or debug co
267
267
  39: logger.notify "\n* #{step_name}\n"
268
268
  40: set_current_step_name(step_name)
269
269
  41: if block_given?
270
- 42: logger.step_in()
271
- 43: begin
272
- 44: yield
273
- 45: rescue Exception => e
274
- 46: if(@options.has_key?(:debug_errors) && @options[:debug_errors] == true)
275
- 47: logger.info("Exception raised during step execution and debug-errors option is set, entering pry. Exception was: #{e.inspect}")
276
- 48: logger.info("HINT: Use the pry 'backtrace' and 'up' commands to navigate to the test code")
277
- 49: binding.pry
278
- 50: end
279
- => 51: raise e
280
- 52: end
281
- 53: logger.step_out()
270
+ 42: logger.with_indent do
271
+ 43: begin
272
+ 44: yield
273
+ 45: rescue Exception => e
274
+ 46: if(@options.has_key?(:debug_errors) && @options[:debug_errors] == true)
275
+ 47: logger.info("Exception raised during step execution and debug-errors option is set, entering pry. Exception was: #{e.inspect}")
276
+ 48: logger.info("HINT: Use the pry 'backtrace' and 'up' commands to navigate to the test code")
277
+ 49: binding.pry
278
+ 50: end
279
+ => 51: raise e
280
+ 52: end
281
+ 53: end
282
282
  54: end
283
283
  55: end
284
284
 
@@ -2,20 +2,10 @@
2
2
 
3
3
  EOS is the network device OS from Arista. You can get more details from their [product page](https://www.arista.com/en/products/eos).
4
4
 
5
+ It reaches out to the EOS-specific host code for any information that it needs. You can check out [these methods](blob/master/lib/beaker/host/eos.rb) if you need more information about this.
6
+
5
7
  # Hypervisors
6
8
 
7
9
  EOS has only been developed and tested as a [vmpooler](https://github.com/puppetlabs/vmpooler) host.
8
10
 
9
11
  This doesn't mean that it can't be used in another hypervisor, but that Beaker doesn't specifically deal with the details of that hypervisor in creating EOS hosts, if there is anything specific to EOS that will need to be done in provisioning steps.
10
-
11
- # Installation Methods
12
-
13
- ## Puppet Enterprise
14
-
15
- `install_pe` should "just work".
16
-
17
- ## Open Source
18
-
19
- In order to install a puppet-agent against an EOS host, you'll have to use the [`install_puppet_agent_dev_repo_on`](blob/master/lib/beaker/dsl/install_utils/foss_utils.rb#L1085) method.
20
-
21
- It reaches out to the EOS-specific host code for any information that it needs. You can check out [these methods](blob/master/lib/beaker/host/eos.rb) if you need more information about this.
@@ -35,21 +35,3 @@ For our different Open Source variants, check out the sections just below, which
35
35
  ### Released Open Source Puppet Agents
36
36
 
37
37
  To install a released version of Puppet Agent, beaker provides the [`install_puppet_agent_on`](http://www.rubydoc.info/gems/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_agent_on-instance_method) method. Please checkout the Rubydocs for more info on this method.
38
-
39
- ### Development Open Source Puppet Agents
40
-
41
- To install a development build of Puppet Agent, beaker provides the [`install_puppet_agent_dev_repo_on`](http://www.rubydoc.info/gems/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_agent_dev_repo_on-instance_method) method. Please checkout the Rubydocs for more info on this method.
42
-
43
- ### PE Promoted Agent Installs
44
-
45
- If you're using this method, then you're going to be downloading the installer from a URL configured like so:
46
-
47
- ```ruby
48
- http://pm.puppetlabs.com/puppet-agent/#{ pe_version }/#{ puppet_agent_version }/repos
49
- ```
50
-
51
- `pe_version` is a variable that you can provide using either the host or global property `:pe_ver`. This is usually done in the hosts file, and will default to `4.0.0-rc1` if nothing is specified.
52
-
53
- `puppet_agent_version` is a variable you can provide the value of through the same methods as `pe_version` above. It will default to `latest`.
54
-
55
- Beaker's DSL method to install from this location is [`install_puppet_agent_pe_promoted_repo_on`](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_agent_pe_promoted_repo_on-instance_method). Follow the link to get API-level docs on this method for more info.
@@ -24,7 +24,6 @@ To be used for confirming the result of a test is as expected. Beaker include a
24
24
 
25
25
  * [Minitest assertions](http://docs.seattlerb.org/minitest/Minitest/Assertions.html)
26
26
  * [assert_output](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Assertions#assert_output-instance_method)
27
- * [assert_no_match](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Assertions#assert_no_match-instance_method)
28
27
 
29
28
  ## Helpers
30
29
 
@@ -42,7 +41,6 @@ DSL methods for host manipulation.
42
41
  * [scp_from](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#scp_from-instance_method)
43
42
  * [scp_to](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#scp_to-instance_method)
44
43
  * [rsync_to](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#rsync_to-instance_method)
45
- * [deploy_package_repo](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#deploy_package_repo-instance_method)
46
44
  * [create_remote_file](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#create_remote_file-instance_method)
47
45
  * [run_script_on](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#run_script_on-instance_method)
48
46
  * [run_script](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Helpers/HostHelpers#run_script-instance_method)
data/lib/beaker/cli.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  module Beaker
2
2
  class CLI
3
- VERSION_STRING =
4
- " wWWWw
3
+ VERSION_STRING = <<-'ART'
4
+ wWWWw
5
5
  |o o|
6
6
  | O | %s!
7
- |(\")|
8
- / \\X/ \\
7
+ |(")|
8
+ / \X/ \
9
9
  | V |
10
- | | | "
10
+ | | |
11
+ ART
11
12
 
12
13
  attr_reader :logger, :options, :network_manager
14
+
13
15
  def initialize
14
16
  @timestamp = Time.now
15
17
  # Initialize a logger object prior to parsing; this should be overwritten whence
@@ -44,7 +46,7 @@ module Beaker
44
46
  exit(0)
45
47
  end
46
48
 
47
- #add additional paths to the LOAD_PATH
49
+ # add additional paths to the LOAD_PATH
48
50
  if not @options[:load_path].empty?
49
51
  @options[:load_path].each do |path|
50
52
  $LOAD_PATH << File.expand_path(path)
@@ -67,7 +69,7 @@ module Beaker
67
69
  # Provision, validate and configure all hosts as defined in the hosts file
68
70
  def provision
69
71
  begin
70
- @hosts = []
72
+ @hosts = []
71
73
  initialize_network_manager
72
74
  @network_manager.proxy_package_manager
73
75
  @network_manager.validate
@@ -78,7 +80,7 @@ module Beaker
78
80
  self
79
81
  end
80
82
 
81
- #Initialize the network manager so it can initialize hosts for testing for subcommands
83
+ # Initialize the network manager so it can initialize hosts for testing for subcommands
82
84
  def initialize_network_manager
83
85
  begin
84
86
  @network_manager = Beaker::NetworkManager.new(@options, @logger)
@@ -104,31 +106,29 @@ module Beaker
104
106
  end
105
107
 
106
108
  # Setup perf monitoring if needed
107
- if /(aggressive)|(normal)/.match?(@options[:collect_perf_data].to_s)
108
- @perf = Beaker::Perf.new( @hosts, @options )
109
- end
109
+ @perf = Beaker::Perf.new(@hosts, @options) if /(aggressive)|(normal)/.match?(@options[:collect_perf_data].to_s)
110
110
 
111
- #pre acceptance phase
111
+ # pre acceptance phase
112
112
  run_suite(:pre_suite, :fast)
113
113
 
114
- #testing phase
114
+ # testing phase
115
115
  begin
116
116
  run_suite(:tests, @options[:fail_mode])
117
- #post acceptance phase
117
+ # post acceptance phase
118
118
  rescue => e
119
- #post acceptance on failure
120
- #run post-suite if we are in fail-slow mode
119
+ # post acceptance on failure
120
+ # run post-suite if we are in fail-slow mode
121
121
  if @options[:fail_mode].to_s.include?('slow')
122
122
  run_suite(:post_suite)
123
123
  @perf.print_perf_info if defined? @perf
124
124
  end
125
125
  raise e
126
126
  else
127
- #post acceptance on success
127
+ # post acceptance on success
128
128
  run_suite(:post_suite)
129
129
  @perf.print_perf_info if defined? @perf
130
130
  end
131
- #cleanup phase
131
+ # cleanup phase
132
132
  rescue => e
133
133
  begin
134
134
  run_suite(:pre_cleanup)
@@ -137,17 +137,15 @@ module Beaker
137
137
  @logger.error "Failed running the pre-cleanup suite."
138
138
  end
139
139
 
140
- #cleanup on error
140
+ # cleanup on error
141
141
  if /(never)|(onpass)/.match?(@options[:preserve_hosts].to_s)
142
142
  @logger.notify "Cleanup: cleaning up after failed run"
143
- if @network_manager
144
- @network_manager.cleanup
145
- end
143
+ @network_manager.cleanup if @network_manager
146
144
  else
147
145
  preserve_hosts_file
148
146
  end
149
147
 
150
- print_reproduction_info( :error )
148
+ print_reproduction_info(:error)
151
149
 
152
150
  @logger.error "Failed running the test suite."
153
151
  puts ''
@@ -160,25 +158,21 @@ module Beaker
160
158
  @logger.error "Failed running the pre-cleanup suite."
161
159
  end
162
160
 
163
- #cleanup on success
161
+ # cleanup on success
164
162
  if /(never)|(onfail)/.match?(@options[:preserve_hosts].to_s)
165
163
  @logger.notify "Cleanup: cleaning up after successful run"
166
- if @network_manager
167
- @network_manager.cleanup
168
- end
164
+ @network_manager.cleanup if @network_manager
169
165
  else
170
166
  preserve_hosts_file
171
167
  end
172
168
 
173
- if @logger.is_debug?
174
- print_reproduction_info( :debug )
175
- end
169
+ print_reproduction_info(:debug) if @logger.is_debug?
176
170
  end
177
171
  end
178
172
 
179
- #Run the provided test suite
180
- #@param [Symbol] suite_name The test suite to execute
181
- #@param [String] failure_strategy How to proceed after a test failure, 'fast' = stop running tests immediately, 'slow' =
173
+ # Run the provided test suite
174
+ # @param [Symbol] suite_name The test suite to execute
175
+ # @param [String] failure_strategy How to proceed after a test failure, 'fast' = stop running tests immediately, 'slow' =
182
176
  # continue to execute tests.
183
177
  def run_suite(suite_name, failure_strategy = nil)
184
178
  if (@options[suite_name].empty?)
@@ -195,9 +189,7 @@ module Beaker
195
189
  def configured_options
196
190
  result = Beaker::Options::OptionsHash.new
197
191
  @attribution.each do |attribute, setter|
198
- if setter != 'preset'
199
- result[attribute] = @options[attribute]
200
- end
192
+ result[attribute] = @options[attribute] if setter != 'preset'
201
193
  end
202
194
  result
203
195
  end
@@ -223,7 +215,7 @@ module Beaker
223
215
  hosts_yaml['HOSTS'] = combined_instance_and_options_hosts
224
216
  hosts_yaml['CONFIG'] = Beaker::Options::OptionsHash.new.merge(hosts_yaml['CONFIG'] || {})
225
217
  # save the rest of the options, excepting the HOSTS that we have already processed
226
- hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,_v| dontpreserve.match?(k) })
218
+ hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject { |k, _v| dontpreserve.match?(k) })
227
219
  # remove copy of HOSTS information
228
220
  hosts_yaml['CONFIG']['provision'] = false
229
221
  File.open(preserved_hosts_filename, 'w') do |file|
@@ -247,7 +239,7 @@ module Beaker
247
239
  end
248
240
  end
249
241
  end
250
- newly_keyed_hosts_entries
242
+ newly_keyed_hosts_entries
251
243
  end
252
244
 
253
245
  # Prints all information required to reproduce the current run & results to the log
@@ -255,9 +247,9 @@ module Beaker
255
247
  # @see #print_command_line
256
248
  #
257
249
  # @return nil
258
- def print_reproduction_info( log_level = :debug )
259
- print_command_line( log_level )
260
- print_env_vars_affecting_beaker( log_level )
250
+ def print_reproduction_info(log_level = :debug)
251
+ print_command_line(log_level)
252
+ print_env_vars_affecting_beaker(log_level)
261
253
  end
262
254
 
263
255
  # Prints Environment variables affecting the beaker run (those that
@@ -267,24 +259,23 @@ module Beaker
267
259
  # print_env_vars_affecting_beaker :error
268
260
  #
269
261
  # @return nil
270
- def print_env_vars_affecting_beaker( log_level )
271
- non_beaker_env_vars = [ 'BUNDLE_PATH', 'BUNDLE_BIN', 'GEM_HOME', 'GEM_PATH', 'RUBYLIB', 'PATH']
272
- env_var_map = non_beaker_env_vars.inject({}) do |memo, possibly_set_vars|
273
- set_var = Array(possibly_set_vars).detect {|possible_var| ENV[possible_var] }
274
- memo[set_var] = ENV[set_var] if set_var
275
- memo
262
+ def print_env_vars_affecting_beaker(log_level)
263
+ non_beaker_env_vars = %w[BUNDLE_PATH BUNDLE_BIN GEM_HOME GEM_PATH RUBYLIB PATH]
264
+ env_var_map = non_beaker_env_vars.each_with_object({}) do |possibly_set_vars, memo|
265
+ set_var = Array(possibly_set_vars).detect { |possible_var| ENV.fetch(possible_var, nil) }
266
+ memo[set_var] = ENV.fetch(set_var, nil) if set_var
276
267
  end
277
268
 
278
269
  env_var_map = env_var_map.merge(Beaker::Options::Presets.new.env_vars)
279
270
 
280
- @logger.send( log_level, "\nImportant ENV variables that may have affected your run:" )
271
+ @logger.send(log_level, "\nImportant ENV variables that may have affected your run:")
281
272
  env_var_map.each_pair do |var, value|
282
273
  if value.is_a?(Hash)
283
- value.each_pair do | subvar, subvalue |
284
- @logger.send( log_level, " #{subvar}\t\t#{subvalue}" )
274
+ value.each_pair do |subvar, subvalue|
275
+ @logger.send(log_level, " #{subvar}\t\t#{subvalue}")
285
276
  end
286
277
  else
287
- @logger.send( log_level, " #{var}\t\t#{value}" )
278
+ @logger.send(log_level, " #{var}\t\t#{value}")
288
279
  end
289
280
  end
290
281
  end
@@ -300,27 +291,27 @@ module Beaker
300
291
  # Please contact @electrical or the Puppet QE Team for more info, or for requests to support this.
301
292
  #
302
293
  # @return nil
303
- def print_command_line( log_level = :debug )
294
+ def print_command_line(log_level = :debug)
304
295
  @logger.send(log_level, "\nYou can reproduce this run with:\n")
305
296
  @logger.send(log_level, @options[:command_line])
306
- if @options[:hosts_preserved_yaml_file]
307
- set_docker_warning = false
308
- has_supported_hypervisor = false
309
- @hosts.each do |host|
310
- case host[:hypervisor]
311
- when /vagrant|fusion|vmpooler|vcloud/
312
- has_supported_hypervisor = true
313
- when /docker/
314
- set_docker_warning = true
315
- end
316
- end
317
- if has_supported_hypervisor
318
- reproducing_command = build_hosts_preserved_reproducing_command(@options[:command_line], @options[:hosts_preserved_yaml_file])
319
- @logger.send(log_level, "\nYou can re-run commands against the already provisioned SUT(s) with:\n")
320
- @logger.send(log_level, '(docker support is untested for this feature. please reference the docs for more info)') if set_docker_warning
321
- @logger.send(log_level, reproducing_command)
297
+ return unless @options[:hosts_preserved_yaml_file]
298
+
299
+ set_docker_warning = false
300
+ has_supported_hypervisor = false
301
+ @hosts.each do |host|
302
+ case host[:hypervisor]
303
+ when /vagrant|fusion|vmpooler|vcloud/
304
+ has_supported_hypervisor = true
305
+ when /docker/
306
+ set_docker_warning = true
322
307
  end
323
308
  end
309
+ return unless has_supported_hypervisor
310
+
311
+ reproducing_command = build_hosts_preserved_reproducing_command(@options[:command_line], @options[:hosts_preserved_yaml_file])
312
+ @logger.send(log_level, "\nYou can re-run commands against the already provisioned SUT(s) with:\n")
313
+ @logger.send(log_level, '(docker support is untested for this feature. please reference the docs for more info)') if set_docker_warning
314
+ @logger.send(log_level, reproducing_command)
324
315
  end
325
316
 
326
317
  # provides a new version of the command given, edited for re-use with a
@@ -4,7 +4,6 @@ module Beaker
4
4
  #
5
5
  # @api public
6
6
  class Command
7
-
8
7
  # A string representing the (possibly) incomplete command
9
8
  attr_accessor :command
10
9
 
@@ -56,11 +55,8 @@ module Beaker
56
55
  # this is deprecated and will not allow you to use a command line
57
56
  # option of `--environment`, please use ENV instead.
58
57
  [:ENV, :environment, 'environment', 'ENV'].each do |k|
59
- if @options[k].is_a?(Hash)
60
- @environment = @environment.merge(@options.delete(k))
61
- end
58
+ @environment = @environment.merge(@options.delete(k)) if @options[k].is_a?(Hash)
62
59
  end
63
-
64
60
  end
65
61
 
66
62
  # @param [Host] host An object that implements {Beaker::Host}'s
@@ -71,17 +67,17 @@ module Beaker
71
67
  #
72
68
  # @return [String] This returns the fully formed command line invocation.
73
69
  def cmd_line host, cmd = @command, env = @environment, pc = @prepend_cmds, ac = @append_cmds
74
- env_string = host.environment_string( env )
75
- prepend_commands = host.prepend_commands( cmd, pc, :cmd_exe => @cmdexe )
76
- append_commands = host.append_commands( cmd, ac, :cmd_exe => @cmdexe )
70
+ env_string = host.environment_string(env)
71
+ prepend_commands = host.prepend_commands(cmd, pc, :cmd_exe => @cmdexe)
72
+ append_commands = host.append_commands(cmd, ac, :cmd_exe => @cmdexe)
77
73
 
78
74
  # This will cause things like `puppet -t -v agent` which is maybe bad.
79
- if host[:platform]&.include?('cisco_ios_xr')
80
- cmd_line_array = [prepend_commands, env_string, cmd, options_string, args_string, append_commands]
81
- else
82
- cmd_line_array = [env_string, prepend_commands, cmd, options_string, args_string, append_commands]
83
- end
84
- cmd_line_array.compact.reject( &:empty? ).join( ' ' )
75
+ cmd_line_array = if host[:platform]&.include?('cisco_ios_xr')
76
+ [prepend_commands, env_string, cmd, options_string, args_string, append_commands]
77
+ else
78
+ [env_string, prepend_commands, cmd, options_string, args_string, append_commands]
79
+ end
80
+ cmd_line_array.compact.reject(&:empty?).join(' ')
85
81
  end
86
82
 
87
83
  # @param [Hash] opts These are the options that the command takes
@@ -99,9 +95,9 @@ module Beaker
99
95
  end
100
96
  end
101
97
 
102
- short_flags, long_flags = flags.partition {|flag| flag.to_s.length == 1 }
103
- parsed_short_flags = short_flags.map {|f| "-#{f}" }
104
- parsed_long_flags = long_flags.map {|f| "--#{f}" }
98
+ short_flags, long_flags = flags.partition { |flag| flag.to_s.length == 1 }
99
+ parsed_short_flags = short_flags.map { |f| "-#{f}" }
100
+ parsed_long_flags = long_flags.map { |f| "--#{f}" }
105
101
 
106
102
  short_opts, long_opts = {}, {}
107
103
  options.each_key do |key|
@@ -111,8 +107,8 @@ module Beaker
111
107
  long_opts[key] = options[key]
112
108
  end
113
109
  end
114
- parsed_short_opts = short_opts.map {|k,v| "-#{k}=#{v}" }
115
- parsed_long_opts = long_opts.map {|k,v| "--#{k}=#{v}" }
110
+ parsed_short_opts = short_opts.map { |k, v| "-#{k}=#{v}" }
111
+ parsed_long_opts = long_opts.map { |k, v| "--#{k}=#{v}" }
116
112
 
117
113
  return (parsed_short_flags +
118
114
  parsed_long_flags +
@@ -125,18 +121,15 @@ module Beaker
125
121
  def args_string args = @args
126
122
  args.flatten.compact.join(' ')
127
123
  end
128
-
129
-
130
-
131
124
  end
132
125
 
133
126
  class PuppetCommand < Command
134
127
  def initialize *args
135
128
  command = "puppet #{args.shift}"
136
- opts = args.last.is_a?(Hash) ? args.pop : Hash.new
137
- opts['ENV'] ||= Hash.new
129
+ opts = args.last.is_a?(Hash) ? args.pop : {}
130
+ opts['ENV'] ||= {}
138
131
  opts[:cmdexe] = true
139
- super( command, args, opts )
132
+ super(command, args, opts)
140
133
  end
141
134
  end
142
135
 
@@ -147,7 +140,6 @@ module Beaker
147
140
  end
148
141
 
149
142
  class SedCommand < Command
150
-
151
143
  # sets up a SedCommand for a particular platform
152
144
  #
153
145
  # the purpose is to abstract away platform-dependent details of the sed command
@@ -168,8 +160,8 @@ module Beaker
168
160
  command << " > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}"
169
161
  end
170
162
  args = []
171
- opts['ENV'] ||= Hash.new
172
- super( command, args, opts )
163
+ opts['ENV'] ||= {}
164
+ super(command, args, opts)
173
165
  end
174
166
  end
175
167
  end
@@ -3,7 +3,7 @@ require 'minitest/test'
3
3
  module Beaker
4
4
  module CommandFactory
5
5
  include Minitest::Assertions
6
- #Why do we need this accessor?
6
+ # Why do we need this accessor?
7
7
  # https://github.com/seattlerb/minitest/blob/master/lib/minitest/assertions.rb#L8-L12
8
8
  # Protocol: Nearly everything here boils up to +assert+, which
9
9
  # expects to be able to increment an instance accessor named
@@ -11,6 +11,7 @@ module Beaker
11
11
  # provided by the thing including Assertions. See Minitest::Runnable
12
12
  # for an example.
13
13
  attr_writer :assertions
14
+
14
15
  def assertions
15
16
  @assertions || 0
16
17
  end
@@ -27,7 +28,7 @@ module Beaker
27
28
  #
28
29
  # @api private
29
30
  # @return [String] Stdout from command execution
30
- def execute(command, options={})
31
+ def execute(command, options = {})
31
32
  cmd_create_options = {}
32
33
  exec_opts = options.dup
33
34
  cmd_create_options[:prepend_cmds] = exec_opts.delete(:prepend_cmds) || nil