beaker 4.40.1 → 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 +13 -11
  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 +4 -3
  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 +15 -27
  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 +5 -6
  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 +169 -158
  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 +47 -56
  167. data/spec/beaker/host/mac/user_spec.rb +53 -62
  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
@@ -1,11 +1,11 @@
1
1
  module Unix::User
2
2
  include Beaker::CommandFactory
3
3
 
4
- def user_list()
4
+ def user_list
5
5
  execute("getent passwd") do |result|
6
6
  users = []
7
7
  result.stdout.each_line do |line|
8
- users << (line.match( /^([^:]+)/) or next)[1]
8
+ users << (line.match(/^([^:]+)/) or next)[1]
9
9
  end
10
10
 
11
11
  yield result if block_given?
@@ -1,11 +1,11 @@
1
- [ 'host', 'command_factory', 'command', 'options' ].each do |lib|
2
- require "beaker/#{lib}"
1
+ %w[host command_factory command options].each do |lib|
2
+ require "beaker/#{lib}"
3
3
  end
4
4
 
5
5
  module Unix
6
6
  class Host < Beaker::Host
7
- [ 'user', 'group', 'exec', 'pkg', 'file' ].each do |lib|
8
- require "beaker/host/unix/#{lib}"
7
+ %w[user group exec pkg file].each do |lib|
8
+ require "beaker/host/unix/#{lib}"
9
9
  end
10
10
 
11
11
  include Unix::User
@@ -17,10 +17,10 @@ module Unix
17
17
  def platform_defaults
18
18
  h = Beaker::Options::OptionsHash.new
19
19
  h.merge({
20
- 'user' => 'root',
21
- 'group' => 'root',
22
- 'pathseparator' => ':',
23
- })
20
+ 'user' => 'root',
21
+ 'group' => 'root',
22
+ 'pathseparator' => ':',
23
+ })
24
24
  end
25
25
 
26
26
  # Determines which SSH Server is in use on this host
@@ -54,8 +54,6 @@ module Unix
54
54
  case self['platform'].variant
55
55
  when /^(f5|netscaler)$/
56
56
  "no puppet-agent package for network device platform '#{self['platform'].variant}'"
57
- else
58
- nil
59
57
  end
60
58
  end
61
59
 
@@ -73,6 +71,5 @@ module Unix
73
71
 
74
72
  @external_copy_base = nil
75
73
  end
76
-
77
74
  end
78
75
  end
@@ -11,11 +11,11 @@ module Windows::Exec
11
11
  ABS_CMD = 'c:\\\\windows\\\\system32\\\\cmd.exe'
12
12
  CMD = 'cmd.exe'
13
13
 
14
- def echo(msg, abs=true)
14
+ def echo(msg, abs = true)
15
15
  (abs ? ABS_CMD : CMD) + " /c echo #{msg}"
16
16
  end
17
17
 
18
- def touch(file, abs=true)
18
+ def touch(file, abs = true)
19
19
  (abs ? ABS_CMD : CMD) + " /c echo. 2> #{file}"
20
20
  end
21
21
 
@@ -35,8 +35,10 @@ module Windows::Exec
35
35
  ips.each_line do |line|
36
36
  matches = line.split('=')
37
37
  next if matches.length <= 1
38
+
38
39
  matches = matches[1].match(/^{"(.*?)"/)
39
40
  next if matches.nil? || matches.captures.nil? || matches.captures.empty?
41
+
40
42
  ip = matches.captures[0] if matches && matches.captures
41
43
  break if ip != ''
42
44
  end
@@ -48,14 +50,13 @@ module Windows::Exec
48
50
  # @param [String] target The hostname to ping
49
51
  # @param [Integer] attempts Amount of times to attempt ping before giving up
50
52
  # @return [Boolean] true of ping successful, overwise false
51
- def ping target, attempts=5
53
+ def ping target, attempts = 5
52
54
  try = 0
53
- while try < attempts do
55
+ while try < attempts
54
56
  result = exec(Beaker::Command.new("ping -n 1 #{target}"), :accept_all_exit_codes => true)
55
- if result.exit_code == 0
56
- return true
57
- end
58
- try+=1
57
+ return true if result.exit_code == 0
58
+
59
+ try += 1
59
60
  end
60
61
  result.exit_code == 0
61
62
  end
@@ -67,10 +68,10 @@ module Windows::Exec
67
68
  command_result = nil
68
69
  # we get periodic failures to restart the service, so looping these with re-attempts
69
70
  repeat_fibonacci_style_for(5) do
70
- 0 == exec(Beaker::Command.new("cygrunsrv -E sshd"), :acceptable_exit_codes => [0, 1] ).exit_code
71
+ 0 == exec(Beaker::Command.new("cygrunsrv -E sshd"), :acceptable_exit_codes => [0, 1]).exit_code
71
72
  end
72
73
  repeat_fibonacci_style_for(5) do
73
- command_result = exec(Beaker::Command.new("cygrunsrv -S sshd"), :acceptable_exit_codes => [0, 1] )
74
+ command_result = exec(Beaker::Command.new("cygrunsrv -S sshd"), :acceptable_exit_codes => [0, 1])
74
75
  0 == command_result.exit_code
75
76
  end
76
77
  command_result
@@ -83,7 +84,7 @@ module Windows::Exec
83
84
  # (from {#ssh_service_restart}).
84
85
  def ssh_permit_user_environment
85
86
  exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> /etc/sshd_config"))
86
- ssh_service_restart()
87
+ ssh_service_restart
87
88
  end
88
89
 
89
90
  # Gets the specific prepend commands as needed for this host
@@ -96,7 +97,7 @@ module Windows::Exec
96
97
  # @return [String] Command string as needed for this host
97
98
  def prepend_commands(_command = '', user_pc = nil, opts = {})
98
99
  cygwin_prefix = (self.is_cygwin? and opts[:cmd_exe]) ? 'cmd.exe /c' : ''
99
- spacing = (user_pc && !cygwin_prefix.empty?) ? ' ' : ''
100
+ spacing = user_pc && !cygwin_prefix.empty? ? ' ' : ''
100
101
  "#{cygwin_prefix}#{spacing}#{user_pc}"
101
102
  end
102
103
 
@@ -111,11 +112,11 @@ module Windows::Exec
111
112
  user_ac
112
113
  end
113
114
 
114
- # Checks if selinux is enabled
115
+ #  Checks if selinux is enabled
115
116
  # selinux is not available on Windows
116
117
  #
117
118
  # @return [Boolean] false
118
- def selinux_enabled?()
119
+ def selinux_enabled?
119
120
  false
120
121
  end
121
122
 
@@ -138,12 +139,11 @@ module Windows::Exec
138
139
  # @param [String] orig The origin path
139
140
  # @param [String] dest the destination path
140
141
  # @param [Boolean] rm Remove the destination prior to move
141
- def mv orig, dest, rm=true
142
+ def mv orig, dest, rm = true
142
143
  rm_rf dest unless !rm
143
144
  execute("mv \"#{orig}\" \"#{dest}\"")
144
145
  end
145
146
 
146
-
147
147
  # Determine if cygwin is actually installed on the SUT. Differs from
148
148
  # is_cygwin?, which is just a type check for a Windows::Host.
149
149
  #
@@ -151,7 +151,7 @@ module Windows::Exec
151
151
  def cygwin_installed?
152
152
  output = exec(Beaker::Command.new('cygcheck --check-setup cygwin'), :accept_all_exit_codes => true).stdout
153
153
  return true if output.include?('cygwin') && output.include?('OK')
154
+
154
155
  false
155
156
  end
156
-
157
157
  end
@@ -20,7 +20,7 @@ module Windows::File
20
20
  # windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style.
21
21
  # This method simply wraps the normal Host#chown call with
22
22
  # a call to cygpath to sanitize input.
23
- def chown(user, path, recursive=false)
23
+ def chown(user, path, recursive = false)
24
24
  cygpath = execute("cygpath -u #{path}")
25
25
  super(user, cygpath, recursive)
26
26
  end
@@ -30,13 +30,13 @@ module Windows::File
30
30
  # windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style.
31
31
  # This method simply wraps the normal Host#chgrp call with
32
32
  # a call to cygpath to sanitize input.
33
- def chgrp(group, path, recursive=false)
33
+ def chgrp(group, path, recursive = false)
34
34
  cygpath = execute("cygpath -u #{path}")
35
35
  super(group, cygpath, recursive)
36
36
  end
37
37
 
38
38
  # Not needed on windows
39
- def chmod(mod, path, recursive=false); end
39
+ def chmod(mod, path, recursive = false); end
40
40
 
41
41
  # (see {Beaker::Host::Unix::File#ls_ld})
42
42
  # @note Cygwin's `ls_ld` implementation does not support
@@ -1,7 +1,7 @@
1
1
  module Windows::Group
2
2
  include Beaker::CommandFactory
3
3
 
4
- def group_list()
4
+ def group_list
5
5
  execute('cmd /c echo "" | wmic group where localaccount="true" get name /format:value') do |result|
6
6
  groups = []
7
7
  result.stdout.each_line do |line|
@@ -28,10 +28,10 @@ module Windows::Group
28
28
  end
29
29
 
30
30
  def group_present(name, &block)
31
- execute("net localgroup /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
31
+ execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
32
32
  end
33
33
 
34
34
  def group_absent(name, &block)
35
- execute("net localgroup /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
35
+ execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
36
36
  end
37
37
  end
@@ -17,7 +17,7 @@ module Windows::Pkg
17
17
  if arch == '64'
18
18
  rootdir = "c:\\\\cygwin64"
19
19
  cygwin = "setup-x86_64.exe"
20
- else #32 bit version
20
+ else # 32 bit version
21
21
  rootdir = "c:\\\\cygwin"
22
22
  cygwin = "setup-x86.exe"
23
23
  end
@@ -29,67 +29,16 @@ module Windows::Pkg
29
29
  raise "Package #{name} cannot be uninstalled on #{self}"
30
30
  end
31
31
 
32
- #Examine the host system to determine the architecture, overrides default host determine_if_x86_64 so that wmic is used
33
- #@return [Boolean] true if x86_64, false otherwise
32
+ # Examine the host system to determine the architecture, overrides default host determine_if_x86_64 so that wmic is used
33
+ # @return [Boolean] true if x86_64, false otherwise
34
34
  def determine_if_x86_64
35
35
  identify_windows_architecture.include?('64')
36
36
  end
37
37
 
38
- # Gets the path & file name for the puppet agent dev package on Windows
39
- #
40
- # @param [String] puppet_collection Name of the puppet collection to use
41
- # @param [String] puppet_agent_version Version of puppet agent to get
42
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
43
- #
44
- # @note Windows only uses the 'install_32' option of the opts hash at this
45
- # time. Note that it will not fail if not provided, however
46
- #
47
- # @return [String, String] Path to the directory and filename of the package, respectively
48
- def puppet_agent_dev_package_info( _puppet_collection = nil, puppet_agent_version = nil, opts = {} )
49
- release_path_end = 'windows'
50
- is_config_32 = self['ruby_arch'] == 'x86' || self['install_32'] || opts['install_32']
51
- should_install_64bit = self.is_x86_64? && !is_config_32
52
- # only install 64bit builds if
53
- # - we do not have install_32 set on host
54
- # - we do not have install_32 set globally
55
- arch_suffix = should_install_64bit ? '64' : '86'
56
- # If a version was specified, use it; otherwise fall back to a default name.
57
- # Avoid when puppet_agent_version is set to a SHA, which isn't used in package names.
58
- if /^\d+\.\d+\.\d+/.match?(puppet_agent_version)
59
- release_file = "puppet-agent-#{puppet_agent_version}-x#{arch_suffix}.msi"
60
- else
61
- release_file = "puppet-agent-x#{arch_suffix}.msi"
62
- end
63
- return release_path_end, release_file
64
- end
65
-
66
- # Gets host-specific information for PE promoted puppet-agent packages
67
- #
68
- # @param [String] puppet_collection Name of the puppet collection to use
69
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
70
- #
71
- # @return [String, String, String] Host-specific information for packages
72
- # 1. release_path_end Suffix for the release_path
73
- # 2. release_file Path to the file on release build servers
74
- # 3. download_file Filename for the package itself
75
- def pe_puppet_agent_promoted_package_info( _puppet_collection = nil, _opts = {} )
76
- is_config_32 = self['ruby_arch'] == 'x86' || self['install_32'] || self['install_32']
77
- should_install_64bit = self.is_x86_64? && !is_config_32
78
- # only install 64bit builds if
79
- # - we do not have install_32 set on host
80
- # - we do not have install_32 set globally
81
- arch_suffix = should_install_64bit ? '64' : '86'
82
- release_path_end = "/windows"
83
- release_file = "/puppet-agent-x#{arch_suffix}.msi"
84
- download_file = "puppet-agent-x#{arch_suffix}.msi"
85
- return release_path_end, release_file, download_file
86
- end
87
-
88
38
  private
89
39
 
90
40
  # @api private
91
41
  def identify_windows_architecture
92
42
  platform.arch.include?('64') ? '64' : '32'
93
43
  end
94
-
95
44
  end
@@ -1,7 +1,7 @@
1
1
  module Windows::User
2
2
  include Beaker::CommandFactory
3
3
 
4
- def user_list()
4
+ def user_list
5
5
  execute('cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value') do |result|
6
6
  users = []
7
7
  result.stdout.each_line do |line|
@@ -24,10 +24,10 @@ module Windows::User
24
24
  end
25
25
 
26
26
  def user_present(name, &block)
27
- execute("net user /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
27
+ execute("net user /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
28
28
  end
29
29
 
30
30
  def user_absent(name, &block)
31
- execute("net user /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block)
31
+ execute("net user /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
32
32
  end
33
33
  end
@@ -1,12 +1,12 @@
1
- [ 'host', 'command_factory', 'command', 'options' ].each do |lib|
2
- require "beaker/#{lib}"
1
+ %w[host command_factory command options].each do |lib|
2
+ require "beaker/#{lib}"
3
3
  end
4
4
 
5
5
  module Windows
6
6
  # A windows host with cygwin tools installed
7
7
  class Host < Unix::Host
8
- [ 'user', 'group', 'exec', 'pkg', 'file' ].each do |lib|
9
- require "beaker/host/windows/#{lib}"
8
+ %w[user group exec pkg file].each do |lib|
9
+ require "beaker/host/windows/#{lib}"
10
10
  end
11
11
 
12
12
  include Windows::User
@@ -18,14 +18,15 @@ module Windows
18
18
  def platform_defaults
19
19
  h = Beaker::Options::OptionsHash.new
20
20
  h.merge({
21
- 'user' => 'Administrator',
22
- 'group' => 'Administrators',
23
- 'pathseparator' => ';',
24
- })
21
+ 'user' => 'Administrator',
22
+ 'group' => 'Administrators',
23
+ 'pathseparator' => ';',
24
+ })
25
25
  end
26
26
 
27
27
  def external_copy_base
28
28
  return @external_copy_base if @external_copy_base
29
+
29
30
  @external_copy_base = execute('echo `cygpath -smF 35`/')
30
31
  @external_copy_base
31
32
  end
@@ -36,20 +37,20 @@ module Windows
36
37
  # (:bitvise or :openssh at this point).
37
38
  def determine_ssh_server
38
39
  return @ssh_server if @ssh_server
40
+
39
41
  @ssh_server = :openssh
40
42
  status = execute('cmd.exe /c sc query BvSshServer', :accept_all_exit_codes => true)
41
43
  if status&.include?('4 RUNNING')
42
44
  @ssh_server = :bitvise
43
45
  else
44
46
  status = execute('cmd.exe /c sc qc sshd', :accept_all_exit_codes => true)
45
- if status&.include?('C:\\Windows\\System32\\OpenSSH\\sshd.exe')
46
- @ssh_server = :win32_openssh
47
- end
47
+ @ssh_server = :win32_openssh if status&.include?('C:\\Windows\\System32\\OpenSSH\\sshd.exe')
48
48
  end
49
49
  @ssh_server
50
50
  end
51
51
 
52
52
  attr_reader :scp_separator
53
+
53
54
  def initialize name, host_hash, options
54
55
  super
55
56
 
@@ -57,6 +58,5 @@ module Windows
57
58
  @scp_separator = '\\'
58
59
  @external_copy_base = nil
59
60
  end
60
-
61
61
  end
62
62
  end