beaker 4.41.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +16 -52
- data/Gemfile +12 -7
- data/HISTORY.md +605 -0
- data/Rakefile +99 -111
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +2 -4
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +81 -83
- data/lib/beaker/host/unix/file.rb +40 -45
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +138 -401
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +88 -196
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +25 -30
- data/lib/beaker/platform.rb +26 -37
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -71
- data/spec/beaker/host/unix/pkg_spec.rb +150 -411
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +168 -349
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -50
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +39 -45
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +8 -24
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
data/lib/beaker/host/unix.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[
|
|
2
|
-
|
|
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
|
-
[
|
|
8
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
-
|
|
57
|
-
|
|
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]
|
|
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 =
|
|
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
|
-
#
|
|
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
|
-
|
|
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
|
data/lib/beaker/host/windows.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
[
|
|
2
|
-
|
|
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
|
-
[
|
|
9
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|