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
@@ -1,10 +1,9 @@
1
- [ 'host', 'command_factory' ].each do |lib|
1
+ %w[host command_factory].each do |lib|
2
2
  require "beaker/#{lib}"
3
3
  end
4
4
 
5
5
  module Cisco
6
6
  class Host < Unix::Host
7
-
8
7
  # as the cisco hosts tend to have custom
9
8
  # ssh configuration, the presets
10
9
  # do not apply where verification of the
@@ -12,10 +11,10 @@ module Cisco
12
11
  def platform_defaults
13
12
  h = Beaker::Options::OptionsHash.new
14
13
  h.merge({
15
- 'ssh' => {
16
- :verify_host_key => false,
17
- },
18
- })
14
+ 'ssh' => {
15
+ :verify_host_key => false,
16
+ },
17
+ })
19
18
  end
20
19
 
21
20
  # Tells you whether a host platform supports beaker's
@@ -34,9 +33,7 @@ module Cisco
34
33
  #
35
34
  # @return nil
36
35
  def scp_post_operations(scp_file_actual, scp_file_target)
37
- if self[:platform].include?('cisco_nexus')
38
- execute( "mv #{scp_file_actual} #{scp_file_target}" )
39
- end
36
+ execute("mv #{scp_file_actual} #{scp_file_target}") if self[:platform].include?('cisco_nexus')
40
37
  nil
41
38
  end
42
39
 
@@ -48,8 +45,8 @@ module Cisco
48
45
  # constraints
49
46
  def scp_path(path)
50
47
  if self[:platform].include?('cisco_nexus')
51
- @home_dir ||= execute( 'pwd' )
52
- answer = "#{@home_dir}/#{File.basename( path )}"
48
+ @home_dir ||= execute('pwd')
49
+ answer = "#{@home_dir}/#{File.basename(path)}"
53
50
  answer << '/' if /\/$/.match?(path)
54
51
  return answer
55
52
  end
@@ -83,18 +80,15 @@ module Cisco
83
80
  # @return [String] Command string as needed for this host
84
81
  def prepend_commands(command = '', user_pc = '', _opts = {})
85
82
  return user_pc unless command.index('vsh').nil?
83
+
86
84
  if self[:platform].include?('cisco_nexus')
87
85
  return user_pc unless command.index('ntpdate').nil?
88
86
  end
89
87
 
90
88
  prepend_cmds = 'source /etc/profile;'
91
89
  prepend_cmds << " sudo -E sh -c \"" if self[:user] != 'root'
92
- if self[:vrf]
93
- prepend_cmds << "ip netns exec #{self[:vrf]} "
94
- end
95
- if user_pc && !user_pc.empty?
96
- prepend_cmds << "#{user_pc} "
97
- end
90
+ prepend_cmds << "ip netns exec #{self[:vrf]} " if self[:vrf]
91
+ prepend_cmds << "#{user_pc} " if user_pc && !user_pc.empty?
98
92
  prepend_cmds.strip
99
93
  end
100
94
 
@@ -106,7 +100,7 @@ module Cisco
106
100
  #
107
101
  # @return [String] Command string as needed for this host
108
102
  def append_commands(command = '', _user_ac = '', _opts = {})
109
- command.gsub('"') {'\\"'}
103
+ command.gsub('"') { '\\"' }
110
104
  # vsh commands, ntpdate or when user is root commands do not require an appended `"`
111
105
  return '"' unless /ntpdate|\/isan\/bin\/vsh/.match?(command) || self[:user] == 'root'
112
106
  end
@@ -125,14 +119,15 @@ module Cisco
125
119
  def environment_string env
126
120
  prestring = ''
127
121
  return prestring if env.empty?
128
- env_array = self.environment_variable_string_pair_array( env )
122
+
123
+ env_array = self.environment_variable_string_pair_array(env)
129
124
  environment_string = env_array.join(' ')
130
125
 
131
- if self[:platform].include?('cisco_nexus')
132
- prestring << " export"
133
- else
134
- prestring << " env"
135
- end
126
+ prestring << if self[:platform].include?('cisco_nexus')
127
+ " export"
128
+ else
129
+ " env"
130
+ end
136
131
  environment_string = "#{prestring} #{environment_string}"
137
132
  environment_string << ';' if prestring.include?('export')
138
133
  environment_string
@@ -146,26 +141,19 @@ module Cisco
146
141
  def validate_setup
147
142
  msg = nil
148
143
  if self[:platform].include?('cisco_nexus')
149
- if !self[:vrf]
150
- msg = 'Cisco Nexus hosts must be provided with a :vrf value.'
151
- end
152
- if !self[:user]
153
- msg = 'Cisco hosts must be provided with a :user value'
154
- end
144
+ msg = 'Cisco Nexus hosts must be provided with a :vrf value.' if !self[:vrf]
145
+ msg = 'Cisco hosts must be provided with a :user value' if !self[:user]
155
146
  end
156
147
  if self[:platform].include?('cisco_ios_xr')
157
- if !self[:user]
158
- msg = 'Cisco hosts must be provided with a :user value'
159
- end
148
+ msg = 'Cisco hosts must be provided with a :user value' if !self[:user]
160
149
  end
161
150
 
162
- if msg
163
- msg << <<-EOF
151
+ return unless msg
152
+
153
+ msg << <<-EOF
164
154
  Check https://github.com/puppetlabs/beaker/blob/master/docs/hosts/cisco.md for more info.'
165
- EOF
166
- raise ArgumentError, msg
167
- end
155
+ EOF
156
+ raise ArgumentError, msg
168
157
  end
169
-
170
158
  end
171
159
  end
@@ -1,34 +1,9 @@
1
- [ 'host', 'command_factory' ].each do |lib|
1
+ %w[host command_factory].each do |lib|
2
2
  require "beaker/#{lib}"
3
3
  end
4
4
 
5
5
  module Eos
6
6
  class Host < Unix::Host
7
-
8
- # Gets the path & file name for the puppet agent dev package on EOS
9
- #
10
- # @param [String] puppet_collection Name of the puppet collection to use
11
- # @param [String] puppet_agent_version Version of puppet agent to get
12
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
13
- #
14
- # @note EOS doesn't use any additional options at this time, but does require
15
- # both puppet_collection & puppet_agent_version, & will fail without them
16
- #
17
- # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
18
- # puppet_agent_version) is either not passed or set to nil
19
- #
20
- # @return [String, String] Path to the directory and filename of the package, respectively
21
- def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, _opts = {} )
22
- error_message = "Must provide %s argument to get puppet agent dev package information"
23
- raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
24
- raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
25
-
26
- variant, version, arch, _ = self['platform'].to_array
27
- release_path = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
28
- release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.swix"
29
- return release_path, release_file
30
- end
31
-
32
7
  # Copies a remote file to the host location specified
33
8
  #
34
9
  # @param [String] remote_url URL to the remote file
@@ -38,7 +13,7 @@ module Eos
38
13
  # about location, so that parameter is ignored
39
14
  #
40
15
  # @return [Result] The result of copying that file to the host
41
- def get_remote_file( remote_url, _host_directory = '' )
16
+ def get_remote_file(remote_url, _host_directory = '')
42
17
  commands = ['enable', "copy #{remote_url} extension:"]
43
18
  command = commands.join("\n")
44
19
  execute("Cli -c '#{command}'")
@@ -49,11 +24,10 @@ module Eos
49
24
  # @param [String] filename Name of the file to install, including file extension
50
25
  #
51
26
  # @return [Result] The result of running the install command on the host
52
- def install_from_file( filename )
27
+ def install_from_file(filename)
53
28
  commands = ['enable', "extension #{filename}"]
54
29
  command = commands.join("\n")
55
30
  execute("Cli -c '#{command}'")
56
31
  end
57
-
58
32
  end
59
- end
33
+ end
@@ -3,7 +3,7 @@ module FreeBSD::Exec
3
3
 
4
4
  def echo_to_file(str, filename)
5
5
  # FreeBSD gets weird about special characters, we have to go a little OTT here
6
- escaped_str = str.gsub(/\t/,'\\t').gsub(/\n/,'\\n')
6
+ escaped_str = str.gsub(/\t/, '\\t').gsub(/\n/, '\\n')
7
7
 
8
8
  exec(Beaker::Command.new("printf \"#{escaped_str}\" > #{filename}"))
9
9
  end
@@ -8,11 +8,11 @@ module FreeBSD::Pkg
8
8
 
9
9
  def check_pkgng_sh
10
10
  'TMPDIR=/dev/null ASSUME_ALWAYS_YES=1 PACKAGESITE=file:///nonexist ' \
11
- 'pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
11
+ 'pkg info -x "pkg(-devel)?\\$" > /dev/null 2>&1'
12
12
  end
13
13
 
14
14
  def pkgng_active?(opts = {})
15
- opts = {:accept_all_exit_codes => true}.merge(opts)
15
+ opts = { :accept_all_exit_codes => true }.merge(opts)
16
16
  execute("/bin/sh -c '#{check_pkgng_sh}'", opts) { |r| r }.exit_code == 0
17
17
  end
18
18
 
@@ -35,7 +35,7 @@ module FreeBSD::Pkg
35
35
  end
36
36
 
37
37
  def check_for_package(package, opts = {})
38
- opts = {:accept_all_exit_codes => true}.merge(opts)
38
+ opts = { :accept_all_exit_codes => true }.merge(opts)
39
39
  cmd = if pkgng_active?
40
40
  "pkg info #{package}"
41
41
  else
@@ -1,15 +1,14 @@
1
- [ 'host', 'command_factory' ].each do |lib|
1
+ %w[host command_factory].each do |lib|
2
2
  require "beaker/#{lib}"
3
3
  end
4
4
 
5
5
  module FreeBSD
6
6
  class Host < Unix::Host
7
-
8
- [
9
- 'exec',
10
- 'pkg',
7
+ %w[
8
+ exec
9
+ pkg
11
10
  ].each do |lib|
12
- require "beaker/host/freebsd/#{lib}"
11
+ require "beaker/host/freebsd/#{lib}"
13
12
  end
14
13
 
15
14
  include FreeBSD::Exec
@@ -18,12 +17,10 @@ module FreeBSD
18
17
  def platform_defaults
19
18
  h = Beaker::Options::OptionsHash.new
20
19
  h.merge({
21
- 'user' => 'root',
22
- 'group' => 'root',
23
- 'pathseparator' => ':',
24
- })
20
+ 'user' => 'root',
21
+ 'group' => 'root',
22
+ 'pathseparator' => ':',
23
+ })
25
24
  end
26
-
27
25
  end
28
-
29
26
  end
@@ -1,7 +1,7 @@
1
1
  module Mac::Exec
2
2
  include Beaker::CommandFactory
3
3
 
4
- def touch(file, abs=true)
4
+ def touch(file, abs = true)
5
5
  (abs ? '/usr/bin/touch' : 'touch') + " #{file}"
6
6
  end
7
7
 
@@ -24,14 +24,14 @@ module Mac::Exec
24
24
  ssh_config_file = '/private/etc/ssh/sshd_config' if /^osx-/.match?(self['platform'])
25
25
 
26
26
  exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> #{ssh_config_file}"))
27
- ssh_service_restart()
27
+ ssh_service_restart
28
28
  end
29
29
 
30
- # Checks if selinux is enabled
30
+ #  Checks if selinux is enabled
31
31
  # selinux is not availble on OS X
32
32
  #
33
33
  # @return [Boolean] false
34
- def selinux_enabled?()
34
+ def selinux_enabled?
35
35
  false
36
36
  end
37
37
 
@@ -6,7 +6,7 @@ module Mac::Group
6
6
  # @param [Proc] block Additional actions or insertions
7
7
  #
8
8
  # @return [Array<String>] The list of group names on the system
9
- def group_list()
9
+ def group_list
10
10
  execute('dscacheutil -q group') do |result|
11
11
  groups = []
12
12
  result.stdout.each_line do |line|
@@ -31,11 +31,11 @@ module Mac::Group
31
31
  def group_get(name)
32
32
  execute("dscacheutil -q group -a name #{name}") do |result|
33
33
  fail_test "failed to get group #{name}" unless /^name: #{name}/.match?(result.stdout)
34
- gi = Hash.new # group info
35
- result.stdout.each_line { |line|
34
+ gi = {} # group info
35
+ result.stdout.each_line do |line|
36
36
  pieces = line.split(': ')
37
37
  gi[pieces[0].to_sym] = pieces[1].strip if pieces[1] != nil
38
- }
38
+ end
39
39
  answer = "#{gi[:name]}:#{gi[:password]}:#{gi[:gid]}"
40
40
 
41
41
  yield answer if block_given?
@@ -51,12 +51,12 @@ module Mac::Group
51
51
  def group_gid(name)
52
52
  gid = -1
53
53
  execute("dscacheutil -q group -a name #{name}") do |result|
54
- result.stdout.each_line { |line|
54
+ result.stdout.each_line do |line|
55
55
  if /^gid:/.match?(line)
56
56
  gid = (line[5, line.length - 5]).chomp
57
57
  break
58
58
  end
59
- }
59
+ end
60
60
  gid
61
61
  end
62
62
  end
@@ -74,7 +74,7 @@ module Mac::Group
74
74
  return if group_exists
75
75
 
76
76
  gid = gid_next
77
- create_cmd = "dscl . create /Groups/#{name}"
77
+ create_cmd = "dscl . create /Groups/#{name}"
78
78
  create_cmd << " && dscl . create /Groups/#{name} PrimaryGroupID #{gid}"
79
79
  execute(create_cmd)
80
80
  end
@@ -38,116 +38,13 @@ module Mac::Pkg
38
38
  # @param [String] cmdline_args Additional command line arguments for
39
39
  # the package manager
40
40
  def upgrade_package(name, _cmdline_args = '')
41
- raise "Package #{name} cannot be upgraded on #{self}"
41
+ raise "Package #{name} cannot be upgraded on #{self}"
42
42
  end
43
43
 
44
- # Deploy configuration generated by the packaging tooling to this host.
45
- #
46
- # This method calls one of #deploy_apt_repo, #deploy_yum_repo, or
47
- # #deploy_zyp_repo depending on the platform of this Host.
48
- #
49
- # @note See {Beaker::DSL::Helpers::HostHelpers#deploy_package_repo} for info on
50
- # params
51
- def deploy_package_repo(_path, _name, _version)
52
- raise "Package repo cannot be deployed on #{self}; the platform is not supported"
53
- end
54
-
55
- #Examine the host system to determine the architecture
56
- #@return [Boolean] true if x86_64, false otherwise
44
+ # Examine the host system to determine the architecture
45
+ # @return [Boolean] true if x86_64, false otherwise
57
46
  def determine_if_x86_64
58
47
  result = exec(Beaker::Command.new("uname -a | grep x86_64"), :expect_all_exit_codes => true)
59
48
  result.exit_code == 0
60
49
  end
61
-
62
- # Gets the path & file name for the puppet agent dev package on OSX
63
- #
64
- # @param [String] puppet_collection Name of the puppet collection to use
65
- # @param [String] puppet_agent_version Version of puppet agent to get
66
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
67
- #
68
- # @note OSX does require :download_url to be set on the opts argument
69
- # in order to check for builds on the builds server
70
- #
71
- # @raise [ArgumentError] If one of the two required parameters (puppet_collection,
72
- # puppet_agent_version) is either not passed or set to nil
73
- #
74
- # @return [String, String] Path to the directory and filename of the package, respectively
75
- def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
76
- error_message = "Must provide %s argument to get puppet agent dev package information"
77
- raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
78
- raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
79
- raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]
80
-
81
- variant, version, arch, codename = self['platform'].to_array
82
-
83
- mac_pkg_name = "puppet-agent-#{puppet_agent_version}"
84
- version = version[0,2] + '.' + version[2,2] unless version.include?(".")
85
- # newest hotness
86
- path_chunk = "apple/#{version}/#{puppet_collection}/#{arch}"
87
- release_path_end = path_chunk
88
- # moved to doing this when 'el capitan' came out & the objection was
89
- # raised that the code name wasn't a fact, & as such can be hard to script
90
- # example: puppet-agent-0.1.0-1.osx10.9.dmg
91
- release_file = "#{mac_pkg_name}-1.osx#{version}.dmg"
92
- if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}") # new hotness
93
- # little older change involved the code name as only difference from above
94
- # example: puppet-agent-0.1.0-1.mavericks.dmg
95
- release_file = "#{mac_pkg_name}-1.#{codename}.dmg"
96
- end
97
- if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}") # oops, try the old stuff
98
- release_path_end = "apple/#{puppet_collection}"
99
- # example: puppet-agent-0.1.0-osx-10.9-x86_64.dmg
100
- release_file = "#{mac_pkg_name}-#{variant}-#{version}-x86_64.dmg"
101
- end
102
- return release_path_end, release_file
103
- end
104
-
105
- # Gets host-specific information for PE promoted puppet-agent packages
106
- #
107
- # @param [String] puppet_collection Name of the puppet collection to use
108
- # @param [Hash{Symbol=>String}] opts Options hash to provide extra values
109
- #
110
- # @return [String, String, String] Host-specific information for packages
111
- # 1. release_path_end Suffix for the release_path. Used on Windows. Check
112
- # {Windows::Pkg#pe_puppet_agent_promoted_package_info} to see usage.
113
- # 2. release_file Path to the file on release build servers
114
- # 3. download_file Filename for the package itself
115
- def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} )
116
- error_message = "Must provide %s argument to get puppet agent dev package information"
117
- raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
118
-
119
- variant, version, arch, _codename = self['platform'].to_array
120
- release_file = "/repos/apple/#{version}/#{puppet_collection}/#{arch}/puppet-agent-*"
121
-
122
- # macOS puppet-agent tarballs haven't always included arch
123
- agent_version = opts[:puppet_agent_version]
124
- agent_version_f = agent_version&.to_f
125
-
126
- download_file = if agent_version_f.nil? || (agent_version_f < 6.28 || (agent_version_f >= 7.0 && agent_version_f < 7.18))
127
- "puppet-agent-#{variant}-#{version}.tar.gz"
128
- else
129
- "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
130
- end
131
-
132
- return '', release_file, download_file
133
- end
134
-
135
- # Installs a given PE promoted package on a host
136
- #
137
- # @param [String] onhost_copy_base Base copy directory on the host
138
- # @param [String] onhost_copied_download Downloaded file path on the host
139
- # @param [String] onhost_copied_file Copied file path once un-compressed
140
- # @param [String] download_file File name of the downloaded file
141
- # @param [Hash{Symbol=>String}] opts additional options
142
- #
143
- # @return nil
144
- def pe_puppet_agent_promoted_package_install(
145
- onhost_copy_base, onhost_copied_download, onhost_copied_file, _download_file, _opts
146
- )
147
- execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}")
148
- # move to better location
149
- execute("mv #{onhost_copied_file}.dmg .")
150
- self.install_package("puppet-agent-*")
151
- end
152
-
153
50
  end
@@ -6,7 +6,7 @@ module Mac::User
6
6
  # @param [Proc] block Additional actions or insertions
7
7
  #
8
8
  # @return [Array<String>] The list of user names on the system
9
- def user_list()
9
+ def user_list
10
10
  execute('dscacheutil -q user') do |result|
11
11
  users = []
12
12
  result.stdout.each_line do |line|
@@ -54,7 +54,7 @@ module Mac::User
54
54
 
55
55
  uid = uid_next
56
56
  gid = gid_next
57
- create_cmd = "dscl . create /Users/#{name}"
57
+ create_cmd = "dscl . create /Users/#{name}"
58
58
  create_cmd << " && dscl . create /Users/#{name} NFSHomeDirectory /Users/#{name}"
59
59
  create_cmd << " && dscl . create /Users/#{name} UserShell /bin/bash"
60
60
  create_cmd << " && dscl . create /Users/#{name} UniqueID #{uid}"
@@ -1,11 +1,10 @@
1
- [ 'host', 'command_factory', 'command', 'options' ].each do |lib|
1
+ %w[host command_factory command options].each do |lib|
2
2
  require "beaker/#{lib}"
3
3
  end
4
4
 
5
5
  module Mac
6
- class Host < Unix::Host
7
-
8
- [ 'exec', 'user', 'group', 'pkg' ].each do |lib|
6
+ class Host < Unix::Host
7
+ %w[exec user group pkg].each do |lib|
9
8
  require "beaker/host/mac/#{lib}"
10
9
  end
11
10
 
@@ -17,18 +16,18 @@ module Mac
17
16
  def platform_defaults
18
17
  h = Beaker::Options::OptionsHash.new
19
18
  h.merge({
20
- 'user' => 'root',
21
- 'group' => 'root',
22
- 'pathseparator' => ':',
23
- })
19
+ 'user' => 'root',
20
+ 'group' => 'root',
21
+ 'pathseparator' => ':',
22
+ })
24
23
  end
25
24
 
26
25
  attr_reader :external_copy_base
26
+
27
27
  def initialize name, host_hash, options
28
28
  super
29
29
 
30
30
  @external_copy_base = '/var/root'
31
31
  end
32
-
33
32
  end
34
33
  end