beaker 4.40.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) 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 +17 -28
  8. data/Gemfile +12 -7
  9. data/Rakefile +99 -111
  10. data/acceptance/config/acceptance-options.rb +1 -1
  11. data/acceptance/config/base/acceptance-options.rb +2 -2
  12. data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
  13. data/acceptance/config/subcommands/acceptance-options.rb +2 -2
  14. data/acceptance/fixtures/module/Rakefile +1 -1
  15. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
  16. data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
  17. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  18. data/acceptance/lib/helpers/test_helper.rb +6 -5
  19. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  20. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  21. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
  40. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  41. data/acceptance/tests/base/dsl/structure_test.rb +5 -11
  42. data/acceptance/tests/base/host/file_test.rb +2 -2
  43. data/acceptance/tests/base/host/group_test.rb +0 -1
  44. data/acceptance/tests/base/host/host_test.rb +66 -63
  45. data/acceptance/tests/base/host/packages.rb +1 -2
  46. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  47. data/acceptance/tests/base/host/user_test.rb +0 -1
  48. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  49. data/acceptance/tests/base/test_suite/export.rb +6 -9
  50. data/acceptance/tests/install/from_file.rb +2 -4
  51. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  52. data/acceptance/tests/subcommands/destroy.rb +19 -21
  53. data/acceptance/tests/subcommands/exec.rb +0 -1
  54. data/acceptance/tests/subcommands/init.rb +2 -3
  55. data/acceptance/tests/subcommands/provision.rb +0 -1
  56. data/beaker.gemspec +4 -7
  57. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  58. data/docs/how_to/debug_beaker_tests.md +12 -12
  59. data/docs/how_to/hosts/eos.md +2 -12
  60. data/docs/how_to/install_puppet.md +0 -18
  61. data/docs/how_to/the_beaker_dsl.md +0 -2
  62. data/lib/beaker/cli.rb +59 -68
  63. data/lib/beaker/command.rb +20 -28
  64. data/lib/beaker/command_factory.rb +3 -2
  65. data/lib/beaker/dsl/assertions.rb +6 -18
  66. data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
  67. data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
  68. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  69. data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
  70. data/lib/beaker/dsl/helpers.rb +2 -4
  71. data/lib/beaker/dsl/outcomes.rb +13 -15
  72. data/lib/beaker/dsl/patterns.rb +1 -3
  73. data/lib/beaker/dsl/roles.rb +17 -20
  74. data/lib/beaker/dsl/structure.rb +53 -65
  75. data/lib/beaker/dsl/test_tagging.rb +7 -10
  76. data/lib/beaker/dsl/wrappers.rb +15 -16
  77. data/lib/beaker/dsl.rb +2 -3
  78. data/lib/beaker/host/aix/exec.rb +1 -1
  79. data/lib/beaker/host/aix/file.rb +0 -1
  80. data/lib/beaker/host/aix/group.rb +1 -1
  81. data/lib/beaker/host/aix/user.rb +1 -1
  82. data/lib/beaker/host/aix.rb +3 -4
  83. data/lib/beaker/host/cisco.rb +27 -39
  84. data/lib/beaker/host/eos.rb +4 -30
  85. data/lib/beaker/host/freebsd/exec.rb +1 -1
  86. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  87. data/lib/beaker/host/freebsd.rb +9 -12
  88. data/lib/beaker/host/mac/exec.rb +4 -4
  89. data/lib/beaker/host/mac/group.rb +7 -7
  90. data/lib/beaker/host/mac/pkg.rb +3 -106
  91. data/lib/beaker/host/mac/user.rb +2 -2
  92. data/lib/beaker/host/mac.rb +8 -9
  93. data/lib/beaker/host/pswindows/exec.rb +66 -70
  94. data/lib/beaker/host/pswindows/file.rb +3 -5
  95. data/lib/beaker/host/pswindows/group.rb +3 -3
  96. data/lib/beaker/host/pswindows/pkg.rb +12 -12
  97. data/lib/beaker/host/pswindows/user.rb +3 -3
  98. data/lib/beaker/host/pswindows.rb +4 -3
  99. data/lib/beaker/host/unix/exec.rb +80 -82
  100. data/lib/beaker/host/unix/file.rb +38 -43
  101. data/lib/beaker/host/unix/group.rb +1 -1
  102. data/lib/beaker/host/unix/pkg.rb +154 -417
  103. data/lib/beaker/host/unix/user.rb +2 -2
  104. data/lib/beaker/host/unix.rb +8 -11
  105. data/lib/beaker/host/windows/exec.rb +17 -17
  106. data/lib/beaker/host/windows/file.rb +3 -3
  107. data/lib/beaker/host/windows/group.rb +3 -3
  108. data/lib/beaker/host/windows/pkg.rb +3 -54
  109. data/lib/beaker/host/windows/user.rb +3 -3
  110. data/lib/beaker/host/windows.rb +12 -12
  111. data/lib/beaker/host.rb +76 -133
  112. data/lib/beaker/host_prebuilt_steps.rb +93 -198
  113. data/lib/beaker/hypervisor/noop.rb +2 -4
  114. data/lib/beaker/hypervisor.rb +44 -61
  115. data/lib/beaker/local_connection.rb +2 -4
  116. data/lib/beaker/logger.rb +68 -76
  117. data/lib/beaker/logger_junit.rb +21 -25
  118. data/lib/beaker/network_manager.rb +39 -42
  119. data/lib/beaker/options/command_line_parser.rb +12 -23
  120. data/lib/beaker/options/hosts_file_parser.rb +16 -24
  121. data/lib/beaker/options/options_file_parser.rb +3 -6
  122. data/lib/beaker/options/options_hash.rb +2 -7
  123. data/lib/beaker/options/parser.rb +86 -102
  124. data/lib/beaker/options/presets.rb +114 -123
  125. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  126. data/lib/beaker/options/validator.rb +26 -31
  127. data/lib/beaker/perf.rb +22 -27
  128. data/lib/beaker/platform.rb +38 -46
  129. data/lib/beaker/result.rb +7 -6
  130. data/lib/beaker/shared/error_handler.rb +8 -10
  131. data/lib/beaker/shared/fog_credentials.rb +5 -9
  132. data/lib/beaker/shared/host_manager.rb +36 -41
  133. data/lib/beaker/shared/options_resolver.rb +3 -7
  134. data/lib/beaker/shared/repetition.rb +2 -4
  135. data/lib/beaker/shared/semvar.rb +37 -41
  136. data/lib/beaker/shared/timed.rb +0 -3
  137. data/lib/beaker/shared.rb +1 -1
  138. data/lib/beaker/ssh_connection.rb +38 -47
  139. data/lib/beaker/subcommand.rb +17 -24
  140. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  141. data/lib/beaker/tasks/quick_start.rb +4 -9
  142. data/lib/beaker/tasks/rake_task.rb +25 -27
  143. data/lib/beaker/tasks/test.rb +4 -4
  144. data/lib/beaker/test_case.rb +16 -28
  145. data/lib/beaker/test_suite.rb +35 -39
  146. data/lib/beaker/test_suite_result.rb +45 -47
  147. data/lib/beaker/version.rb +1 -1
  148. data/lib/beaker.rb +6 -7
  149. data/spec/beaker/cli_spec.rb +121 -142
  150. data/spec/beaker/command_spec.rb +55 -59
  151. data/spec/beaker/dsl/assertions_spec.rb +36 -36
  152. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
  153. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  154. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
  155. data/spec/beaker/dsl/outcomes_spec.rb +14 -14
  156. data/spec/beaker/dsl/roles_spec.rb +125 -130
  157. data/spec/beaker/dsl/structure_spec.rb +172 -161
  158. data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
  159. data/spec/beaker/dsl/wrappers_spec.rb +32 -33
  160. data/spec/beaker/host/aix_spec.rb +14 -14
  161. data/spec/beaker/host/cisco_spec.rb +84 -94
  162. data/spec/beaker/host/eos_spec.rb +15 -36
  163. data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
  164. data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
  165. data/spec/beaker/host/mac/exec_spec.rb +2 -3
  166. data/spec/beaker/host/mac/group_spec.rb +48 -57
  167. data/spec/beaker/host/mac/user_spec.rb +54 -63
  168. data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
  169. data/spec/beaker/host/pswindows/file_spec.rb +16 -16
  170. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  171. data/spec/beaker/host/pswindows_spec.rb +13 -13
  172. data/spec/beaker/host/unix/exec_spec.rb +75 -80
  173. data/spec/beaker/host/unix/file_spec.rb +66 -73
  174. data/spec/beaker/host/unix/pkg_spec.rb +155 -401
  175. data/spec/beaker/host/unix_spec.rb +11 -207
  176. data/spec/beaker/host/windows/exec_spec.rb +30 -32
  177. data/spec/beaker/host/windows/file_spec.rb +18 -19
  178. data/spec/beaker/host/windows/group_spec.rb +10 -12
  179. data/spec/beaker/host/windows/pkg_spec.rb +6 -9
  180. data/spec/beaker/host/windows/user_spec.rb +17 -23
  181. data/spec/beaker/host/windows_spec.rb +39 -39
  182. data/spec/beaker/host_prebuilt_steps_spec.rb +172 -326
  183. data/spec/beaker/host_spec.rb +204 -284
  184. data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
  185. data/spec/beaker/localhost_connection_spec.rb +10 -11
  186. data/spec/beaker/logger_junit_spec.rb +19 -30
  187. data/spec/beaker/logger_spec.rb +153 -136
  188. data/spec/beaker/network_manager_spec.rb +23 -23
  189. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  190. data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
  191. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  192. data/spec/beaker/options/options_hash_spec.rb +4 -6
  193. data/spec/beaker/options/parser_spec.rb +167 -167
  194. data/spec/beaker/options/presets_spec.rb +7 -9
  195. data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
  196. data/spec/beaker/options/validator_spec.rb +10 -11
  197. data/spec/beaker/perf_spec.rb +18 -21
  198. data/spec/beaker/platform_spec.rb +25 -36
  199. data/spec/beaker/shared/error_handler_spec.rb +7 -16
  200. data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
  201. data/spec/beaker/shared/host_manager_spec.rb +50 -84
  202. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  203. data/spec/beaker/shared/repetition_spec.rb +17 -24
  204. data/spec/beaker/shared/semvar_spec.rb +21 -26
  205. data/spec/beaker/ssh_connection_spec.rb +76 -83
  206. data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
  207. data/spec/beaker/subcommand_spec.rb +75 -77
  208. data/spec/beaker/test_case_spec.rb +25 -50
  209. data/spec/beaker/test_suite_spec.rb +147 -154
  210. data/spec/helpers.rb +48 -53
  211. data/spec/matchers.rb +8 -7
  212. data/spec/mocks.rb +1 -6
  213. data/spec/spec_helper.rb +0 -1
  214. metadata +7 -24
  215. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  216. data/acceptance/tests/base/external_resources_test.rb +0 -31
  217. data/spec/beaker/host/mac_spec.rb +0 -113
@@ -8,7 +8,7 @@ test_name "dsl::helpers::host_helpers #shell" do
8
8
  end
9
9
 
10
10
  step "#shell makes command output available via `.stdout` on success" do
11
- output = shell(%Q{echo "echo via on"}).stdout
11
+ output = shell(%{echo "echo via on"}).stdout
12
12
  assert_equal "echo via on\n", output
13
13
  end
14
14
 
@@ -18,7 +18,7 @@ test_name "dsl::helpers::host_helpers #shell" do
18
18
  end
19
19
 
20
20
  step "#shell makes exit status available via `.exit_code`" do
21
- status = shell(%Q{echo "echo via on"}).exit_code
21
+ status = shell(%{echo "echo via on"}).exit_code
22
22
  assert_equal 0, status
23
23
  end
24
24
 
@@ -32,7 +32,7 @@ test_name "dsl::helpers::host_helpers #shell" do
32
32
 
33
33
  step "#shell with :acceptable_exit_codes will fail for other exit codes" do
34
34
  assert_raises(Beaker::Host::CommandFailure) do
35
- shell %Q{echo "echo via on"}, :acceptable_exit_codes => [127]
35
+ shell %{echo "echo via on"}, :acceptable_exit_codes => [127]
36
36
  end
37
37
  end
38
38
 
@@ -44,8 +44,8 @@ test_name "dsl::helpers::host_helpers #shell" do
44
44
  end
45
45
 
46
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)
47
+ shell %{echo "${RANDOM}:${RANDOM}"} do |result|
48
+ assert_match(/\d+:\d+/, result.stdout)
49
49
  end
50
50
  end
51
51
  end
@@ -1,10 +1,8 @@
1
1
  require "helpers/test_helper"
2
2
 
3
3
  test_name "dsl::helpers::host_helpers #upgrade_package" do
4
-
5
4
  # NOTE: there does not appear to be a way to confine just to cygwin hosts
6
5
  confine_block :to, :platform => /windows/ do
7
-
8
6
  # NOTE: check_for_package on windows currently fails as follows:
9
7
  #
10
8
  # ArgumentError: wrong number of arguments (3 for 1..2)
@@ -20,7 +18,6 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
20
18
  end
21
19
 
22
20
  confine_block :to, :platform => /osx/ do
23
-
24
21
  step "#upgrade_package CURRENTLY fails with a RuntimeError on OS X" do
25
22
  # NOTE: documentation could be better on this method
26
23
  assert_raises RuntimeError do
@@ -30,8 +27,10 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
30
27
  end
31
28
 
32
29
  confine_block :except, :platform => /windows|osx/ do
33
- confine_block :to, :platform => /centos|el-\d/ do
30
+ # rsync is broken on beaker-docker
31
+ confine :except, :hypervisor => 'docker'
34
32
 
33
+ confine_block :to, :platform => /centos|el-\d/ do
35
34
  step "#upgrade_package CURRENTLY does not fail on CentOS if unknown package is specified" do
36
35
  # NOTE: I would expect this to fail with an Beaker::Host::CommandFailure,
37
36
  # but maybe it's because yum doesn't really care:
@@ -48,7 +47,6 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
48
47
  end
49
48
 
50
49
  confine_block :except, :platform => /centos|el-\d/ do
51
-
52
50
  step "#upgrade_package fails if package is not already installed" do
53
51
  assert_raises Beaker::Host::CommandFailure do
54
52
  upgrade_package default, "non-existent-package-name"
@@ -13,32 +13,29 @@ test_name "DSL::Structure::PlatformTagConfiner" do
13
13
  end
14
14
 
15
15
  step "#{pstc_method_name} can remove hosts from a test, or be skipped if empty" do
16
- assert hosts.length() > 0, "#{pstc_method_name} did not have enough hosts to test"
16
+ assert hosts.length > 0, "#{pstc_method_name} did not have enough hosts to test"
17
17
  previous_hosts = hosts.dup
18
18
 
19
19
  options[:platform_tag_confines] = [
20
20
  :platform => /#{default[:platform]}/,
21
21
  :tag_reason_hash => {
22
- 'tag1' => 'reason1'
23
- }
22
+ 'tag1' => 'reason1',
23
+ },
24
24
  ]
25
25
 
26
26
  begin
27
- tag( 'tag1' )
27
+ tag('tag1')
28
28
  rescue Beaker::DSL::Outcomes::SkipTest => e
29
- if /^No\ suitable\ hosts\ found/.match?(e.message)
30
- # SkipTest is raised in the case when there are no hosts leftover for a test
31
- # after confining. It's a very common acceptance test case where all of the
32
- # hosts involved are of the same platform, and are thus all confined
33
- # away by the code being run here. In this case, the hosts object will not
34
- # be altered, but should be considered a pass, since the fact that SkipTest
35
- # is being raised confirms that a lower number of hosts are coming out of
36
- # the confine (0) than came in (>0, according to our pre-condition assertion)
37
- else
38
- fail "#{pstc_method_name} raised unexpected SkipTest exception: #{e}"
39
- end
29
+ fail "#{pstc_method_name} raised unexpected SkipTest exception: #{e}" unless /^No\ suitable\ hosts\ found/.match?(e.message)
30
+ # SkipTest is raised in the case when there are no hosts leftover for a test
31
+ # after confining. It's a very common acceptance test case where all of the
32
+ # hosts involved are of the same platform, and are thus all confined
33
+ # away by the code being run here. In this case, the hosts object will not
34
+ # be altered, but should be considered a pass, since the fact that SkipTest
35
+ # is being raised confirms that a lower number of hosts are coming out of
36
+ # the confine (0) than came in (>0, according to our pre-condition assertion)
40
37
  else
41
- assert hosts.length() < previous_hosts.length(), "#{pstc_method_name} did not change hosts array"
38
+ assert hosts.length < previous_hosts.length, "#{pstc_method_name} did not change hosts array"
42
39
  end
43
40
 
44
41
  # cleanup
@@ -46,4 +43,4 @@ test_name "DSL::Structure::PlatformTagConfiner" do
46
43
  options[:platform_tag_confines] = nil
47
44
  @hosts = previous_hosts
48
45
  end
49
- end
46
+ end
@@ -3,11 +3,10 @@ test_name "dsl::structure" do
3
3
  begin
4
4
  @in_confine = 0
5
5
  confine_block :to, :platform => default["platform"] do
6
- @in_confine +=1
6
+ @in_confine += 1
7
7
  end
8
8
 
9
9
  assert_equal 1, @in_confine, "#confine_block did not run the supplied block"
10
-
11
10
  rescue Beaker::DSL::Outcomes::SkipTest => e
12
11
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
13
12
  end
@@ -17,12 +16,11 @@ test_name "dsl::structure" do
17
16
  begin
18
17
  @in_confine = 0
19
18
  confine_block :to, :platform => default["platform"] do
20
- @in_confine +=1
19
+ @in_confine += 1
21
20
  end
22
21
 
23
22
  assert_equal 1, @in_confine, "#confine_block did not run the supplied block"
24
23
  assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
25
-
26
24
  rescue Beaker::DSL::Outcomes::SkipTest => e
27
25
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
28
26
  end
@@ -32,11 +30,10 @@ test_name "dsl::structure" do
32
30
  begin
33
31
  @in_confine = 0
34
32
  confine_block :except, :platform => default["platform"] do
35
- @in_confine +=1
33
+ @in_confine += 1
36
34
  end
37
35
 
38
36
  assert_equal 0, @in_confine, "#confine_block did not skip the supplied block"
39
-
40
37
  rescue Beaker::DSL::Outcomes::SkipTest => e
41
38
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
42
39
  end
@@ -46,12 +43,11 @@ test_name "dsl::structure" do
46
43
  begin
47
44
  @in_confine = 0
48
45
  confine_block :except, :platform => default["platform"] do
49
- @in_confine +=1
46
+ @in_confine += 1
50
47
  end
51
48
 
52
49
  assert_equal 0, @in_confine, "#confine_block did not skip the supplied block"
53
50
  assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
54
-
55
51
  rescue Beaker::DSL::Outcomes::SkipTest => e
56
52
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
57
53
  end
@@ -61,7 +57,7 @@ test_name "dsl::structure" do
61
57
  begin
62
58
  @in_confine = 0
63
59
  confine_block :to, :platform => default["platform"] do
64
- @in_confine +=1
60
+ @in_confine += 1
65
61
  skip_test "this block raises a skip"
66
62
  end
67
63
  rescue Beaker::DSL::Outcomes::SkipTest => e
@@ -76,7 +72,6 @@ test_name "dsl::structure" do
76
72
  confine :to, { :platform => 'test' }
77
73
 
78
74
  fail "#confine did not skip test but should have."
79
-
80
75
  rescue Beaker::DSL::Outcomes::SkipTest => e
81
76
  assert_match(/No suitable hosts found with {:platform=>"test"}/, e.message, "#confine raised an unexpected skip_test")
82
77
  end
@@ -87,7 +82,6 @@ test_name "dsl::structure" do
87
82
  confine :except, { :platform => default['platform'] }
88
83
 
89
84
  fail "#confine did not skip test but should have."
90
-
91
85
  rescue Beaker::DSL::Outcomes::SkipTest => e
92
86
  assert_match(/No suitable hosts found without {:platform=>"#{default['platform']}"}/, e.message, "#confine raised an unexpected
93
87
  # skip_test")
@@ -21,7 +21,7 @@ test_name 'File Test' do
21
21
  tmpdir = host.tmpdir('beaker')
22
22
  # ensure we have a user to chown to
23
23
  host.chgrp('testgroup', tmpdir)
24
- assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output: #{stdout}")
24
+ assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output")
25
25
  end
26
26
  end
27
27
 
@@ -78,4 +78,4 @@ test_name 'File Test' do
78
78
  host.user_absent('testuser')
79
79
  host.group_absent('testgroup')
80
80
  end
81
- end
81
+ end
@@ -14,5 +14,4 @@ test_name 'Group Test' do
14
14
  end
15
15
  end
16
16
  end
17
-
18
17
  end
@@ -34,7 +34,7 @@ hosts.each do |host|
34
34
  env_value1 = "#{env_prefix}_v1"
35
35
 
36
36
  host.clear_env_var(env_param1)
37
- host.add_env_var(env_param1,env_value1)
37
+ host.add_env_var(env_param1, env_value1)
38
38
 
39
39
  val = host.get_env_var(env_param1)
40
40
 
@@ -57,12 +57,12 @@ hosts.each do |host|
57
57
  host.clear_env_var(env_param1)
58
58
  host.clear_env_var(env_param2)
59
59
  host.clear_env_var(env_param3)
60
- host.add_env_var(env_param1,env_value1)
61
- host.add_env_var(env_param1,env_value2)
62
- host.add_env_var(env_param1,env_value3)
60
+ host.add_env_var(env_param1, env_value1)
61
+ host.add_env_var(env_param1, env_value2)
62
+ host.add_env_var(env_param1, env_value3)
63
63
 
64
64
  val = host.get_env_var(env_id)
65
- assert('' == val,'get_env_var should not match a partial env key name')
65
+ assert('' == val, 'get_env_var should not match a partial env key name')
66
66
  end
67
67
 
68
68
  step "#get_env_var : should not return a match from a key\'s value"
@@ -72,10 +72,10 @@ hosts.each do |host|
72
72
  env_value1 = "#{env_prefix}_v1"
73
73
 
74
74
  host.clear_env_var(env_param1)
75
- host.add_env_var(env_param1,env_value1)
75
+ host.add_env_var(env_param1, env_value1)
76
76
 
77
77
  val = host.get_env_var(env_value1)
78
- assert('' == val,'get_env_var should not return a match from a key\'s value')
78
+ assert('' == val, 'get_env_var should not return a match from a key\'s value')
79
79
  end
80
80
 
81
81
  step "#clear_env_var : should only remove the specified key"
@@ -92,9 +92,9 @@ hosts.each do |host|
92
92
  env_param3 = "#{env_id}"
93
93
  env_value3 = "#{env_id}"
94
94
 
95
- host.add_env_var(env_param1,env_value1)
96
- host.add_env_var(env_param2,env_value2)
97
- host.add_env_var(env_param3,env_value3)
95
+ host.add_env_var(env_param1, env_value1)
96
+ host.add_env_var(env_param2, env_value2)
97
+ host.add_env_var(env_param3, env_value3)
98
98
 
99
99
  host.clear_env_var(env_param3)
100
100
 
@@ -103,7 +103,7 @@ hosts.each do |host|
103
103
  val = host.get_env_var(env_param2)
104
104
  assert_match(/^#{env_param2}=#{env_value2}$/, val, "#{env_param2} should exist after calling clear_env_var")
105
105
  val = host.get_env_var(env_param3)
106
- assert('' == val,"#{env_param3} should not exist after calling clear_env_var")
106
+ assert('' == val, "#{env_param3} should not exist after calling clear_env_var")
107
107
  end
108
108
 
109
109
  step "#add_env_var : can add a unique environment variable"
@@ -121,9 +121,9 @@ hosts.each do |host|
121
121
  host.clear_env_var(env_param1)
122
122
  host.clear_env_var(env_param2)
123
123
  host.clear_env_var(env_param3)
124
- host.add_env_var(env_param1,env_value1)
125
- host.add_env_var(env_param2,env_value2)
126
- host.add_env_var(env_param3,env_value3)
124
+ host.add_env_var(env_param1, env_value1)
125
+ host.add_env_var(env_param2, env_value2)
126
+ host.add_env_var(env_param3, env_value3)
127
127
 
128
128
  val = host.get_env_var(env_param1)
129
129
  assert_match(/^#{env_param1}=#{env_value1}$/, val, "#{env_param1} should exist")
@@ -150,23 +150,27 @@ hosts.each do |host|
150
150
  assert_match(/TEST=3(;|:)2(;|:)1$/, val, "add_env_var can correctly add env vars")
151
151
  end
152
152
 
153
- step "#add_env_var : can preserve an environment between ssh connections"
154
- hosts.each do |host|
155
- host.clear_env_var("TEST")
156
- logger.debug("add TEST=1")
157
- host.add_env_var("TEST", "1")
158
- logger.debug("add TEST=1 again (shouldn't create duplicate entry)")
159
- host.add_env_var("TEST", "1")
160
- logger.debug("add TEST=2")
161
- host.add_env_var("TEST", "2")
162
- logger.debug("ensure that TEST env var has correct setting")
163
- logger.debug("add TEST=3")
164
- host.add_env_var("TEST", "3")
165
- logger.debug("close the connection")
166
- host.close
167
- logger.debug("ensure that TEST env var has correct setting")
168
- val = host.get_env_var("TEST")
169
- assert_match(/TEST=3(;|:)2(;|:)1$/, val, "can preserve an environment between ssh connections")
153
+ step "#add_env_var : can preserve an environment between ssh connections" do
154
+ # beaker-docker can't deal with closing the connection
155
+ confine :except, :hypervisor => 'docker'
156
+
157
+ hosts.each do |host|
158
+ host.clear_env_var("TEST")
159
+ logger.debug("add TEST=1")
160
+ host.add_env_var("TEST", "1")
161
+ logger.debug("add TEST=1 again (shouldn't create duplicate entry)")
162
+ host.add_env_var("TEST", "1")
163
+ logger.debug("add TEST=2")
164
+ host.add_env_var("TEST", "2")
165
+ logger.debug("ensure that TEST env var has correct setting")
166
+ logger.debug("add TEST=3")
167
+ host.add_env_var("TEST", "3")
168
+ logger.debug("close the connection")
169
+ host.close
170
+ logger.debug("ensure that TEST env var has correct setting")
171
+ val = host.get_env_var("TEST")
172
+ assert_match(/TEST=3(;|:)2(;|:)1$/, val, "can preserve an environment between ssh connections")
173
+ end
170
174
  end
171
175
 
172
176
  step "#delete_env_var : can delete an environment"
@@ -187,9 +191,9 @@ end
187
191
 
188
192
  step "#mkdir_p : can recursively create a directory structure on a host"
189
193
  hosts.each do |host|
190
- #clean up first!
194
+ # clean up first!
191
195
  host.rm_rf("test1")
192
- #test dir construction
196
+ # test dir construction
193
197
  logger.debug("create test1/test2/test3/test4")
194
198
  assert_equal(true, host.mkdir_p("test1/test2/test3/test4"), "can create directory structure")
195
199
  logger.debug("should be able to create a file in the new dir")
@@ -197,23 +201,23 @@ hosts.each do |host|
197
201
  end
198
202
 
199
203
  step "#do_scp_to : can copy a directory to the host with no ignores"
200
- current_dir = File.dirname(__FILE__)
204
+ current_dir = __dir__
201
205
  module_fixture = File.join(current_dir, "../../../fixtures/module")
202
206
  hosts.each do |host|
203
207
  logger.debug("can recursively copy a module over")
204
- #make sure that we are clean on the test host
208
+ # make sure that we are clean on the test host
205
209
  host.rm_rf("module")
206
210
  host.do_scp_to(module_fixture, ".", {})
207
211
  Dir.mktmpdir do |tmp_dir|
208
- #grab copy from host
212
+ # grab copy from host
209
213
  host.do_scp_from("module", tmp_dir, {})
210
- #compare to local copy
214
+ # compare to local copy
211
215
  local_paths = Dir.glob(File.join(module_fixture, "**/*")).select { |f| File.file?(f) }
212
216
  host_paths = Dir.glob(File.join(File.join(tmp_dir, "module"), "**/*")).select { |f| File.file?(f) }
213
- #each local file should have a single match on the host
217
+ # each local file should have a single match on the host
214
218
  local_paths.each do |path|
215
- search_name = path.gsub(/^.*fixtures\//, '') #reduce down to the path that should match
216
- matched = host_paths.select{ |check| /#{Regexp.escape(search_name)}$/.match?(check) }
219
+ search_name = path.gsub(/^.*fixtures\//, '') # reduce down to the path that should match
220
+ matched = host_paths.select { |check| /#{Regexp.escape(search_name)}$/.match?(check) }
217
221
  assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
218
222
  host_paths = host_paths - matched
219
223
  end
@@ -222,24 +226,24 @@ hosts.each do |host|
222
226
  end
223
227
 
224
228
  step "#do_scp_to with :ignore : can copy a dir to the host, excluding ignored patterns that DO NOT appear in the source absolute path"
225
- current_dir = File.dirname(__FILE__)
229
+ current_dir = __dir__
226
230
  module_fixture = File.expand_path(File.join(current_dir, "../../../fixtures/module"))
227
231
  hosts.each do |host|
228
232
  logger.debug("can recursively copy a module over, ignoring some files/dirs")
229
- #make sure that we are clean on the test host
233
+ # make sure that we are clean on the test host
230
234
  host.rm_rf("module")
231
- host.do_scp_to(module_fixture, ".", {:ignore => ['tests', 'Gemfile']})
235
+ host.do_scp_to(module_fixture, ".", { :ignore => %w[tests Gemfile] })
232
236
  Dir.mktmpdir do |tmp_dir|
233
- #grab copy from host
237
+ # grab copy from host
234
238
  host.do_scp_from("module", tmp_dir, {})
235
- #compare to local copy
239
+ # compare to local copy
236
240
  local_paths = Dir.glob(File.join(module_fixture, "**/*")).select { |f| File.file?(f) }
237
241
  host_paths = Dir.glob(File.join(File.join(tmp_dir, "module"), "**/*")).select { |f| File.file?(f) }
238
- #each local file should have a single match on the host
242
+ # each local file should have a single match on the host
239
243
  local_paths.each do |path|
240
- search_name = path.gsub(/^.*fixtures\//, '') #reduce down to the path that should match
241
- matched = host_paths.select{ |check| /#{Regexp.escape(search_name)}$/.match?(check) }
242
- re = /((\/|\A)tests(\/|\z))|((\/|\A)Gemfile(\/|\z))/
244
+ search_name = path.gsub(/^.*fixtures\//, '') # reduce down to the path that should match
245
+ matched = host_paths.select { |check| /#{Regexp.escape(search_name)}$/.match?(check) }
246
+ re = /((\/|\A)tests(\/|\z))|((\/|\A)Gemfile(\/|\z))/
243
247
  if !path&.match?(re)
244
248
  assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
245
249
  else
@@ -252,24 +256,25 @@ hosts.each do |host|
252
256
  end
253
257
 
254
258
  step "#do_scp_to with :ignore : can copy a dir to the host, excluding ignored patterns that DO appear in the source absolute path"
255
- current_dir = File.dirname(__FILE__)
259
+ current_dir = __dir__
256
260
  module_fixture = File.expand_path(File.join(current_dir, "../../../fixtures/module"))
257
261
  hosts.each do |host|
258
262
  logger.debug("can recursively copy a module over, ignoring some sub-files/sub-dirs that also appear in the absolute path")
259
- #make sure that we are clean on the test host
263
+ # make sure that we are clean on the test host
260
264
  host.rm_rf("module")
261
- host.do_scp_to(module_fixture, ".", {:ignore => ['module', 'Gemfile']})
265
+ host.do_scp_to(module_fixture, ".", { :ignore => %w[module Gemfile] })
262
266
  Dir.mktmpdir do |tmp_dir|
263
- #grab copy from host
267
+ # grab copy from host
264
268
  host.do_scp_from("module", tmp_dir, {})
265
- #compare to local copy
269
+ # compare to local copy
266
270
  local_paths = Dir.glob(File.join(module_fixture, "**/*")).select { |f| File.file?(f) }
267
271
  host_paths = Dir.glob(File.join(File.join(tmp_dir, "module"), "**/*")).select { |f| File.file?(f) }
268
- #each local file should have a single match on the host
272
+ # each local file should have a single match on the host
269
273
  local_paths.each do |path|
270
- search_name = path.gsub(/^.*fixtures\/module\//, '') #reduce down to the path that should match
271
- matched = host_paths.select{ |check| check =~ /#{Regexp.escape(search_name)}$/ }
272
- re = /((\/|\A)module(\/|\z))|((\/|\A)Gemfile(\/|\z))/
274
+ search_name = path.gsub(/^.*fixtures\/module\//, '') # reduce down to the path that should match
275
+ search_name_regex = /#{Regexp.escape(search_name)}$/
276
+ matched = host_paths.select { |check| search_name_regex.match?(check) }
277
+ re = /((\/|\A)module(\/|\z))|((\/|\A)Gemfile(\/|\z))/
273
278
  if !path.gsub(/^.*module\//, '')&.match?(re)
274
279
  assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
275
280
  else
@@ -282,9 +287,10 @@ hosts.each do |host|
282
287
  end
283
288
 
284
289
  step "Ensure scp errors close the ssh connection" do
290
+ # beaker-docker can't deal with closing the connection
291
+ confine :except, :hypervisor => 'docker'
285
292
 
286
293
  step 'Attempt to generate a remote file that does not exist' do
287
-
288
294
  # This assert relies on the behavior of the net-scp library to
289
295
  # raise an error when #channel.on_close is called, which is called by
290
296
  # indirectly called by beaker's own SshConnection #close mehod. View
@@ -301,7 +307,6 @@ step "Ensure scp errors close the ssh connection" do
301
307
  end
302
308
 
303
309
  step 'Attempt to scp from a resource on the SUT that does not exist' do
304
-
305
310
  # This assert relies on the behavior of the net-scp library to
306
311
  # use the Dir.mkdir method in the #download_start_state method.
307
312
  # See the source for further info:
@@ -318,7 +323,7 @@ step "Ensure scp errors close the ssh connection" do
318
323
  end
319
324
 
320
325
  step 'Ensure that a long 128+ character string with UTF-8 characters does not break net-ssh' do
321
- long_string = 'a' * 128 + "\u06FF"
326
+ long_string = ('a' * 128) + "\u06FF"
322
327
  on(default, "mkdir /tmp/#{long_string}")
323
328
  result = on(default, 'ls /tmp')
324
329
  assert(result.stdout.include?(long_string), 'Error in folder creation with long string + UTF-8 characters')
@@ -327,6 +332,4 @@ step 'Ensure that a long 128+ character string with UTF-8 characters does not br
327
332
  on(default, "rm -rf /tmp/#{long_string}")
328
333
  result = on(default, 'ls /tmp')
329
334
  assert(!result.stdout.include?(long_string), 'Error in folder deletion with long string + UTF-8 characters')
330
-
331
335
  end
332
-
@@ -22,7 +22,6 @@ def get_host_pkg(host)
22
22
  else
23
23
  Beaker::HostPrebuiltSteps::UNIX_PACKAGES
24
24
  end
25
-
26
25
  end
27
26
 
28
27
  step '#check_for_command : can determine where a command exists'
@@ -49,6 +48,7 @@ hosts.each do |host|
49
48
  # a lot of dependencies.
50
49
  # skipping this test for windows since it requires a restart
51
50
  next if host['platform'].include?('windows')
51
+
52
52
  package = 'zsh'
53
53
  package = 'CSWzsh' if host['platform'].include?('solaris-10')
54
54
  package = 'git' if /opensuse|sles/.match?(host['platform'])
@@ -78,5 +78,4 @@ hosts.each do |host|
78
78
  assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
79
79
  end
80
80
  end
81
-
82
81
  end
@@ -1,62 +1,7 @@
1
1
  test_name 'confirm unix-specific package methods work'
2
2
  confine :except, :platform => %w(windows solaris osx)
3
3
 
4
- current_dir = File.dirname(__FILE__)
5
- pkg_fixtures = File.expand_path(File.join(current_dir, '../../../fixtures/package'))
6
- pkg_name = 'puppetserver'
7
-
8
- def clean_file(host, file)
9
- unless file.nil?
10
- filename = pkg_file(host, file)
11
-
12
- if !filename.nil? && host.file_exist?(filename)
13
- on(host, "rm -rf #{filename}")
14
- end
15
- end
16
- end
17
-
18
- def pkg_file(host, pkg_name)
19
- if /debian|ubuntu/.match?(host['platform'])
20
- "/etc/apt/sources.list.d/#{pkg_name}.list"
21
- elsif host['platform'].include?('el')
22
- "/etc/yum.repos.d/#{pkg_name}.repo"
23
- else
24
- nil
25
- end
26
- end
27
-
28
4
  step '#update_apt_if_needed : can execute without raising an error'
29
5
  hosts.each do |host|
30
6
  host.update_apt_if_needed
31
7
  end
32
-
33
- step '#deploy_apt_repo : deploy puppet-server nightly repo'
34
- hosts.each do |host|
35
-
36
- if /debian|ubuntu/.match?(host['platform'])
37
- clean_file(host, pkg_name)
38
- host.deploy_apt_repo(pkg_fixtures, pkg_name, 'latest')
39
- assert(host.file_exist?(pkg_file(host, pkg_name)), 'apt file should exist')
40
- clean_file(host, pkg_name)
41
- end
42
-
43
- end
44
-
45
- step '#deploy_yum_repo : deploy puppet-server nightly repo'
46
- hosts.each do |host|
47
-
48
- if host['platform'].include?('el')
49
- clean_file(host, pkg_name)
50
- host.deploy_yum_repo(pkg_fixtures, pkg_name, 'latest')
51
- assert(host.file_exist?(pkg_file(host, pkg_name)), 'yum file should exist')
52
- clean_file(host, pkg_name)
53
- end
54
-
55
- end
56
-
57
- step '#deploy_package_repo : deploy puppet-server nightly repo'
58
- hosts.each do |host|
59
- next if host['platform'].variant == 'sles' && Integer(host['platform'].version) < 12
60
- host.deploy_package_repo(pkg_fixtures, pkg_name, 'latest')
61
- clean_file(host, pkg_name)
62
- end
@@ -14,5 +14,4 @@ test_name 'User Test' do
14
14
  end
15
15
  end
16
16
  end
17
-
18
17
  end
@@ -1,5 +1,4 @@
1
1
  test_name "confirm host prebuilt steps behave correctly" do
2
-
3
2
  confine_block :except, :platform => /f5|windows/ do
4
3
  step "confirm ssh environment file existence" do
5
4
  hosts.each do |host|
@@ -29,4 +28,4 @@ test_name "confirm host prebuilt steps behave correctly" do
29
28
  end
30
29
  end
31
30
  end
32
- end
31
+ end
@@ -1,13 +1,10 @@
1
1
  test_name 'ensure tests can export arbitrary data' do
2
-
3
2
  step 'export nested hash' do
4
- export({'middle earth' => {
5
- 'Hobbits' => ['Bilbo', 'Frodo'],
6
- 'Elves' => 'Arwen',
7
- :total => {'numbers' => 42}
8
- }
9
- })
10
- export({'another' => 'author'})
3
+ export({ 'middle earth' => {
4
+ 'Hobbits' => %w[Bilbo Frodo],
5
+ 'Elves' => 'Arwen',
6
+ :total => { 'numbers' => 42 },
7
+ } })
8
+ export({ 'another' => 'author' })
11
9
  end
12
-
13
10
  end
@@ -6,15 +6,13 @@ step 'install arbitrary msi via url' do
6
6
  hosts.each do |host|
7
7
  if host['platform'].include?('win')
8
8
  # this should be implemented at the host/win/pkg.rb level someday
9
- generic_install_msi_on(host, 'https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.msi', {}, {:debug => true})
9
+ generic_install_msi_on(host, 'https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.msi', {}, { :debug => true })
10
10
  end
11
11
  end
12
12
  end
13
13
 
14
14
  step 'install arbitrary dmg via url' do
15
15
  hosts.each do |host|
16
- if host['platform'].include?('osx')
17
- host.generic_install_dmg('https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.dmg', 'Vagrant', 'Vagrant.pkg')
18
- end
16
+ host.generic_install_dmg('https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.dmg', 'Vagrant', 'Vagrant.pkg') if host['platform'].include?('osx')
19
17
  end
20
18
  end
@@ -5,6 +5,6 @@
5
5
  begin
6
6
  require 'helpers/test_helper'
7
7
  rescue LoadError
8
- $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH << File.expand_path(File.join(__dir__, '..', 'lib'))
9
9
  require 'helpers/test_helper'
10
10
  end