beaker 3.35.0 → 4.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/.gitignore +32 -9
- data/CHANGELOG.md +56 -1
- data/CONTRIBUTING.md +82 -32
- data/DOCUMENTING.md +68 -44
- data/README.md +14 -31
- data/acceptance/lib/helpers/test_helper.rb +0 -28
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +106 -103
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +1 -50
- 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 +71 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -3
- data/acceptance/tests/base/host/file_test.rb +81 -0
- data/beaker.gemspec +7 -15
- data/docs/README.md +5 -12
- data/docs/concepts/beaker_libraries.md +2 -2
- data/docs/concepts/glossary.md +11 -0
- data/docs/concepts/style_guide.md +24 -91
- data/docs/concepts/test_tagging.md +3 -10
- data/docs/concepts/testing_beaker_itself.md +3 -2
- data/docs/concepts/ticket_process.md +17 -45
- data/docs/how_to/archive_sut_files.md +7 -33
- data/docs/how_to/change_terminal_output_coloring.md +7 -4
- data/docs/how_to/confine.md +5 -16
- data/docs/how_to/debug_beaker_tests.md +14 -6
- data/docs/how_to/hosts/README.md +2 -5
- data/docs/how_to/hosts/archlinux.md +4 -2
- data/docs/how_to/hosts/cisco.md +9 -30
- data/docs/how_to/hosts/eos.md +5 -14
- data/docs/how_to/hypervisors/README.md +18 -36
- data/docs/how_to/install_puppet.md +18 -51
- data/docs/how_to/platform_specific_tag_confines.md +11 -31
- data/docs/how_to/preserve_hosts.md +13 -54
- data/docs/how_to/rake_tasks.md +1 -4
- data/docs/how_to/recipes.md +9 -2
- data/docs/how_to/run_in_parallel.md +10 -10
- data/docs/how_to/ssh_agent_forwarding.md +8 -13
- data/docs/how_to/ssh_connection_preference.md +10 -10
- data/docs/how_to/test_arbitrary_beaker_versions.md +5 -12
- data/docs/how_to/the_beaker_dsl.md +207 -184
- data/docs/how_to/upgrade_from_2_to_3.md +13 -53
- data/docs/how_to/upgrade_from_3_to_4.md +52 -0
- data/docs/how_to/use_hocon_helpers.md +10 -28
- data/docs/how_to/use_user_password_authentication.md +13 -10
- data/docs/how_to/write_a_beaker_test_for_a_module.md +6 -2
- data/docs/tutorials/README.md +14 -55
- data/docs/tutorials/creating_a_test_environment.md +47 -52
- data/docs/tutorials/installation.md +57 -21
- data/docs/tutorials/lets_write_a_test.md +8 -1
- data/docs/tutorials/quick_start_rake_tasks.md +63 -62
- data/docs/tutorials/subcommands.md +19 -32
- data/docs/tutorials/test_run.md +14 -16
- data/docs/tutorials/test_suites.md +14 -43
- data/docs/tutorials/the_command_line.md +14 -2
- data/lib/beaker/cli.rb +11 -24
- data/lib/beaker/dsl/helpers/host_helpers.rb +10 -34
- data/lib/beaker/dsl/helpers.rb +4 -6
- data/lib/beaker/dsl/install_utils.rb +0 -5
- data/lib/beaker/dsl/roles.rb +1 -1
- data/lib/beaker/dsl.rb +7 -0
- data/lib/beaker/host/aix/file.rb +2 -2
- data/lib/beaker/host/aix/group.rb +1 -0
- data/lib/beaker/host/aix/user.rb +1 -0
- data/lib/beaker/host/freebsd/pkg.rb +9 -0
- data/lib/beaker/host/mac/group.rb +1 -0
- data/lib/beaker/host/mac/user.rb +8 -13
- data/lib/beaker/host/pswindows/file.rb +2 -2
- data/lib/beaker/host/pswindows/group.rb +1 -0
- data/lib/beaker/host/pswindows/user.rb +1 -0
- data/lib/beaker/host/unix/exec.rb +5 -5
- data/lib/beaker/host/unix/file.rb +43 -2
- data/lib/beaker/host/unix/group.rb +1 -0
- data/lib/beaker/host/unix/pkg.rb +9 -2
- data/lib/beaker/host/unix/user.rb +1 -0
- data/lib/beaker/host/windows/file.rb +32 -2
- data/lib/beaker/host/windows/group.rb +1 -0
- data/lib/beaker/host/windows/user.rb +1 -0
- data/lib/beaker/host.rb +12 -11
- data/lib/beaker/host_prebuilt_steps.rb +1 -5
- data/lib/beaker/hypervisor.rb +1 -5
- data/lib/beaker/logger.rb +1 -1
- data/lib/beaker/result.rb +4 -0
- data/lib/beaker/shared/fog_credentials.rb +61 -0
- data/lib/beaker/shared/host_manager.rb +6 -3
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/subcommand.rb +5 -3
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +0 -10
- data/spec/beaker/cli_spec.rb +21 -0
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +14 -51
- data/spec/beaker/dsl/wrappers_spec.rb +0 -46
- data/spec/beaker/host/mac/user_spec.rb +5 -8
- data/spec/beaker/host/unix/exec_spec.rb +1 -1
- data/spec/beaker/host/unix/file_spec.rb +39 -0
- data/spec/beaker/host/unix/pkg_spec.rb +66 -17
- data/spec/beaker/host/unix_spec.rb +4 -4
- data/spec/beaker/host/windows/file_spec.rb +55 -0
- data/spec/beaker/host_prebuilt_steps_spec.rb +26 -73
- data/spec/beaker/host_spec.rb +10 -14
- data/spec/beaker/hypervisor/hypervisor_spec.rb +3 -3
- data/spec/beaker/logger_spec.rb +4 -0
- data/spec/beaker/shared/fog_credentials_spec.rb +100 -0
- data/spec/beaker/shared/host_manager_spec.rb +8 -0
- data/spec/beaker/subcommand_spec.rb +1 -0
- metadata +56 -165
- data/acceptance/lib/beaker/acceptance/install_utils.rb +0 -58
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +0 -68
- data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +0 -49
- data/lib/beaker/dsl/helpers/facter_helpers.rb +0 -57
- data/lib/beaker/dsl/install_utils/pe_defaults.rb +0 -143
- data/lib/beaker/dsl/install_utils/windows_utils.rb +0 -223
- data/spec/beaker/dsl/ezbake_utils_spec.rb +0 -279
- data/spec/beaker/dsl/install_utils/pe_defaults_spec.rb +0 -61
- data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +0 -263
|
@@ -394,6 +394,16 @@ module Beaker
|
|
|
394
394
|
host.install_package package_name, '', package_version
|
|
395
395
|
end
|
|
396
396
|
|
|
397
|
+
# Uninstall a package on a host
|
|
398
|
+
#
|
|
399
|
+
# @param [Host] host A host object
|
|
400
|
+
# @param [String] package_name Name of the package to uninstall
|
|
401
|
+
#
|
|
402
|
+
# @return [Result] An object representing the outcome of *uninstall command*.
|
|
403
|
+
def uninstall_package host, package_name
|
|
404
|
+
host.uninstall_package package_name
|
|
405
|
+
end
|
|
406
|
+
|
|
397
407
|
# Check to see if a package is installed on a remote host
|
|
398
408
|
#
|
|
399
409
|
# @param [Host] host A host object
|
|
@@ -558,40 +568,6 @@ module Beaker
|
|
|
558
568
|
end
|
|
559
569
|
end
|
|
560
570
|
|
|
561
|
-
# Create a temp directory on remote host owned by specified user.
|
|
562
|
-
#
|
|
563
|
-
# @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
|
|
564
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
|
565
|
-
# @param [String] path_prefix A remote path prefix for the new temp
|
|
566
|
-
# directory.
|
|
567
|
-
# @param [String] user The name of user that should own the temp
|
|
568
|
-
# directory. If no username is specified defaults to the currently logged in user
|
|
569
|
-
# per host
|
|
570
|
-
#
|
|
571
|
-
# @return [String, Array<String>] Returns the name of the newly-created dir, or an array
|
|
572
|
-
# of names of newly-created dirs per-host
|
|
573
|
-
def create_tmpdir_on(host, path_prefix = '', user=nil)
|
|
574
|
-
|
|
575
|
-
block_on host do | host |
|
|
576
|
-
# use default user logged into this host
|
|
577
|
-
if not user
|
|
578
|
-
user = host['user']
|
|
579
|
-
end
|
|
580
|
-
|
|
581
|
-
if not on(host, "getent passwd #{user}").exit_code == 0
|
|
582
|
-
raise "User #{user} does not exist on #{host}."
|
|
583
|
-
end
|
|
584
|
-
|
|
585
|
-
if defined? host.tmpdir
|
|
586
|
-
dir = host.tmpdir(path_prefix)
|
|
587
|
-
on host, "chown #{user}:#{user} #{dir}"
|
|
588
|
-
dir
|
|
589
|
-
else
|
|
590
|
-
raise "Host platform not supported by `create_tmpdir_on`."
|
|
591
|
-
end
|
|
592
|
-
end
|
|
593
|
-
end
|
|
594
|
-
|
|
595
571
|
# 'echo' the provided value on the given host(s)
|
|
596
572
|
# @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
|
|
597
573
|
# or a role (String or Symbol) that identifies one or more hosts.
|
data/lib/beaker/dsl/helpers.rb
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
require "beaker/dsl/helpers/#{lib}_helpers"
|
|
4
4
|
end
|
|
5
5
|
|
|
6
|
-
require "beaker-hiera"
|
|
7
|
-
require 'beaker-puppet'
|
|
8
6
|
module Beaker
|
|
9
7
|
module DSL
|
|
10
8
|
|
|
11
|
-
# Contains methods to help you manage and configure your SUTs
|
|
12
|
-
|
|
9
|
+
# Contains methods to help you manage and configure your SUTs.
|
|
10
|
+
|
|
11
|
+
# Extensions, available in separate modules, enable you to configure and interact with puppet, facter
|
|
12
|
+
# and hiera. See [the docs](/docs/how_to/the_beaker_dsl.md).
|
|
13
13
|
|
|
14
14
|
# To mix this is into a class you need the following:
|
|
15
15
|
# * a method *hosts* that yields any hosts implementing
|
|
@@ -28,8 +28,6 @@ module Beaker
|
|
|
28
28
|
include Beaker::DSL::Helpers::TestHelpers
|
|
29
29
|
include Beaker::DSL::Helpers::WebHelpers
|
|
30
30
|
include Beaker::DSL::Helpers::HoconHelpers
|
|
31
|
-
include Beaker::DSL::Helpers::Hiera
|
|
32
|
-
include BeakerPuppet::Helpers
|
|
33
31
|
end
|
|
34
32
|
end
|
|
35
33
|
end
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
require "beaker/dsl/install_utils/pe_defaults"
|
|
2
|
-
require 'beaker-puppet'
|
|
3
|
-
|
|
4
1
|
module Beaker
|
|
5
2
|
module DSL
|
|
6
3
|
# Collection of installation methods and support
|
|
7
4
|
module InstallUtils
|
|
8
|
-
include DSL::InstallUtils::PEDefaults
|
|
9
|
-
include BeakerPuppet::InstallUtils
|
|
10
5
|
end
|
|
11
6
|
end
|
|
12
7
|
end
|
data/lib/beaker/dsl/roles.rb
CHANGED
|
@@ -139,7 +139,7 @@ module Beaker
|
|
|
139
139
|
return !version_is_less(version, '4.0') if version && !version.empty?
|
|
140
140
|
end
|
|
141
141
|
return true if host[:roles] && host[:roles].include?('aio')
|
|
142
|
-
return true if host[:type] && !!(host[:type] =~ /(\A|-)aio(\Z|-)/ )
|
|
142
|
+
return true if host[:type] && !!(host[:type] =~ /(\A|-)(aio|git)(\Z|-)/ )
|
|
143
143
|
false
|
|
144
144
|
end
|
|
145
145
|
|
data/lib/beaker/dsl.rb
CHANGED
|
@@ -83,6 +83,13 @@ module Beaker
|
|
|
83
83
|
|
|
84
84
|
def self.register(helper_module)
|
|
85
85
|
include helper_module
|
|
86
|
+
|
|
87
|
+
# Modules added into a module which has previously been included are not
|
|
88
|
+
# retroactively included in the including class. Do this here so we don't
|
|
89
|
+
# have to in every DSL extension library.
|
|
90
|
+
#
|
|
91
|
+
# https://github.com/adrianomitre/retroactive_module_inclusion
|
|
92
|
+
Beaker::TestCase.class_eval { include Beaker::DSL }
|
|
86
93
|
end
|
|
87
94
|
end
|
|
88
95
|
end
|
data/lib/beaker/host/aix/file.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Aix::File
|
|
2
2
|
include Beaker::CommandFactory
|
|
3
3
|
|
|
4
|
-
def tmpfile(name)
|
|
4
|
+
def tmpfile(name = '')
|
|
5
5
|
execute("rndnum=${RANDOM} && touch /tmp/#{name}.${rndnum} && echo /tmp/#{name}.${rndnum}")
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def tmpdir(name)
|
|
8
|
+
def tmpdir(name = '')
|
|
9
9
|
execute("rndnum=${RANDOM} && mkdir /tmp/#{name}.${rndnum} && echo /tmp/#{name}.${rndnum}")
|
|
10
10
|
end
|
|
11
11
|
|
data/lib/beaker/host/aix/user.rb
CHANGED
|
@@ -25,6 +25,15 @@ module FreeBSD::Pkg
|
|
|
25
25
|
execute(cmd, opts) { |result| result }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def uninstall_package(package, cmdline_args = nil, opts = {})
|
|
29
|
+
cmd = if pkgng_active?
|
|
30
|
+
"pkg delete #{cmdline_args || '-y'} #{package}"
|
|
31
|
+
else
|
|
32
|
+
"pkg_delete #{cmdline_args || '-r'} #{package}"
|
|
33
|
+
end
|
|
34
|
+
execute(cmd, opts) { |result| result }
|
|
35
|
+
end
|
|
36
|
+
|
|
28
37
|
def check_for_package(package, opts = {})
|
|
29
38
|
opts = {:accept_all_exit_codes => true}.merge(opts)
|
|
30
39
|
cmd = if pkgng_active?
|
data/lib/beaker/host/mac/user.rb
CHANGED
|
@@ -21,28 +21,23 @@ module Mac::User
|
|
|
21
21
|
|
|
22
22
|
# Gets the user information in /etc/passwd format
|
|
23
23
|
#
|
|
24
|
+
# @note Calls POSIX-compliant `$ id -P <user>` to get /etc/passwd-style
|
|
25
|
+
# output
|
|
26
|
+
#
|
|
24
27
|
# @param [String] name Name of the user
|
|
25
28
|
# @param [Proc] block Additional actions or insertions
|
|
26
29
|
#
|
|
27
|
-
# @yield [
|
|
28
|
-
# @return [
|
|
30
|
+
# @yield [Result] User information in /etc/passwd format
|
|
31
|
+
# @return [Result] User information in /etc/passwd format
|
|
29
32
|
# @raise [FailTest] Raises an Assertion failure if it can't find the name
|
|
30
33
|
# queried for in the returned block
|
|
31
34
|
def user_get(name, &block)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fail_test "failed to get user #{name}" unless result.stdout =~ /^name: #{name}/
|
|
35
|
-
ui = Hash.new # user info
|
|
36
|
-
result.stdout.each_line { |line|
|
|
37
|
-
pieces = line.split(': ')
|
|
38
|
-
ui[pieces[0].to_sym] = pieces[1].strip if pieces[1] != nil
|
|
39
|
-
}
|
|
40
|
-
answer = "#{ui[:name]}:#{ui[:password]}:#{ui[:uid]}:#{ui[:gid]}:"
|
|
41
|
-
answer << "#{ui[:name]}:#{ui[:dir]}:#{ui[:shell]}"
|
|
35
|
+
execute("id -P #{name}") do |result|
|
|
36
|
+
fail_test "failed to get user #{name}" unless result.stdout =~ /^#{name}:/
|
|
42
37
|
|
|
43
38
|
yield result if block_given?
|
|
39
|
+
result
|
|
44
40
|
end
|
|
45
|
-
answer
|
|
46
41
|
end
|
|
47
42
|
|
|
48
43
|
# Makes sure the user is present, creating them if necessary
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module PSWindows::File
|
|
2
2
|
include Beaker::CommandFactory
|
|
3
3
|
|
|
4
|
-
def tmpfile(name)
|
|
4
|
+
def tmpfile(name = '')
|
|
5
5
|
result = exec(powershell('[System.IO.Path]::GetTempFileName()'))
|
|
6
6
|
result.stdout.chomp()
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def tmpdir(name)
|
|
9
|
+
def tmpdir(name = '')
|
|
10
10
|
result = exec(powershell('[System.IO.Path]::GetTempPath()'))
|
|
11
11
|
result.stdout.chomp()
|
|
12
12
|
end
|
|
@@ -189,25 +189,25 @@ module Unix::Exec
|
|
|
189
189
|
def ssh_permit_user_environment
|
|
190
190
|
case self['platform']
|
|
191
191
|
when /debian|ubuntu|cumulus|huaweios|archlinux/
|
|
192
|
-
directory =
|
|
192
|
+
directory = tmpdir()
|
|
193
193
|
exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
|
|
194
194
|
exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
|
|
195
195
|
when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7/
|
|
196
|
-
directory =
|
|
196
|
+
directory = tmpdir()
|
|
197
197
|
exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
|
|
198
198
|
exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
|
|
199
199
|
when /el-|centos|fedora|redhat|oracle|scientific|eos/
|
|
200
|
-
directory =
|
|
200
|
+
directory = tmpdir()
|
|
201
201
|
exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
|
|
202
202
|
exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
|
|
203
203
|
when /sles/
|
|
204
|
-
directory =
|
|
204
|
+
directory = tmpdir()
|
|
205
205
|
exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
|
|
206
206
|
exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
|
|
207
207
|
when /solaris/
|
|
208
208
|
# kept solaris here because refactoring it into its own Host module
|
|
209
209
|
# conflicts with the solaris hypervisor that already exists
|
|
210
|
-
directory =
|
|
210
|
+
directory = tmpdir()
|
|
211
211
|
exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
|
|
212
212
|
exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
|
|
213
213
|
when /(free|open)bsd/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Unix::File
|
|
2
2
|
include Beaker::CommandFactory
|
|
3
3
|
|
|
4
|
-
def tmpfile(name)
|
|
4
|
+
def tmpfile(name = '')
|
|
5
5
|
execute("mktemp -t #{name}.XXXXXX")
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def tmpdir(name)
|
|
8
|
+
def tmpdir(name = '')
|
|
9
9
|
execute("mktemp -dt #{name}.XXXXXX")
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -13,6 +13,47 @@ module Unix::File
|
|
|
13
13
|
'/tmp'
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
# Change user ownership of a path
|
|
17
|
+
#
|
|
18
|
+
# @see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chown.html
|
|
19
|
+
#
|
|
20
|
+
# @note To maintain argument order consistency with the underlying
|
|
21
|
+
# syscall, avoid having to specify nil arguments, and not do
|
|
22
|
+
# anything hacky with the arguments list, this method does not
|
|
23
|
+
# allow you to modify group ownership. Use Host::chgrp instead.
|
|
24
|
+
# @param [String] user User to chown to
|
|
25
|
+
# @param [String] path Path to chown
|
|
26
|
+
# @param [Boolean] recursive Whether to pass the recursive flag
|
|
27
|
+
#
|
|
28
|
+
# @return [Beaker::Result] result of command execution
|
|
29
|
+
def chown(user, path, recursive=false)
|
|
30
|
+
execute("chown #{recursive ? '-R ' : ''}#{user} #{path}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Change group ownership of a path
|
|
34
|
+
#
|
|
35
|
+
# @see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chgrp.html
|
|
36
|
+
#
|
|
37
|
+
# @param [String] group Group to chgrp to
|
|
38
|
+
# @param [String] path Path to chgrp
|
|
39
|
+
# @param [Boolean] recursive Whether to pass the recursive flag
|
|
40
|
+
#
|
|
41
|
+
# @return [Beaker::Result] result of command execution
|
|
42
|
+
def chgrp(group, path, recursive=false)
|
|
43
|
+
execute("chgrp #{recursive ? '-R ' : ''}#{group} #{path}")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# List long output of a path
|
|
47
|
+
#
|
|
48
|
+
# @see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html
|
|
49
|
+
#
|
|
50
|
+
# @param [String] path Path to list properties of
|
|
51
|
+
#
|
|
52
|
+
# @return [Beaker::Result] result of command execution
|
|
53
|
+
def ls_ld(path)
|
|
54
|
+
execute("ls -ld #{path}")
|
|
55
|
+
end
|
|
56
|
+
|
|
16
57
|
# Handles any changes needed in a path for SCP
|
|
17
58
|
#
|
|
18
59
|
# @param [String] path File path to SCP to
|
data/lib/beaker/host/unix/pkg.rb
CHANGED
|
@@ -417,8 +417,15 @@ module Unix::Pkg
|
|
|
417
417
|
puppet_collection, puppet_agent_version, opts )
|
|
418
418
|
when /^(sles|aix|el|centos|oracle|redhat|scientific)$/
|
|
419
419
|
variant = 'el' if variant.match(/(?:el|centos|oracle|redhat|scientific)/)
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
if variant == 'aix'
|
|
421
|
+
arch = 'ppc' if arch == 'power'
|
|
422
|
+
version_x, version_y = /^(\d+)\.(\d+)/.match(puppet_agent_version).captures.map(&:to_i)
|
|
423
|
+
if version_x < 5 || version_x == 5 && version_y < 99 # 5.99.z indicates pre-release puppet6
|
|
424
|
+
version = '7.1' if version == '7.2'
|
|
425
|
+
else
|
|
426
|
+
version = '6.1'
|
|
427
|
+
end
|
|
428
|
+
end
|
|
422
429
|
release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
|
|
423
430
|
release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.rpm"
|
|
424
431
|
else
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Windows::File
|
|
2
2
|
include Beaker::CommandFactory
|
|
3
3
|
|
|
4
|
-
def tmpfile(name)
|
|
4
|
+
def tmpfile(name = '')
|
|
5
5
|
execute("cygpath -m $(mktemp -t #{name}.XXXXXX)")
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def tmpdir(name)
|
|
8
|
+
def tmpdir(name = '')
|
|
9
9
|
execute("cygpath -m $(mktemp -td #{name}.XXXXXX)")
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -15,6 +15,36 @@ module Windows::File
|
|
|
15
15
|
tmp_path.gsub(/\n/, '') + '\\TEMP'
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
# (see {Beaker::Host::Unix::File#chown})
|
|
19
|
+
# @note Cygwin's `chown` implementation does not support
|
|
20
|
+
# windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style.
|
|
21
|
+
# This method simply wraps the normal Host#chown call with
|
|
22
|
+
# a call to cygpath to sanitize input.
|
|
23
|
+
def chown(user, path, recursive=false)
|
|
24
|
+
cygpath = execute("cygpath -u #{path}")
|
|
25
|
+
super(user, cygpath, recursive)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# (see {Beaker::Host::Unix::File#chgrp})
|
|
29
|
+
# @note Cygwin's `chgrp` implementation does not support
|
|
30
|
+
# windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style.
|
|
31
|
+
# This method simply wraps the normal Host#chgrp call with
|
|
32
|
+
# a call to cygpath to sanitize input.
|
|
33
|
+
def chgrp(group, path, recursive=false)
|
|
34
|
+
cygpath = execute("cygpath -u #{path}")
|
|
35
|
+
super(group, cygpath, recursive)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# (see {Beaker::Host::Unix::File#ls_ld})
|
|
39
|
+
# @note Cygwin's `ls_ld` implementation does not support
|
|
40
|
+
# windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style.
|
|
41
|
+
# This method simply wraps the normal Host#ls_ld call with
|
|
42
|
+
# a call to cygpath to sanitize input.
|
|
43
|
+
def ls_ld(path)
|
|
44
|
+
cygpath = execute("cygpath -u #{path}")
|
|
45
|
+
super(cygpath)
|
|
46
|
+
end
|
|
47
|
+
|
|
18
48
|
# Updates a file path for use with SCP, depending on the SSH Server
|
|
19
49
|
#
|
|
20
50
|
# @note This will fail with an SSH server that is not OpenSSL or BitVise.
|
data/lib/beaker/host.rb
CHANGED
|
@@ -502,6 +502,8 @@ module Beaker
|
|
|
502
502
|
# @param to_path [String] The destination path on the host
|
|
503
503
|
# @param opts [Hash{Symbol=>String}] Options to alter execution
|
|
504
504
|
# @option opts [Array<String>] :ignore An array of file/dir paths that will not be copied to the host
|
|
505
|
+
# @raise [Beaker::Host::CommandFailure] With Rsync error (if available)
|
|
506
|
+
# @return [Rsync::Result] Rsync result with status code
|
|
505
507
|
def do_rsync_to from_path, to_path, opts = {}
|
|
506
508
|
ssh_opts = self['ssh']
|
|
507
509
|
rsync_args = []
|
|
@@ -532,18 +534,15 @@ module Beaker
|
|
|
532
534
|
ssh_opts.has_key?('auth_methods') and
|
|
533
535
|
ssh_opts['auth_methods'].include?('publickey')
|
|
534
536
|
|
|
535
|
-
key
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
if key.is_a? Array
|
|
539
|
-
key = key.first
|
|
537
|
+
# find the first SSH key that exists
|
|
538
|
+
key = Array(ssh_opts['keys']).find do |k|
|
|
539
|
+
File.exist?(k)
|
|
540
540
|
end
|
|
541
541
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
ssh_args << "-i #{key}"
|
|
542
|
+
if key
|
|
543
|
+
# rsync doesn't always play nice with tilde, so be sure to expand first
|
|
544
|
+
ssh_args << "-i #{File.expand_path(key)}"
|
|
545
|
+
end
|
|
547
546
|
end
|
|
548
547
|
end
|
|
549
548
|
|
|
@@ -571,7 +570,9 @@ module Beaker
|
|
|
571
570
|
@logger.notify "rsync: localhost:#{from_path} to #{hostname_with_user}:#{to_path} {:ignore => #{opts[:ignore]}}"
|
|
572
571
|
result = Rsync.run(from_path, to_path, rsync_args)
|
|
573
572
|
@logger.debug("rsync returned #{result.inspect}")
|
|
574
|
-
|
|
573
|
+
|
|
574
|
+
return result if result.success?
|
|
575
|
+
raise Beaker::Host::CommandFailure, result.error
|
|
575
576
|
end
|
|
576
577
|
|
|
577
578
|
end
|
|
@@ -258,7 +258,7 @@ module Beaker
|
|
|
258
258
|
if result.exit_code == 1
|
|
259
259
|
url_base = opts[:epel_url]
|
|
260
260
|
url_base = opts[:epel_url_archive] if host['platform'].version == '5'
|
|
261
|
-
host.
|
|
261
|
+
host.install_package_with_rpm("#{url_base}/epel-release-latest-#{host['platform'].version}.noarch.rpm", '--replacepkgs', { :package_proxy => opts[:package_proxy] })
|
|
262
262
|
#update /etc/yum.repos.d/epel.repo for new baseurl
|
|
263
263
|
host.exec(Command.new("sed -i -e 's;#baseurl.*$;baseurl=#{Regexp.escape("#{url_base}/#{host['platform'].version}")}/\$basearch;' /etc/yum.repos.d/epel.repo"))
|
|
264
264
|
#remove mirrorlist
|
|
@@ -573,10 +573,6 @@ module Beaker
|
|
|
573
573
|
logger.debug(skip_msg)
|
|
574
574
|
end
|
|
575
575
|
|
|
576
|
-
# REMOVE POST BEAKER 3: backwards compatability, do some setup based upon the global type
|
|
577
|
-
# this is the worst and i hate it
|
|
578
|
-
Class.new.extend(Beaker::DSL).configure_type_defaults_on(host)
|
|
579
|
-
|
|
580
576
|
if skip_msg.nil?
|
|
581
577
|
#close the host to re-establish the connection with the new sshd settings
|
|
582
578
|
host.close
|
data/lib/beaker/hypervisor.rb
CHANGED
|
@@ -28,11 +28,7 @@ module Beaker
|
|
|
28
28
|
Beaker::Hypervisor
|
|
29
29
|
else
|
|
30
30
|
# Custom hypervisor
|
|
31
|
-
|
|
32
|
-
require "beaker/hypervisor/#{type}"
|
|
33
|
-
rescue LoadError
|
|
34
|
-
raise "Invalid hypervisor: #{type}"
|
|
35
|
-
end
|
|
31
|
+
require "beaker/hypervisor/#{type}"
|
|
36
32
|
Beaker.const_get(type.split('_').collect(&:capitalize).join)
|
|
37
33
|
end
|
|
38
34
|
|
data/lib/beaker/logger.rb
CHANGED
|
@@ -203,7 +203,7 @@ module Beaker
|
|
|
203
203
|
end
|
|
204
204
|
else
|
|
205
205
|
# Remove invalid and undefined UTF-8 character encodings
|
|
206
|
-
string.to_s.force_encoding('UTF-8')
|
|
206
|
+
string = string.to_s.dup.force_encoding('UTF-8')
|
|
207
207
|
return string.to_s.chars.select{|i| i.valid_encoding?}.join
|
|
208
208
|
end
|
|
209
209
|
end
|
data/lib/beaker/result.rb
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'stringify-hash'
|
|
2
|
+
|
|
3
|
+
module Beaker
|
|
4
|
+
module Shared
|
|
5
|
+
# A set of functions to read .fog files
|
|
6
|
+
module FogCredentials
|
|
7
|
+
# Constructs ArgumentError with common phrasing for #get_fog_credentials errors
|
|
8
|
+
#
|
|
9
|
+
# @param path [String] path to offending file
|
|
10
|
+
# @param from_env [String] if the path was overridden in ENV
|
|
11
|
+
# @param reason [String] explanation for the failure
|
|
12
|
+
# @return [ArgumentError] ArgumentError with preformatted message
|
|
13
|
+
def fog_credential_error(path = nil, from_env = nil, reason = nil)
|
|
14
|
+
message = "Failed loading credentials from .fog file"
|
|
15
|
+
message << " '#{path}'" if path
|
|
16
|
+
message << " #{from_env}" if from_env
|
|
17
|
+
message << "."
|
|
18
|
+
message << "Reason: #{reason}" if reason
|
|
19
|
+
ArgumentError.new(message)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Load credentials from a .fog file
|
|
23
|
+
#
|
|
24
|
+
# @note Loaded .fog files may use symbols for keys.
|
|
25
|
+
# Although not clearly documented, it is valid:
|
|
26
|
+
# https://www.rubydoc.info/gems/fog-core/1.42.0/Fog#credential-class_method
|
|
27
|
+
# https://github.com/fog/fog-core/blob/7865ef77ea990fd0d085e49c28e15957b7ce0d2b/spec/utils_spec.rb#L11
|
|
28
|
+
#
|
|
29
|
+
# @param fog_file_path [String] dot fog path. Overridden by ENV["FOG_RC"]
|
|
30
|
+
# @param credential_group [String, Symbol] Credential group to use. Overridden by ENV["FOG_CREDENTIAL"]
|
|
31
|
+
# @return [StringifyHash] credentials stored in fog_file_path
|
|
32
|
+
# @raise [ArgumentError] when the credentials cannot be loaded, describing the reson
|
|
33
|
+
def get_fog_credentials(fog_file_path = '~/.fog', credential_group = :default)
|
|
34
|
+
# respect file location from env
|
|
35
|
+
if ENV["FOG_RC"]
|
|
36
|
+
fog_file_path = ENV["FOG_RC"]
|
|
37
|
+
from_env = ' set in ENV["FOG_RC"]'
|
|
38
|
+
end
|
|
39
|
+
begin
|
|
40
|
+
fog = YAML.load_file(fog_file_path)
|
|
41
|
+
rescue Psych::SyntaxError, Errno::ENOENT => e
|
|
42
|
+
raise fog_credential_error fog_file_path, from_env, "(#{e.class}) #{e.message}"
|
|
43
|
+
end
|
|
44
|
+
if fog == false # YAML.load => false for empty file
|
|
45
|
+
raise fog_credential_error fog_file_path, from_env, "is empty."
|
|
46
|
+
end
|
|
47
|
+
# transparently support symbols or strings for keys
|
|
48
|
+
fog = StringifyHash.new.merge!(fog)
|
|
49
|
+
# respect credential from env
|
|
50
|
+
# @note ENV must be a string, e.g. "default" not ":default"
|
|
51
|
+
if ENV["FOG_CREDENTIAL"]
|
|
52
|
+
credential_group = ENV["FOG_CREDENTIAL"].to_sym
|
|
53
|
+
end
|
|
54
|
+
if not fog[credential_group]
|
|
55
|
+
raise fog_credential_error fog_file_path, from_env, "could not load the specified credential group '#{credential_group}'."
|
|
56
|
+
end
|
|
57
|
+
fog[credential_group]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -33,9 +33,10 @@ module Beaker
|
|
|
33
33
|
#@param [Array<Host>] hosts The hosts to examine
|
|
34
34
|
#@param [String] role The host returned will have this role in its role list
|
|
35
35
|
#@return [Host] The single host with the desired role in its roles list
|
|
36
|
-
#@raise [ArgumentError] Raised if more than one host has the given role defined,
|
|
37
|
-
# role defined.
|
|
36
|
+
#@raise [ArgumentError] Raised if more than one host has the given role defined, if no host has the
|
|
37
|
+
# role defined, or if role = nil since hosts_with_role(nil) returns all hosts.
|
|
38
38
|
def only_host_with_role(hosts, role)
|
|
39
|
+
raise ArgumentError, "role cannot be nil." if role.nil?
|
|
39
40
|
a_host = hosts_with_role(hosts, role)
|
|
40
41
|
case
|
|
41
42
|
when a_host.length == 0
|
|
@@ -53,8 +54,10 @@ module Beaker
|
|
|
53
54
|
# @param [String] role The host returned will have this role in its role list
|
|
54
55
|
# @return [Host] The single host with the desired role in its roles list
|
|
55
56
|
# or nil if no host is found
|
|
56
|
-
# @raise [ArgumentError] Raised if more than one host has the given role defined
|
|
57
|
+
# @raise [ArgumentError] Raised if more than one host has the given role defined,
|
|
58
|
+
# or if role = nil since hosts_with_role(nil) returns all hosts.
|
|
57
59
|
def find_at_most_one_host_with_role(hosts, role)
|
|
60
|
+
raise ArgumentError, "role cannot be nil." if role.nil?
|
|
58
61
|
role_hosts = hosts_with_role(hosts, role)
|
|
59
62
|
host_with_role = nil
|
|
60
63
|
case role_hosts.length
|