beaker 4.38.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +36 -11
- data/.rubocop.yml +75 -0
- data/.rubocop_todo.yml +239 -0
- data/CHANGELOG.md +88 -33
- data/Gemfile +16 -4
- data/HISTORY.md +103 -0
- data/Rakefile +101 -112
- 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/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +3 -3
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +7 -6
- 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 +7 -8
- 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 +9 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
- 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 +23 -30
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
- 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 +21 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +9 -21
- data/acceptance/tests/base/host/file_test.rb +8 -8
- data/acceptance/tests/base/host/group_test.rb +2 -3
- data/acceptance/tests/base/host/host_test.rb +69 -66
- data/acceptance/tests/base/host/packages.rb +27 -30
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +2 -3
- 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 +3 -5
- 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 +10 -14
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +13 -13
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +63 -74
- data/lib/beaker/command.rb +22 -30
- data/lib/beaker/command_factory.rb +4 -3
- data/lib/beaker/dsl/assertions.rb +7 -19
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
- data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +17 -19
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +18 -21
- data/lib/beaker/dsl/structure.rb +55 -67
- 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 +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +36 -48
- 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 +5 -5
- data/lib/beaker/host/mac/group.rb +13 -13
- data/lib/beaker/host/mac/pkg.rb +6 -109
- data/lib/beaker/host/mac/user.rb +7 -7
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +70 -74
- data/lib/beaker/host/pswindows/file.rb +4 -6
- data/lib/beaker/host/pswindows/group.rb +5 -5
- data/lib/beaker/host/pswindows/pkg.rb +17 -17
- data/lib/beaker/host/pswindows/user.rb +4 -4
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +86 -88
- data/lib/beaker/host/unix/file.rb +41 -47
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +158 -421
- data/lib/beaker/host/unix/user.rb +4 -4
- data/lib/beaker/host/unix.rb +18 -20
- data/lib/beaker/host/windows/exec.rb +20 -20
- data/lib/beaker/host/windows/file.rb +5 -5
- data/lib/beaker/host/windows/group.rb +5 -5
- data/lib/beaker/host/windows/pkg.rb +6 -57
- data/lib/beaker/host/windows/user.rb +4 -4
- data/lib/beaker/host/windows.rb +13 -13
- data/lib/beaker/host.rb +82 -139
- data/lib/beaker/host_prebuilt_steps.rb +121 -233
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +46 -63
- data/lib/beaker/local_connection.rb +4 -6
- data/lib/beaker/logger.rb +71 -85
- data/lib/beaker/logger_junit.rb +22 -26
- data/lib/beaker/network_manager.rb +40 -43
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +34 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +3 -10
- data/lib/beaker/options/parser.rb +89 -105
- 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 +29 -34
- data/lib/beaker/platform.rb +38 -46
- 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 +40 -46
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +6 -8
- data/lib/beaker/shared/semvar.rb +39 -43
- data/lib/beaker/shared/timed.rb +2 -5
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +46 -55
- data/lib/beaker/subcommand.rb +23 -30
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +5 -10
- data/lib/beaker/tasks/rake_task.rb +26 -28
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +52 -57
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +135 -153
- data/spec/beaker/command_spec.rb +64 -58
- data/spec/beaker/dsl/assertions_spec.rb +38 -47
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
- data/spec/beaker/dsl/outcomes_spec.rb +15 -14
- data/spec/beaker/dsl/roles_spec.rb +170 -132
- data/spec/beaker/dsl/structure_spec.rb +181 -163
- data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
- data/spec/beaker/dsl/wrappers_spec.rb +39 -40
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +92 -102
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
- data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
- data/spec/beaker/host/mac/exec_spec.rb +4 -5
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
- data/spec/beaker/host/pswindows/file_spec.rb +21 -18
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +14 -14
- data/spec/beaker/host/unix/exec_spec.rb +87 -92
- data/spec/beaker/host/unix/file_spec.rb +76 -82
- data/spec/beaker/host/unix/pkg_spec.rb +165 -407
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +32 -34
- data/spec/beaker/host/windows/file_spec.rb +22 -23
- data/spec/beaker/host/windows/group_spec.rb +17 -19
- data/spec/beaker/host/windows/pkg_spec.rb +10 -13
- 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 +193 -341
- data/spec/beaker/host_spec.rb +241 -312
- data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
- data/spec/beaker/localhost_connection_spec.rb +14 -13
- data/spec/beaker/logger_junit_spec.rb +22 -34
- data/spec/beaker/logger_spec.rb +174 -155
- data/spec/beaker/network_manager_spec.rb +27 -27
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +7 -9
- data/spec/beaker/options/parser_spec.rb +187 -187
- data/spec/beaker/options/presets_spec.rb +8 -10
- data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
- data/spec/beaker/options/validator_spec.rb +27 -28
- data/spec/beaker/perf_spec.rb +32 -34
- data/spec/beaker/platform_spec.rb +27 -37
- data/spec/beaker/shared/error_handler_spec.rb +8 -17
- data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
- data/spec/beaker/shared/host_manager_spec.rb +55 -89
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +24 -31
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +85 -90
- data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
- data/spec/beaker/subcommand_spec.rb +89 -89
- data/spec/beaker/test_case_spec.rb +33 -62
- data/spec/beaker/test_suite_spec.rb +153 -160
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +9 -8
- data/spec/mocks.rb +6 -11
- data/spec/spec_helper.rb +0 -4
- metadata +60 -85
- 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/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
@@ -1,41 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
[ 'command', "dsl" ].each do |lib|
|
1
|
+
%w[command dsl].each do |lib|
|
4
2
|
require "beaker/#{lib}"
|
5
3
|
end
|
6
4
|
|
7
5
|
module Beaker
|
8
|
-
#Provides convienience methods for commonly run actions on hosts
|
6
|
+
# Provides convienience methods for commonly run actions on hosts
|
9
7
|
module HostPrebuiltSteps
|
10
8
|
include Beaker::DSL::Patterns
|
11
9
|
|
12
10
|
NTPSERVER = 'pool.ntp.org'
|
13
11
|
SLEEPWAIT = 5
|
14
12
|
TRIES = 5
|
15
|
-
RHEL8_PACKAGES = [
|
13
|
+
RHEL8_PACKAGES = %w[curl chrony]
|
16
14
|
RHEL9_PACKAGES = ['chrony']
|
17
|
-
FEDORA_PACKAGES = [
|
18
|
-
UNIX_PACKAGES = [
|
15
|
+
FEDORA_PACKAGES = %w[curl chrony]
|
16
|
+
UNIX_PACKAGES = %w[curl ntpdate]
|
19
17
|
FREEBSD_PACKAGES = ['curl', 'perl5|perl']
|
20
18
|
OPENBSD_PACKAGES = ['curl']
|
21
|
-
ARCHLINUX_PACKAGES = [
|
19
|
+
ARCHLINUX_PACKAGES = %w[curl ntp net-tools openssh]
|
22
20
|
WINDOWS_PACKAGES = ['curl']
|
23
21
|
PSWINDOWS_PACKAGES = []
|
24
22
|
SLES10_PACKAGES = ['curl']
|
25
|
-
SLES_PACKAGES = [
|
26
|
-
DEBIAN_PACKAGES = [
|
27
|
-
CUMULUS_PACKAGES = [
|
28
|
-
SOLARIS10_PACKAGES = [
|
29
|
-
SOLARIS11_PACKAGES = [
|
23
|
+
SLES_PACKAGES = %w[curl ntp]
|
24
|
+
DEBIAN_PACKAGES = %w[curl ntpdate lsb-release apt-transport-https]
|
25
|
+
CUMULUS_PACKAGES = %w[curl ntpdate]
|
26
|
+
SOLARIS10_PACKAGES = %w[CSWcurl CSWntp wget]
|
27
|
+
SOLARIS11_PACKAGES = %w[curl ntp]
|
30
28
|
ETC_HOSTS_PATH = "/etc/hosts"
|
31
29
|
ETC_HOSTS_PATH_SOLARIS = "/etc/inet/hosts"
|
32
30
|
ROOT_KEYS_SCRIPT = "https://raw.githubusercontent.com/puppetlabs/puppetlabs-sshkeys/master/templates/scripts/manage_root_authorized_keys"
|
33
31
|
ROOT_KEYS_SYNC_CMD = "curl -k -o - -L #{ROOT_KEYS_SCRIPT} | %s"
|
34
32
|
ROOT_KEYS_SYNC_CMD_AIX = "curl --tlsv1 -o - -L #{ROOT_KEYS_SCRIPT} | %s"
|
35
|
-
APT_CFG = %q{ Acquire::http::Proxy "http://proxy.puppetlabs.net:3128/"; }
|
36
|
-
IPS_PKG_REPO="http://solaris-11-internal-repo.delivery.puppetlabs.net"
|
37
33
|
|
38
|
-
#Run timesync on the provided hosts
|
34
|
+
# Run timesync on the provided hosts
|
39
35
|
# @param [Host, Array<Host>] host One or more hosts to act upon
|
40
36
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
41
37
|
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
@@ -47,38 +43,36 @@ module Beaker
|
|
47
43
|
if host['platform'].include? 'windows'
|
48
44
|
# The exit code of 5 is for Windows 2008 systems where the w32tm /register command
|
49
45
|
# is not actually necessary.
|
50
|
-
host.exec(Command.new("w32tm /register"), :acceptable_exit_codes => [0,5])
|
51
|
-
host.exec(Command.new("net start w32time"), :acceptable_exit_codes => [0,2])
|
46
|
+
host.exec(Command.new("w32tm /register"), :acceptable_exit_codes => [0, 5])
|
47
|
+
host.exec(Command.new("net start w32time"), :acceptable_exit_codes => [0, 2])
|
52
48
|
host.exec(Command.new("w32tm /config /manualpeerlist:#{ntp_server} /syncfromflags:manual /update"))
|
53
49
|
host.exec(Command.new("w32tm /resync"))
|
54
50
|
logger.notify "NTP date succeeded on #{host}"
|
55
51
|
else
|
56
|
-
|
57
|
-
when host['platform'] =~ /el-[89]|fedora/
|
52
|
+
if /el-[89]|fedora/.match?(host['platform'])
|
58
53
|
ntp_command = "chronyc add server #{ntp_server} prefer trust;chronyc makestep;chronyc burst 1/2"
|
59
|
-
|
54
|
+
elsif /opensuse-|sles-/.match?(host['platform'])
|
60
55
|
ntp_command = "sntp #{ntp_server}"
|
61
|
-
|
56
|
+
elsif host['platform'].include?('cisco_nexus')
|
62
57
|
ntp_server = host.exec(Command.new("getent hosts #{NTPSERVER} | head -n1 |cut -d \" \" -f1"), :acceptable_exit_codes => [0]).stdout
|
63
58
|
ntp_command = "sudo -E sh -c 'export DCOS_CONTEXT=2;/isan/bin/ntpdate -u -t 20 #{ntp_server}'"
|
64
59
|
else
|
65
60
|
ntp_command = "ntpdate -u -t 20 #{ntp_server}"
|
66
61
|
end
|
67
|
-
success=false
|
62
|
+
success = false
|
68
63
|
try = 0
|
69
|
-
until try >= TRIES
|
64
|
+
until try >= TRIES
|
70
65
|
try += 1
|
71
66
|
if host.exec(Command.new(ntp_command), :accept_all_exit_codes => true).exit_code == 0
|
72
|
-
success=true
|
67
|
+
success = true
|
73
68
|
break
|
74
69
|
end
|
75
70
|
sleep SLEEPWAIT
|
76
71
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
72
|
+
raise "NTP date was not successful after #{try} tries" unless success
|
73
|
+
|
74
|
+
logger.notify "NTP date succeeded on #{host} after #{try} tries"
|
75
|
+
|
82
76
|
end
|
83
77
|
end
|
84
78
|
nil
|
@@ -129,6 +123,7 @@ module Beaker
|
|
129
123
|
when /windows/
|
130
124
|
if host.is_cygwin?
|
131
125
|
raise RuntimeError, "cygwin is not installed on #{host}" if !host.cygwin_installed?
|
126
|
+
|
132
127
|
WINDOWS_PACKAGES
|
133
128
|
else
|
134
129
|
PSWINDOWS_PACKAGES
|
@@ -146,7 +141,7 @@ module Beaker
|
|
146
141
|
when /fedora/
|
147
142
|
FEDORA_PACKAGES
|
148
143
|
else
|
149
|
-
if
|
144
|
+
if !/aix|solaris|osx-|f5-|netscaler|cisco_/.match?(host['platform'])
|
150
145
|
UNIX_PACKAGES
|
151
146
|
else
|
152
147
|
[]
|
@@ -162,6 +157,7 @@ module Beaker
|
|
162
157
|
package_list.each do |string|
|
163
158
|
alternatives = string.split('|')
|
164
159
|
next if alternatives.any? { |pkg| host.check_for_package pkg }
|
160
|
+
|
165
161
|
install_one_of_packages host, alternatives
|
166
162
|
end
|
167
163
|
end
|
@@ -182,9 +178,9 @@ module Beaker
|
|
182
178
|
raise error
|
183
179
|
end
|
184
180
|
|
185
|
-
#Install a set of authorized keys using {HostPrebuiltSteps::ROOT_KEYS_SCRIPT}. This is a
|
186
|
-
#convenience method to allow for easy login to hosts after they have been provisioned with
|
187
|
-
#Beaker.
|
181
|
+
# Install a set of authorized keys using {HostPrebuiltSteps::ROOT_KEYS_SCRIPT}. This is a
|
182
|
+
# convenience method to allow for easy login to hosts after they have been provisioned with
|
183
|
+
# Beaker.
|
188
184
|
# @param [Host, Array<Host>] host One or more hosts to act upon
|
189
185
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
190
186
|
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
@@ -195,11 +191,11 @@ module Beaker
|
|
195
191
|
# when reality dictates otherwise"
|
196
192
|
logger = opts[:logger]
|
197
193
|
block_on host do |host|
|
198
|
-
|
194
|
+
logger.notify "Sync root authorized_keys from github on #{host.name}"
|
199
195
|
# Allow all exit code, as this operation is unlikely to cause problems if it fails.
|
200
|
-
if host['platform']
|
196
|
+
if /solaris|eos/.match?(host['platform'])
|
201
197
|
host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "bash"), :accept_all_exit_codes => true)
|
202
|
-
elsif host['platform']
|
198
|
+
elsif host['platform'].include?('aix')
|
203
199
|
host.exec(Command.new(ROOT_KEYS_SYNC_CMD_AIX % "env PATH=/usr/gnu/bin:$PATH bash"), :accept_all_exit_codes => true)
|
204
200
|
else
|
205
201
|
host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "env PATH=\"/usr/gnu/bin:$PATH\" bash"), :accept_all_exit_codes => true)
|
@@ -215,146 +211,75 @@ module Beaker
|
|
215
211
|
# @param [Host, Array<Host>] hosts One or more hosts to act upon
|
216
212
|
def apt_get_update hosts
|
217
213
|
block_on hosts do |host|
|
218
|
-
|
219
|
-
host.exec(Command.new("apt-get update"))
|
220
|
-
end
|
214
|
+
host.exec(Command.new("apt-get update")) if /ubuntu|debian|cumulus/.match?(host[:platform])
|
221
215
|
end
|
222
216
|
end
|
223
217
|
|
224
|
-
#Create a file on host or hosts at the provided file path with the provided file contents.
|
218
|
+
# Create a file on host or hosts at the provided file path with the provided file contents.
|
225
219
|
# @param [Host, Array<Host>] host One or more hosts to act upon
|
226
220
|
# @param [String] file_path The path at which the new file will be created on the host or hosts.
|
227
221
|
# @param [String] file_content The contents of the file to be created on the host or hosts.
|
228
222
|
def copy_file_to_remote(host, file_path, file_content)
|
229
223
|
block_on host do |host|
|
230
224
|
Tempfile.open 'beaker' do |tempfile|
|
231
|
-
File.open(tempfile.path, 'w') {|file| file.puts file_content }
|
225
|
+
File.open(tempfile.path, 'w') { |file| file.puts file_content }
|
232
226
|
|
233
227
|
host.do_scp_to(tempfile.path, file_path, @options)
|
234
228
|
end
|
235
229
|
end
|
236
230
|
end
|
237
231
|
|
238
|
-
#
|
239
|
-
# the internal Puppet Labs proxy {HostPrebuiltSteps::APT_CFG} proxy.
|
240
|
-
# On solaris-11 host or hosts: alter pkg to point to
|
241
|
-
# the internal Puppet Labs proxy {HostPrebuiltSteps::IPS_PKG_REPO}.
|
242
|
-
#
|
243
|
-
# Do nothing for other platform host or hosts.
|
244
|
-
#
|
245
|
-
# @param [Host, Array<Host>] host One or more hosts to act upon
|
246
|
-
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
247
|
-
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
248
|
-
def proxy_config( host, opts )
|
249
|
-
logger = opts[:logger]
|
250
|
-
block_on host do |host|
|
251
|
-
case
|
252
|
-
when host['platform'] =~ /ubuntu|debian|cumulus/
|
253
|
-
host.exec(Command.new("if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi"))
|
254
|
-
copy_file_to_remote(host, '/etc/apt/apt.conf', APT_CFG)
|
255
|
-
apt_get_update(host)
|
256
|
-
when host['platform'] =~ /solaris-11/
|
257
|
-
host.exec(Command.new("/usr/bin/pkg unset-publisher solaris || :"))
|
258
|
-
host.exec(Command.new("/usr/bin/pkg set-publisher -g %s solaris" % IPS_PKG_REPO))
|
259
|
-
else
|
260
|
-
logger.debug "#{host}: repo proxy configuration not modified"
|
261
|
-
end
|
262
|
-
end
|
263
|
-
rescue => e
|
264
|
-
report_and_raise(logger, e, "proxy_config")
|
265
|
-
end
|
266
|
-
|
267
|
-
#Install EPEL on host or hosts with platform = /el-(6|7)/. Do nothing on host or hosts of other platforms.
|
268
|
-
# @param [Host, Array<Host>] host One or more hosts to act upon. Will use individual host epel_url, epel_arch
|
269
|
-
# and epel_pkg before using defaults provided in opts.
|
270
|
-
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
271
|
-
# @option opts [Boolean] :debug If true, print verbose rpm information when installing EPEL
|
272
|
-
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
273
|
-
# @option opts [String] :epel_url Link to download from
|
274
|
-
def add_el_extras( host, opts )
|
275
|
-
#add_el_extras
|
276
|
-
#only supports el-* platforms
|
277
|
-
logger = opts[:logger]
|
278
|
-
debug_opt = opts[:debug] ? 'vh' : ''
|
279
|
-
block_on host do |host|
|
280
|
-
case
|
281
|
-
when el_based?(host) && ['6','7'].include?(host['platform'].version)
|
282
|
-
result = host.exec(Command.new('rpm -qa | grep epel-release'), :acceptable_exit_codes => [0,1])
|
283
|
-
if result.exit_code == 1
|
284
|
-
url_base = opts[:epel_url]
|
285
|
-
host.install_package_with_rpm("#{url_base}/epel-release-latest-#{host['platform'].version}.noarch.rpm", '--replacepkgs', { :package_proxy => opts[:package_proxy] })
|
286
|
-
#update /etc/yum.repos.d/epel.repo for new baseurl
|
287
|
-
host.exec(Command.new("sed -i -e 's;#baseurl.*$;baseurl=#{Regexp.escape("#{url_base}/#{host['platform'].version}")}/\$basearch;' /etc/yum.repos.d/epel.repo"))
|
288
|
-
#remove mirrorlist
|
289
|
-
host.exec(Command.new("sed -i -e '/mirrorlist/d' /etc/yum.repos.d/epel.repo"))
|
290
|
-
host.exec(Command.new('yum clean all && yum makecache'))
|
291
|
-
end
|
292
|
-
else
|
293
|
-
logger.debug "#{host}: package repo configuration not modified"
|
294
|
-
end
|
295
|
-
end
|
296
|
-
rescue => e
|
297
|
-
report_and_raise(logger, e, "add_repos")
|
298
|
-
end
|
299
|
-
|
300
|
-
#Determine the domain name of the provided host from its /etc/resolv.conf
|
232
|
+
# Determine the domain name of the provided host from its /etc/resolv.conf
|
301
233
|
# @param [Host] host the host to act upon
|
302
234
|
def get_domain_name(host)
|
303
235
|
domain = nil
|
304
236
|
search = nil
|
305
|
-
if host['platform']
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
237
|
+
resolv_conf = if host['platform'].include?('windows')
|
238
|
+
if host.is_cygwin?
|
239
|
+
host.exec(Command.new("cat /cygdrive/c/Windows/System32/drivers/etc/hosts")).stdout
|
240
|
+
else
|
241
|
+
host.exec(Command.new('type C:\Windows\System32\drivers\etc\hosts')).stdout
|
242
|
+
end
|
243
|
+
else
|
244
|
+
host.exec(Command.new("cat /etc/resolv.conf")).stdout
|
245
|
+
end
|
246
|
+
resolv_conf.each_line do |line|
|
247
|
+
if (match = /^\s*domain\s+(\S+)/.match(line))
|
248
|
+
domain = match[1]
|
249
|
+
elsif (match = /^\s*search\s+(\S+)/.match(line))
|
250
|
+
search = match[1]
|
310
251
|
end
|
311
|
-
else
|
312
|
-
resolv_conf = host.exec(Command.new("cat /etc/resolv.conf")).stdout
|
313
252
|
end
|
314
|
-
resolv_conf.each_line { |line|
|
315
|
-
if line =~ /^\s*domain\s+(\S+)/
|
316
|
-
domain = $1
|
317
|
-
elsif line =~ /^\s*search\s+(\S+)/
|
318
|
-
search = $1
|
319
|
-
end
|
320
|
-
}
|
321
253
|
return_value ||= domain
|
322
254
|
return_value ||= search
|
323
255
|
|
324
|
-
|
325
|
-
return_value.gsub(/\.$/, '')
|
326
|
-
end
|
327
|
-
end
|
256
|
+
return unless return_value
|
328
257
|
|
329
|
-
|
330
|
-
# @param [Host] host the host to act upon
|
331
|
-
# @deprecated use {Host#get_ip}
|
332
|
-
def get_ip(host)
|
333
|
-
host.get_ip
|
258
|
+
return_value.gsub(/\.$/, '')
|
334
259
|
end
|
335
260
|
|
336
|
-
#Append the provided string to the /etc/hosts file of the provided host
|
261
|
+
# Append the provided string to the /etc/hosts file of the provided host
|
337
262
|
# @param [Host] host the host to act upon
|
338
263
|
# @param [String] etc_hosts The string to append to the /etc/hosts file
|
339
264
|
def set_etc_hosts(host, etc_hosts)
|
340
|
-
if host['platform']
|
265
|
+
if host['platform'].include?('freebsd')
|
341
266
|
host.echo_to_file(etc_hosts, '/etc/hosts')
|
342
|
-
elsif ((host['platform']
|
267
|
+
elsif ((host['platform'].include?('windows')) and not host.is_cygwin?)
|
343
268
|
host.exec(Command.new("echo '#{etc_hosts}' >> C:\\Windows\\System32\\drivers\\etc\\hosts"))
|
344
269
|
else
|
345
270
|
host.exec(Command.new("echo '#{etc_hosts}' >> /etc/hosts"))
|
346
271
|
end
|
347
272
|
# AIX must be configured to prefer local DNS over external
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
273
|
+
return unless host['platform'].include?('aix')
|
274
|
+
|
275
|
+
aix_netsvc = '/etc/netsvc.conf'
|
276
|
+
aix_local_resolv = 'hosts = local, bind'
|
277
|
+
return if host.exec(Command.new("grep '#{aix_local_resolv}' #{aix_netsvc}"), :accept_all_exit_codes => true).exit_code == 0
|
278
|
+
|
279
|
+
host.exec(Command.new("echo '#{aix_local_resolv}' >> #{aix_netsvc}"))
|
355
280
|
end
|
356
281
|
|
357
|
-
#Make it possible to log in as root by copying the current users ssh keys to the root account
|
282
|
+
# Make it possible to log in as root by copying the current users ssh keys to the root account
|
358
283
|
# @param [Host, Array<Host>] host One or more hosts to act upon
|
359
284
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
360
285
|
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
@@ -362,10 +287,10 @@ module Beaker
|
|
362
287
|
logger = opts[:logger]
|
363
288
|
block_on host do |host|
|
364
289
|
logger.debug "Give root a copy of current user's keys, on #{host.name}"
|
365
|
-
if host['platform']
|
290
|
+
if host['platform'].include?('windows') and host.is_cygwin?
|
366
291
|
host.exec(Command.new('cp -r .ssh /cygdrive/c/Users/Administrator/.'))
|
367
292
|
host.exec(Command.new('chown -R Administrator /cygdrive/c/Users/Administrator/.ssh'))
|
368
|
-
elsif host['platform']
|
293
|
+
elsif host['platform'].include?('windows') and not host.is_cygwin?
|
369
294
|
# from https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true:
|
370
295
|
# /i : If Source is a directory or contains wildcards and Destination
|
371
296
|
# does not exist, xcopy assumes destination specifies a directory
|
@@ -376,23 +301,17 @@ module Beaker
|
|
376
301
|
# /y : Suppresses prompting to confirm that you want to overwrite an
|
377
302
|
# existing destination file.
|
378
303
|
host.exec(Command.new("if exist .ssh (xcopy .ssh C:\\Users\\Administrator\\.ssh /s /e /y /i)"))
|
379
|
-
elsif host['platform']
|
380
|
-
host.exec(Command.new('sudo cp -r .ssh /var/root/.'), {:pty => true})
|
381
|
-
elsif host['platform']
|
382
|
-
host.exec(Command.new('sudo cp -r .ssh /root/.'), {:pty => true})
|
383
|
-
elsif host['platform']
|
384
|
-
host.exec(Command.new('sudo cp -r .ssh
|
385
|
-
elsif host['platform'] =~ /solaris-10/
|
386
|
-
host.exec(Command.new('sudo cp -r .ssh /.'), {:pty => true})
|
387
|
-
elsif host['platform'] =~ /solaris-11/
|
388
|
-
host.exec(Command.new('sudo cp -r .ssh /root/.'), {:pty => true})
|
304
|
+
elsif host['platform'].include?('osx')
|
305
|
+
host.exec(Command.new('sudo cp -r .ssh /var/root/.'), { :pty => true })
|
306
|
+
elsif /(free|open)bsd/.match?(host['platform']) || host['platform'].include?('solaris-11')
|
307
|
+
host.exec(Command.new('sudo cp -r .ssh /root/.'), { :pty => true })
|
308
|
+
elsif host['platform'].include?('solaris-10')
|
309
|
+
host.exec(Command.new('sudo cp -r .ssh /.'), { :pty => true })
|
389
310
|
else
|
390
|
-
host.exec(Command.new('sudo su -c "cp -r .ssh /root/."'), {:pty => true})
|
311
|
+
host.exec(Command.new('sudo su -c "cp -r .ssh /root/."'), { :pty => true })
|
391
312
|
end
|
392
313
|
|
393
|
-
if host.selinux_enabled?
|
394
|
-
host.exec(Command.new('sudo fixfiles restore /root'))
|
395
|
-
end
|
314
|
+
host.exec(Command.new('sudo fixfiles restore /root')) if host.selinux_enabled?
|
396
315
|
end
|
397
316
|
end
|
398
317
|
|
@@ -404,7 +323,7 @@ module Beaker
|
|
404
323
|
# @param [Host, Array<Host>] hosts An array of hosts to act upon
|
405
324
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
406
325
|
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
407
|
-
def hack_etc_hosts hosts,
|
326
|
+
def hack_etc_hosts hosts, _opts
|
408
327
|
etc_hosts = "127.0.0.1\tlocalhost localhost.localdomain\n"
|
409
328
|
hosts.each do |host|
|
410
329
|
ip = host['vm_ip'] || host['ip'].to_s
|
@@ -423,7 +342,8 @@ module Beaker
|
|
423
342
|
def disable_updates hosts, opts
|
424
343
|
logger = opts[:logger]
|
425
344
|
hosts.each do |host|
|
426
|
-
next if host['platform']
|
345
|
+
next if host['platform'].include?('netscaler')
|
346
|
+
|
427
347
|
logger.notify "Disabling updates.puppetlabs.com by modifying hosts file to resolve updates to 127.0.0.1 on #{host}"
|
428
348
|
set_etc_hosts(host, "127.0.0.1\tupdates.puppetlabs.com\n")
|
429
349
|
end
|
@@ -440,77 +360,59 @@ module Beaker
|
|
440
360
|
logger = opts[:logger]
|
441
361
|
block_on host do |host|
|
442
362
|
logger.debug "Update sshd_config to allow root login"
|
443
|
-
if host['platform']
|
363
|
+
if host['platform'].include?('osx')
|
444
364
|
# If osx > 10.10 use '/private/etc/ssh/sshd_config', else use '/etc/sshd_config'
|
445
365
|
ssh_config_file = '/private/etc/ssh/sshd_config'
|
446
|
-
ssh_config_file = '/etc/sshd_config' if
|
366
|
+
ssh_config_file = '/etc/sshd_config' if /^osx-10\.(9|10)/i.match?(host['platform'])
|
447
367
|
|
448
368
|
host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' #{ssh_config_file}"))
|
449
369
|
host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' #{ssh_config_file}"))
|
450
|
-
elsif host['platform']
|
451
|
-
host.exec(Command.new("sudo sed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true}
|
452
|
-
elsif host['platform']
|
453
|
-
host.exec(Command.new("sudo perl -pi -e 's/^PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config"), {:pty => true}
|
454
|
-
elsif host['platform']
|
455
|
-
host.exec(Command.new("sudo gsed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true}
|
456
|
-
elsif host['platform']
|
457
|
-
host.exec(Command.new("if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi"), {:pty => true}
|
458
|
-
host.exec(Command.new("sudo gsed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true}
|
459
|
-
elsif host['platform']
|
460
|
-
#interacting with f5 should using tmsh
|
370
|
+
elsif host['platform'].include?('freebsd')
|
371
|
+
host.exec(Command.new("sudo sed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), { :pty => true })
|
372
|
+
elsif host['platform'].include?('openbsd')
|
373
|
+
host.exec(Command.new("sudo perl -pi -e 's/^PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config"), { :pty => true })
|
374
|
+
elsif host['platform'].include?('solaris-10')
|
375
|
+
host.exec(Command.new("sudo gsed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), { :pty => true })
|
376
|
+
elsif host['platform'].include?('solaris-11')
|
377
|
+
host.exec(Command.new("if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi"), { :pty => true })
|
378
|
+
host.exec(Command.new("sudo gsed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), { :pty => true })
|
379
|
+
elsif host['platform'].include?('f5') || host.is_powershell?
|
380
|
+
# interacting with f5 should using tmsh
|
461
381
|
logger.warn("Attempting to enable root login non-supported platform: #{host.name}: #{host['platform']}")
|
462
382
|
elsif host.is_cygwin?
|
463
|
-
host.exec(Command.new("sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config"), {:pty => true})
|
464
|
-
elsif host.is_powershell?
|
465
|
-
logger.warn("Attempting to enable root login non-supported platform: #{host.name}: #{host['platform']}")
|
383
|
+
host.exec(Command.new("sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config"), { :pty => true })
|
466
384
|
else
|
467
|
-
host.exec(Command.new("sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""), {:pty => true})
|
385
|
+
host.exec(Command.new("sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""), { :pty => true })
|
468
386
|
end
|
469
|
-
#restart sshd
|
470
|
-
if host['platform']
|
471
|
-
host.exec(Command.new("sudo su -c \"service ssh restart\""), {:pty => true})
|
472
|
-
elsif
|
473
|
-
host.exec(Command.new("sudo -E systemctl restart sshd.service"), {:pty => true})
|
474
|
-
elsif
|
475
|
-
host.exec(Command.new("sudo -E /sbin/service sshd reload"), {:pty => true})
|
476
|
-
elsif host['platform']
|
387
|
+
# restart sshd
|
388
|
+
if /debian|ubuntu|cumulus/.match?(host['platform'])
|
389
|
+
host.exec(Command.new("sudo su -c \"service ssh restart\""), { :pty => true })
|
390
|
+
elsif /arch|(centos|el|redhat)-[789]|fedora-(1[4-9]|2[0-9]|3[0-9])/.match?(host['platform'])
|
391
|
+
host.exec(Command.new("sudo -E systemctl restart sshd.service"), { :pty => true })
|
392
|
+
elsif /centos|el-|redhat|fedora|eos/.match?(host['platform'])
|
393
|
+
host.exec(Command.new("sudo -E /sbin/service sshd reload"), { :pty => true })
|
394
|
+
elsif /(free|open)bsd/.match?(host['platform'])
|
477
395
|
host.exec(Command.new("sudo /etc/rc.d/sshd restart"))
|
478
|
-
elsif host['platform']
|
479
|
-
host.exec(Command.new("sudo -E svcadm restart network/ssh"), {:pty => true}
|
396
|
+
elsif host['platform'].include?('solaris')
|
397
|
+
host.exec(Command.new("sudo -E svcadm restart network/ssh"), { :pty => true })
|
480
398
|
else
|
481
399
|
logger.warn("Attempting to update ssh on non-supported platform: #{host.name}: #{host['platform']}")
|
482
400
|
end
|
483
401
|
end
|
484
402
|
end
|
485
403
|
|
486
|
-
#Disable SELinux on centos, does nothing on other platforms
|
404
|
+
# Disable SELinux on centos, does nothing on other platforms
|
487
405
|
# @param [Host, Array<Host>] host One or more hosts to act upon
|
488
406
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
489
407
|
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
490
408
|
def disable_se_linux host, opts
|
491
409
|
logger = opts[:logger]
|
492
410
|
block_on host do |host|
|
493
|
-
if
|
494
|
-
|
495
|
-
host.exec(Command.new("sudo su -c \"setenforce 0\""), {:pty => true})
|
496
|
-
else
|
497
|
-
@logger.warn("Attempting to disable SELinux on non-supported platform: #{host.name}: #{host['platform']}")
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
#Disable iptables on centos, does nothing on other platforms
|
503
|
-
# @param [Host, Array<Host>] host One or more hosts to act upon
|
504
|
-
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
505
|
-
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
506
|
-
def disable_iptables host, opts
|
507
|
-
logger = opts[:logger]
|
508
|
-
block_on host do |host|
|
509
|
-
if host['platform'] =~ /centos|el-|redhat|fedora|eos/
|
510
|
-
logger.debug("Disabling iptables on #{host.name}")
|
511
|
-
host.exec(Command.new("sudo su -c \"/etc/init.d/iptables stop\""), {:pty => true})
|
411
|
+
if /centos|el-|redhat|fedora|eos/.match?(host['platform'])
|
412
|
+
logger.debug("Disabling se_linux on #{host.name}")
|
413
|
+
host.exec(Command.new("sudo su -c \"setenforce 0\""), { :pty => true })
|
512
414
|
else
|
513
|
-
logger.warn("Attempting to disable
|
415
|
+
logger.warn("Attempting to disable SELinux on non-supported platform: #{host.name}: #{host['platform']}")
|
514
416
|
end
|
515
417
|
end
|
516
418
|
end
|
@@ -527,17 +429,19 @@ module Beaker
|
|
527
429
|
block_on host do |host|
|
528
430
|
logger.debug("enabling proxy support on #{host.name}")
|
529
431
|
case host['platform']
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
432
|
+
when /ubuntu/, /debian/, /cumulus/
|
433
|
+
host.exec(Command.new("echo 'Acquire::http::Proxy \"#{opts[:package_proxy]}/\";' >> /etc/apt/apt.conf.d/10proxy"))
|
434
|
+
when /^el-/, /centos/, /fedora/, /redhat/, /eos/
|
435
|
+
host.exec(Command.new("echo 'proxy=#{opts[:package_proxy]}/' >> /etc/yum.conf"))
|
436
|
+
when /solaris-11/
|
437
|
+
host.exec(Command.new("/usr/bin/pkg unset-publisher solaris || :"))
|
438
|
+
host.exec(Command.new("/usr/bin/pkg set-publisher -g %s solaris" % opts[:package_proxy]))
|
534
439
|
else
|
535
440
|
logger.debug("Attempting to enable package manager proxy support on non-supported platform: #{host.name}: #{host['platform']}")
|
536
441
|
end
|
537
442
|
end
|
538
443
|
end
|
539
444
|
|
540
|
-
|
541
445
|
# Merge the two provided hashes so that an array of values is created from collisions
|
542
446
|
# @param [Hash] h1 The first hash
|
543
447
|
# @param [Hash] h2 The second hash
|
@@ -549,12 +453,12 @@ module Beaker
|
|
549
453
|
# => {:PATH=>["/1st/path", "/2nd/path"]}
|
550
454
|
def additive_hash_merge h1, h2
|
551
455
|
merged_hash = {}
|
552
|
-
normalized_h2 = h2.
|
553
|
-
h1.each_pair do |key,
|
456
|
+
normalized_h2 = h2.each_with_object({}) { |(k, v), h| h[k.to_s.upcase] = v; }
|
457
|
+
h1.each_pair do |key, _val|
|
554
458
|
normalized_key = key.to_s.upcase
|
555
459
|
if normalized_h2.has_key?(normalized_key)
|
556
460
|
merged_hash[key] = [h1[key], normalized_h2[normalized_key]]
|
557
|
-
merged_hash[key] = merged_hash[key].uniq #remove dupes
|
461
|
+
merged_hash[key] = merged_hash[key].uniq # remove dupes
|
558
462
|
end
|
559
463
|
end
|
560
464
|
merged_hash
|
@@ -569,9 +473,7 @@ module Beaker
|
|
569
473
|
|
570
474
|
env.each_key do |key|
|
571
475
|
separator = host['pathseparator']
|
572
|
-
if key == 'PATH' && (not host.is_powershell?)
|
573
|
-
separator = ':'
|
574
|
-
end
|
476
|
+
separator = ':' if key == 'PATH' && (not host.is_powershell?)
|
575
477
|
env[key] = env[key].join(separator)
|
576
478
|
end
|
577
479
|
env
|
@@ -586,7 +488,7 @@ module Beaker
|
|
586
488
|
block_on host do |host|
|
587
489
|
skip_msg = host.skip_set_env?
|
588
490
|
unless skip_msg.nil?
|
589
|
-
logger.debug(
|
491
|
+
logger.debug(skip_msg)
|
590
492
|
next
|
591
493
|
end
|
592
494
|
|
@@ -594,14 +496,12 @@ module Beaker
|
|
594
496
|
|
595
497
|
logger.debug("setting local environment on #{host.name}")
|
596
498
|
|
597
|
-
if host['platform']
|
598
|
-
env['CYGWIN'] = 'nodosfilewarning'
|
599
|
-
end
|
499
|
+
env['CYGWIN'] = 'nodosfilewarning' if host['platform'].include?('windows') && host.is_cygwin?
|
600
500
|
|
601
501
|
host.ssh_permit_user_environment
|
602
502
|
host.ssh_set_user_environment(env)
|
603
503
|
|
604
|
-
#close the host to re-establish the connection with the new sshd settings
|
504
|
+
# close the host to re-establish the connection with the new sshd settings
|
605
505
|
host.close
|
606
506
|
|
607
507
|
# print out the working env
|
@@ -612,17 +512,5 @@ module Beaker
|
|
612
512
|
end
|
613
513
|
end
|
614
514
|
end
|
615
|
-
|
616
|
-
private
|
617
|
-
|
618
|
-
# A helper to tell whether a host is el-based
|
619
|
-
# @param [Host] host the host to act upon
|
620
|
-
#
|
621
|
-
# @return [Boolean] if the host is el_based
|
622
|
-
def el_based? host
|
623
|
-
['centos','redhat','scientific','el','oracle'].include?(host['platform'].variant)
|
624
|
-
end
|
625
|
-
|
626
515
|
end
|
627
|
-
|
628
516
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Beaker
|
2
2
|
class Noop < Beaker::Hypervisor
|
3
|
+
def initialize(hosts, options)
|
4
|
+
super
|
3
5
|
|
4
|
-
def initialize(new_hosts, options)
|
5
|
-
@options = options
|
6
6
|
@logger = options[:logger]
|
7
|
-
@hosts = new_hosts
|
8
7
|
end
|
9
8
|
|
10
9
|
def validate
|
@@ -26,6 +25,5 @@ module Beaker
|
|
26
25
|
def cleanup
|
27
26
|
# noop
|
28
27
|
end
|
29
|
-
|
30
28
|
end
|
31
29
|
end
|