beaker 4.38.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) 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 +36 -11
  5. data/.rubocop.yml +75 -0
  6. data/.rubocop_todo.yml +239 -0
  7. data/CHANGELOG.md +88 -33
  8. data/Gemfile +16 -4
  9. data/HISTORY.md +103 -0
  10. data/Rakefile +101 -112
  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/Gemfile +1 -1
  16. data/acceptance/fixtures/module/Rakefile +3 -3
  17. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
  18. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
  19. data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
  20. data/acceptance/lib/helpers/test_helper.rb +7 -6
  21. data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
  22. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
  23. data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
  24. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +7 -8
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +9 -7
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +23 -30
  30. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
  31. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
  32. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +21 -16
  33. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
  34. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
  35. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
  36. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
  37. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
  38. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
  39. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
  40. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
  41. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
  42. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
  43. data/acceptance/tests/base/dsl/structure_test.rb +9 -21
  44. data/acceptance/tests/base/host/file_test.rb +8 -8
  45. data/acceptance/tests/base/host/group_test.rb +2 -3
  46. data/acceptance/tests/base/host/host_test.rb +69 -66
  47. data/acceptance/tests/base/host/packages.rb +27 -30
  48. data/acceptance/tests/base/host/packages_unix.rb +0 -55
  49. data/acceptance/tests/base/host/user_test.rb +2 -3
  50. data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
  51. data/acceptance/tests/base/test_suite/export.rb +6 -9
  52. data/acceptance/tests/install/from_file.rb +3 -5
  53. data/acceptance/tests/load_path_bootstrap.rb +1 -1
  54. data/acceptance/tests/subcommands/destroy.rb +19 -21
  55. data/acceptance/tests/subcommands/exec.rb +0 -1
  56. data/acceptance/tests/subcommands/init.rb +2 -3
  57. data/acceptance/tests/subcommands/provision.rb +0 -1
  58. data/beaker.gemspec +10 -14
  59. data/docs/concepts/argument_processing_and_precedence.md +1 -10
  60. data/docs/concepts/style_guide.md +1 -1
  61. data/docs/how_to/debug_beaker_tests.md +13 -13
  62. data/docs/how_to/hosts/eos.md +2 -12
  63. data/docs/how_to/install_puppet.md +0 -18
  64. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  65. data/docs/how_to/the_beaker_dsl.md +0 -2
  66. data/lib/beaker/cli.rb +63 -74
  67. data/lib/beaker/command.rb +22 -30
  68. data/lib/beaker/command_factory.rb +4 -3
  69. data/lib/beaker/dsl/assertions.rb +7 -19
  70. data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
  71. data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
  72. data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
  73. data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
  74. data/lib/beaker/dsl/helpers.rb +2 -4
  75. data/lib/beaker/dsl/outcomes.rb +17 -19
  76. data/lib/beaker/dsl/patterns.rb +1 -3
  77. data/lib/beaker/dsl/roles.rb +18 -21
  78. data/lib/beaker/dsl/structure.rb +55 -67
  79. data/lib/beaker/dsl/test_tagging.rb +7 -10
  80. data/lib/beaker/dsl/wrappers.rb +15 -16
  81. data/lib/beaker/dsl.rb +2 -3
  82. data/lib/beaker/host/aix/exec.rb +1 -1
  83. data/lib/beaker/host/aix/file.rb +0 -1
  84. data/lib/beaker/host/aix/group.rb +3 -3
  85. data/lib/beaker/host/aix/user.rb +3 -3
  86. data/lib/beaker/host/aix.rb +3 -4
  87. data/lib/beaker/host/cisco.rb +36 -48
  88. data/lib/beaker/host/eos.rb +4 -30
  89. data/lib/beaker/host/freebsd/exec.rb +1 -1
  90. data/lib/beaker/host/freebsd/pkg.rb +3 -3
  91. data/lib/beaker/host/freebsd.rb +9 -12
  92. data/lib/beaker/host/mac/exec.rb +5 -5
  93. data/lib/beaker/host/mac/group.rb +13 -13
  94. data/lib/beaker/host/mac/pkg.rb +6 -109
  95. data/lib/beaker/host/mac/user.rb +7 -7
  96. data/lib/beaker/host/mac.rb +8 -9
  97. data/lib/beaker/host/pswindows/exec.rb +70 -74
  98. data/lib/beaker/host/pswindows/file.rb +4 -6
  99. data/lib/beaker/host/pswindows/group.rb +5 -5
  100. data/lib/beaker/host/pswindows/pkg.rb +17 -17
  101. data/lib/beaker/host/pswindows/user.rb +4 -4
  102. data/lib/beaker/host/pswindows.rb +4 -3
  103. data/lib/beaker/host/unix/exec.rb +86 -88
  104. data/lib/beaker/host/unix/file.rb +41 -47
  105. data/lib/beaker/host/unix/group.rb +3 -3
  106. data/lib/beaker/host/unix/pkg.rb +158 -421
  107. data/lib/beaker/host/unix/user.rb +4 -4
  108. data/lib/beaker/host/unix.rb +18 -20
  109. data/lib/beaker/host/windows/exec.rb +20 -20
  110. data/lib/beaker/host/windows/file.rb +5 -5
  111. data/lib/beaker/host/windows/group.rb +5 -5
  112. data/lib/beaker/host/windows/pkg.rb +6 -57
  113. data/lib/beaker/host/windows/user.rb +4 -4
  114. data/lib/beaker/host/windows.rb +13 -13
  115. data/lib/beaker/host.rb +82 -139
  116. data/lib/beaker/host_prebuilt_steps.rb +121 -233
  117. data/lib/beaker/hypervisor/noop.rb +2 -4
  118. data/lib/beaker/hypervisor.rb +46 -63
  119. data/lib/beaker/local_connection.rb +4 -6
  120. data/lib/beaker/logger.rb +71 -85
  121. data/lib/beaker/logger_junit.rb +22 -26
  122. data/lib/beaker/network_manager.rb +40 -43
  123. data/lib/beaker/options/command_line_parser.rb +12 -23
  124. data/lib/beaker/options/hosts_file_parser.rb +34 -25
  125. data/lib/beaker/options/options_file_parser.rb +3 -6
  126. data/lib/beaker/options/options_hash.rb +3 -10
  127. data/lib/beaker/options/parser.rb +89 -105
  128. data/lib/beaker/options/presets.rb +114 -123
  129. data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
  130. data/lib/beaker/options/validator.rb +26 -31
  131. data/lib/beaker/perf.rb +29 -34
  132. data/lib/beaker/platform.rb +38 -46
  133. data/lib/beaker/result.rb +7 -6
  134. data/lib/beaker/shared/error_handler.rb +8 -10
  135. data/lib/beaker/shared/fog_credentials.rb +5 -9
  136. data/lib/beaker/shared/host_manager.rb +40 -46
  137. data/lib/beaker/shared/options_resolver.rb +3 -7
  138. data/lib/beaker/shared/repetition.rb +6 -8
  139. data/lib/beaker/shared/semvar.rb +39 -43
  140. data/lib/beaker/shared/timed.rb +2 -5
  141. data/lib/beaker/shared.rb +1 -1
  142. data/lib/beaker/ssh_connection.rb +46 -55
  143. data/lib/beaker/subcommand.rb +23 -30
  144. data/lib/beaker/subcommands/subcommand_util.rb +4 -4
  145. data/lib/beaker/tasks/quick_start.rb +5 -10
  146. data/lib/beaker/tasks/rake_task.rb +26 -28
  147. data/lib/beaker/tasks/test.rb +4 -4
  148. data/lib/beaker/test_case.rb +15 -27
  149. data/lib/beaker/test_suite.rb +35 -39
  150. data/lib/beaker/test_suite_result.rb +52 -57
  151. data/lib/beaker/version.rb +1 -1
  152. data/lib/beaker.rb +5 -6
  153. data/spec/beaker/cli_spec.rb +135 -153
  154. data/spec/beaker/command_spec.rb +64 -58
  155. data/spec/beaker/dsl/assertions_spec.rb +38 -47
  156. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
  157. data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
  158. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
  159. data/spec/beaker/dsl/outcomes_spec.rb +15 -14
  160. data/spec/beaker/dsl/roles_spec.rb +170 -132
  161. data/spec/beaker/dsl/structure_spec.rb +181 -163
  162. data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
  163. data/spec/beaker/dsl/wrappers_spec.rb +39 -40
  164. data/spec/beaker/host/aix_spec.rb +14 -14
  165. data/spec/beaker/host/cisco_spec.rb +92 -102
  166. data/spec/beaker/host/eos_spec.rb +15 -36
  167. data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
  168. data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
  169. data/spec/beaker/host/mac/exec_spec.rb +4 -5
  170. data/spec/beaker/host/mac/group_spec.rb +47 -56
  171. data/spec/beaker/host/mac/user_spec.rb +53 -62
  172. data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
  173. data/spec/beaker/host/pswindows/file_spec.rb +21 -18
  174. data/spec/beaker/host/pswindows/user_spec.rb +17 -23
  175. data/spec/beaker/host/pswindows_spec.rb +14 -14
  176. data/spec/beaker/host/unix/exec_spec.rb +87 -92
  177. data/spec/beaker/host/unix/file_spec.rb +76 -82
  178. data/spec/beaker/host/unix/pkg_spec.rb +165 -407
  179. data/spec/beaker/host/unix_spec.rb +11 -207
  180. data/spec/beaker/host/windows/exec_spec.rb +32 -34
  181. data/spec/beaker/host/windows/file_spec.rb +22 -23
  182. data/spec/beaker/host/windows/group_spec.rb +17 -19
  183. data/spec/beaker/host/windows/pkg_spec.rb +10 -13
  184. data/spec/beaker/host/windows/user_spec.rb +17 -23
  185. data/spec/beaker/host/windows_spec.rb +39 -39
  186. data/spec/beaker/host_prebuilt_steps_spec.rb +193 -341
  187. data/spec/beaker/host_spec.rb +241 -312
  188. data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
  189. data/spec/beaker/localhost_connection_spec.rb +14 -13
  190. data/spec/beaker/logger_junit_spec.rb +22 -34
  191. data/spec/beaker/logger_spec.rb +174 -155
  192. data/spec/beaker/network_manager_spec.rb +27 -27
  193. data/spec/beaker/options/command_line_parser_spec.rb +20 -23
  194. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  195. data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
  196. data/spec/beaker/options/options_file_parser_spec.rb +4 -7
  197. data/spec/beaker/options/options_hash_spec.rb +7 -9
  198. data/spec/beaker/options/parser_spec.rb +187 -187
  199. data/spec/beaker/options/presets_spec.rb +8 -10
  200. data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
  201. data/spec/beaker/options/validator_spec.rb +27 -28
  202. data/spec/beaker/perf_spec.rb +32 -34
  203. data/spec/beaker/platform_spec.rb +27 -37
  204. data/spec/beaker/shared/error_handler_spec.rb +8 -17
  205. data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
  206. data/spec/beaker/shared/host_manager_spec.rb +55 -89
  207. data/spec/beaker/shared/options_resolver_spec.rb +9 -12
  208. data/spec/beaker/shared/repetition_spec.rb +24 -31
  209. data/spec/beaker/shared/semvar_spec.rb +21 -26
  210. data/spec/beaker/ssh_connection_spec.rb +85 -90
  211. data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
  212. data/spec/beaker/subcommand_spec.rb +89 -89
  213. data/spec/beaker/test_case_spec.rb +33 -62
  214. data/spec/beaker/test_suite_spec.rb +153 -160
  215. data/spec/helpers.rb +48 -53
  216. data/spec/matchers.rb +9 -8
  217. data/spec/mocks.rb +6 -11
  218. data/spec/spec_helper.rb +0 -4
  219. metadata +60 -85
  220. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
  221. data/acceptance/tests/base/external_resources_test.rb +0 -31
  222. data/spec/beaker/host/mac_spec.rb +0 -113
  223. data/spec/mock_fission.rb +0 -60
  224. data/spec/mock_vsphere.rb +0 -314
  225. data/spec/mock_vsphere_helper.rb +0 -183
@@ -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 e.message =~ /^No\ suitable\ hosts\ found/
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
@@ -15,16 +14,13 @@ test_name "dsl::structure" do
15
14
 
16
15
  step "#confine_block leaves hosts array intact after running block on matching hosts" do
17
16
  begin
18
- previous_hosts = hosts.dup
19
-
20
17
  @in_confine = 0
21
18
  confine_block :to, :platform => default["platform"] do
22
- @in_confine +=1
19
+ @in_confine += 1
23
20
  end
24
21
 
25
22
  assert_equal 1, @in_confine, "#confine_block did not run the supplied block"
26
23
  assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
27
-
28
24
  rescue Beaker::DSL::Outcomes::SkipTest => e
29
25
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
30
26
  end
@@ -34,11 +30,10 @@ test_name "dsl::structure" do
34
30
  begin
35
31
  @in_confine = 0
36
32
  confine_block :except, :platform => default["platform"] do
37
- @in_confine +=1
33
+ @in_confine += 1
38
34
  end
39
35
 
40
36
  assert_equal 0, @in_confine, "#confine_block did not skip the supplied block"
41
-
42
37
  rescue Beaker::DSL::Outcomes::SkipTest => e
43
38
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
44
39
  end
@@ -46,32 +41,27 @@ test_name "dsl::structure" do
46
41
 
47
42
  step "#confine_block leaves hosts array intact after skipping block on non-matching hosts" do
48
43
  begin
49
- previous_hosts = hosts.dup
50
-
51
44
  @in_confine = 0
52
45
  confine_block :except, :platform => default["platform"] do
53
- @in_confine +=1
46
+ @in_confine += 1
54
47
  end
55
48
 
56
49
  assert_equal 0, @in_confine, "#confine_block did not skip the supplied block"
57
50
  assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
58
-
59
51
  rescue Beaker::DSL::Outcomes::SkipTest => e
60
52
  fail "#confine_block raised unexpected SkipTest exception: #{e}"
61
53
  end
62
54
  end
63
55
 
64
56
  step "#confine_block allows blocks to raise skip_test" do
65
- previous_hosts = hosts.dup
66
-
67
57
  begin
68
58
  @in_confine = 0
69
59
  confine_block :to, :platform => default["platform"] do
70
- @in_confine +=1
60
+ @in_confine += 1
71
61
  skip_test "this block raises a skip"
72
62
  end
73
63
  rescue Beaker::DSL::Outcomes::SkipTest => e
74
- assert_match /this block raises a skip/, e.message, "#confine_block raised an unexpected skip_test"
64
+ assert_match(/this block raises a skip/, e.message, "#confine_block raised an unexpected skip_test")
75
65
  assert_equal 1, @in_confine, "#confine_block did not execute supplied block"
76
66
  assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
77
67
  end
@@ -82,9 +72,8 @@ test_name "dsl::structure" do
82
72
  confine :to, { :platform => 'test' }
83
73
 
84
74
  fail "#confine did not skip test but should have."
85
-
86
75
  rescue Beaker::DSL::Outcomes::SkipTest => e
87
- assert_match /No suitable hosts found with {:platform=>"test"}/, e.message, "#confine raised an unexpected skip_test"
76
+ assert_match(/No suitable hosts found with {:platform=>"test"}/, e.message, "#confine raised an unexpected skip_test")
88
77
  end
89
78
  end
90
79
 
@@ -93,10 +82,9 @@ test_name "dsl::structure" do
93
82
  confine :except, { :platform => default['platform'] }
94
83
 
95
84
  fail "#confine did not skip test but should have."
96
-
97
85
  rescue Beaker::DSL::Outcomes::SkipTest => e
98
- assert_match /No suitable hosts found without {:platform=>"#{default['platform']}"}/, e.message, "#confine raised an unexpected
99
- # skip_test"
86
+ assert_match(/No suitable hosts found without {:platform=>"#{default['platform']}"}/, e.message, "#confine raised an unexpected
87
+ # skip_test")
100
88
  end
101
89
  end
102
90
  end
@@ -11,7 +11,7 @@ test_name 'File Test' do
11
11
  tmpfile = host.tmpfile('beaker')
12
12
  # ensure we have a user to chown to
13
13
  host.chown('testuser', tmpfile)
14
- assert_match /testuser/, host.ls_ld(tmpfile), "Should have found testuser in `ls -ld` output"
14
+ assert_match(/testuser/, host.ls_ld(tmpfile), "Should have found testuser in `ls -ld` output")
15
15
  end
16
16
  end
17
17
 
@@ -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
 
@@ -31,7 +31,7 @@ test_name 'File Test' do
31
31
  tmpdir = host.tmpdir('beaker')
32
32
  on host, host.touch("#{tmpdir}/somefile.txt", false)
33
33
  host.chown('testuser', tmpdir, true)
34
- assert_match /testuser/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testuser in `ls -ld` output for sub-file"
34
+ assert_match(/testuser/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testuser in `ls -ld` output for sub-file")
35
35
  end
36
36
  end
37
37
 
@@ -41,7 +41,7 @@ test_name 'File Test' do
41
41
  tmpfile = host.tmpfile('beaker')
42
42
  # ensure we have a group to chgrp to
43
43
  host.chgrp('testgroup', tmpfile)
44
- assert_match /testgroup/, host.ls_ld(tmpfile), "Should have found testgroup in `ls -ld` output"
44
+ assert_match(/testgroup/, host.ls_ld(tmpfile), "Should have found testgroup in `ls -ld` output")
45
45
  end
46
46
  end
47
47
 
@@ -51,7 +51,7 @@ test_name 'File Test' do
51
51
  tmpdir = host.tmpdir('beaker')
52
52
  # ensure we have a group to chgrp to
53
53
  host.chgrp('testgroup', tmpdir)
54
- assert_match /testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output"
54
+ assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output")
55
55
  end
56
56
  end
57
57
 
@@ -61,7 +61,7 @@ test_name 'File Test' do
61
61
  tmpdir = host.tmpdir('beaker')
62
62
  on host, host.touch("#{tmpdir}/somefile.txt", false)
63
63
  host.chgrp('testgroup', tmpdir, true)
64
- assert_match /testgroup/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testgroup in `ls -ld` output for sub-file"
64
+ assert_match(/testgroup/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testgroup in `ls -ld` output for sub-file")
65
65
  end
66
66
  end
67
67
 
@@ -69,7 +69,7 @@ test_name 'File Test' do
69
69
  hosts.each do |host|
70
70
  # create a tmp file to mangle
71
71
  tmpdir = host.tmpdir('beaker')
72
- assert_match /beaker/, host.ls_ld(tmpdir), "Should have found beaker in `ls -ld` output"
72
+ assert_match(/beaker/, host.ls_ld(tmpdir), "Should have found beaker in `ls -ld` output")
73
73
  end
74
74
  end
75
75
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  test_name 'Group Test' do
2
2
  step "#group_get: has an Administrators group on Windows" do
3
- hosts.select { |h| h['platform'] =~ /windows/ }.each do |host|
3
+ hosts.select { |h| h['platform'].include?('windows') }.each do |host|
4
4
  host.group_get('Administrators') do |result|
5
5
  refute_match(result.stdout, '1376', 'Output indicates Administrators not found')
6
6
  end
@@ -8,11 +8,10 @@ test_name 'Group Test' do
8
8
  end
9
9
 
10
10
  step "#group_get: should not have CroMags group on Windows" do
11
- hosts.select { |h| h['platform'] =~ /windows/ }.each do |host|
11
+ hosts.select { |h| h['platform'].include?('windows') }.each do |host|
12
12
  assert_raises Beaker::Host::CommandFailure do
13
13
  host.group_get('CroMags') { |result| }
14
14
  end
15
15
  end
16
16
  end
17
-
18
17
  end
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  step "#is_x86_64? : can determine arch on hosts"
22
22
  hosts.each do |host|
23
- if host['platform'] =~ /x86_64|_64|amd64|-64/
23
+ if /x86_64|_64|amd64|-64/.match?(host['platform'])
24
24
  assert_equal(true, host.is_x86_64?, "is_x86_64? should be true on #{host}: #{host['platform']}")
25
25
  else
26
26
  assert_equal(false, host.is_x86_64?, "is_x86_64? should be false on #{host}: #{host['platform']}")
@@ -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| check =~ /#{Regexp.escape(search_name)}$/ }
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,25 +226,25 @@ 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| check =~ /#{Regexp.escape(search_name)}$/ }
242
- re = /((\/|\A)tests(\/|\z))|((\/|\A)Gemfile(\/|\z))/
243
- if path !~ re
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))/
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
246
250
  assert_equal(0, matched.length, "should have found no instances of path #{search_name}, found #{matched.length}: \n #{matched}")
@@ -252,25 +256,26 @@ 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))/
273
- if path.gsub(/^.*module\//, '') !~ re
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))/
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
276
281
  assert_equal(0, matched.length, "should have found no instances of path #{search_name}, found #{matched.length}: \n #{matched}")
@@ -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
-
@@ -2,29 +2,26 @@ test_name 'confirm packages on hosts behave correctly'
2
2
  confine :except, :platform => %w(osx)
3
3
 
4
4
  def get_host_pkg(host)
5
- case
6
- when host['platform'] =~ /sles-10/
7
- Beaker::HostPrebuiltSteps::SLES10_PACKAGES
8
- when host['platform'] =~ /opensuse|sles-/
9
- Beaker::HostPrebuiltSteps::SLES_PACKAGES
10
- when host['platform'] =~ /debian/
11
- Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES
12
- when host['platform'] =~ /cumulus/
13
- Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES
14
- when (host['platform'] =~ /windows/ and host.is_cygwin?)
15
- Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES
16
- when (host['platform'] =~ /windows/ and not host.is_cygwin?)
17
- Beaker::HostPrebuiltSteps::PSWINDOWS_PACKAGES
18
- when host['platform'] =~ /freebsd/
19
- Beaker::HostPrebuiltSteps::FREEBSD_PACKAGES
20
- when host['platform'] =~ /openbsd/
21
- Beaker::HostPrebuiltSteps::OPENBSD_PACKAGES
22
- when host['platform'] =~ /solaris-10/
23
- Beaker::HostPrebuiltSteps::SOLARIS10_PACKAGES
24
- else
25
- Beaker::HostPrebuiltSteps::UNIX_PACKAGES
5
+ case host['platform']
6
+ when /sles-10/
7
+ Beaker::HostPrebuiltSteps::SLES10_PACKAGES
8
+ when /opensuse|sles-/
9
+ Beaker::HostPrebuiltSteps::SLES_PACKAGES
10
+ when /debian/
11
+ Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES
12
+ when /cumulus/
13
+ Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES
14
+ when /windows/
15
+ host.is_cygwin? ? Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES : Beaker::HostPrebuiltSteps::PSWINDOWS_PACKAGES
16
+ when /freebsd/
17
+ Beaker::HostPrebuiltSteps::FREEBSD_PACKAGES
18
+ when /openbsd/
19
+ Beaker::HostPrebuiltSteps::OPENBSD_PACKAGES
20
+ when /solaris-10/
21
+ Beaker::HostPrebuiltSteps::SOLARIS10_PACKAGES
22
+ else
23
+ Beaker::HostPrebuiltSteps::UNIX_PACKAGES
26
24
  end
27
-
28
25
  end
29
26
 
30
27
  step '#check_for_command : can determine where a command exists'
@@ -50,12 +47,13 @@ hosts.each do |host|
50
47
  # this works on Windows as well, althought it pulls in
51
48
  # a lot of dependencies.
52
49
  # skipping this test for windows since it requires a restart
53
- next if host['platform'] =~ /windows/
50
+ next if host['platform'].include?('windows')
51
+
54
52
  package = 'zsh'
55
- package = 'CSWzsh' if host['platform'] =~ /solaris-10/
56
- package = 'git' if host['platform'] =~ /opensuse|sles/
53
+ package = 'CSWzsh' if host['platform'].include?('solaris-10')
54
+ package = 'git' if /opensuse|sles/.match?(host['platform'])
57
55
 
58
- if host['platform'] =~ /solaris-11/
56
+ if host['platform'].include?('solaris-11')
59
57
  logger.debug("#{package} should be uninstalled on #{host}")
60
58
  host.uninstall_package(package)
61
59
  assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
@@ -66,19 +64,18 @@ hosts.each do |host|
66
64
  cmdline_args = ''
67
65
  # Newer vmpooler hosts created by Packer templates, and running Cygwin 2.4,
68
66
  # must have these switches passed
69
- cmdline_args = '--local-install --download' if (host['platform'] =~ /windows/ and host.is_cygwin?)
67
+ cmdline_args = '--local-install --download' if (host['platform'].include?('windows') and host.is_cygwin?)
70
68
  host.install_package(package, cmdline_args)
71
69
  assert(host.check_for_package(package), "'#{package}' should be installed")
72
70
 
73
71
  # windows does not support uninstall_package
74
- unless host['platform'] =~ /windows/
72
+ unless host['platform'].include?('windows')
75
73
  logger.debug("#{package} should be uninstalled on #{host}")
76
74
  host.uninstall_package(package)
77
- if host['platform'] =~ /debian/
75
+ if host['platform'].include?('debian')
78
76
  assert_equal(false, host.check_for_command(package), "'#{package}' should not be installed or available")
79
77
  else
80
78
  assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
81
79
  end
82
80
  end
83
-
84
81
  end