beaker 4.40.2 → 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 +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +17 -28
- data/Gemfile +12 -7
- 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 +80 -82
- data/lib/beaker/host/unix/file.rb +38 -43
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +154 -417
- 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 +93 -198
- 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 -24
- 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 +22 -27
- 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 +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 -73
- data/spec/beaker/host/unix/pkg_spec.rb +155 -401
- 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 +172 -326
- 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 -36
- 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 +48 -53
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +7 -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/dsl/outcomes.rb
CHANGED
@@ -15,7 +15,6 @@ module Beaker
|
|
15
15
|
# designed to allow some degree of freedom from the individual third
|
16
16
|
# party test runners that could be used.
|
17
17
|
module Outcomes
|
18
|
-
|
19
18
|
# Raise this class if it is determined that a test case should not
|
20
19
|
# be executed because the feature in question is still a
|
21
20
|
# "Work in Progress"
|
@@ -32,16 +31,15 @@ module Beaker
|
|
32
31
|
# shown itself to pass the test.
|
33
32
|
class PassTest < RuntimeError; end
|
34
33
|
|
35
|
-
|
36
34
|
# Raises FailTest Exception and logs an error message
|
37
35
|
#
|
38
36
|
# @param [String] msg An optional message to log
|
39
37
|
# @raise [FailTest]
|
40
38
|
def fail_test msg = nil
|
41
|
-
message = formatted_message(
|
42
|
-
logger.warn(
|
39
|
+
message = formatted_message(msg, 'Failed')
|
40
|
+
logger.warn([message, logger.pretty_backtrace].join("\n"))
|
43
41
|
|
44
|
-
raise(
|
42
|
+
raise(FailTest, message)
|
45
43
|
end
|
46
44
|
|
47
45
|
# Raises PassTest Exception and logs a message
|
@@ -49,10 +47,10 @@ module Beaker
|
|
49
47
|
# @param [String] msg An optional message to log
|
50
48
|
# @raise [PassTest]
|
51
49
|
def pass_test msg = nil
|
52
|
-
message = formatted_message(
|
53
|
-
logger.notify(
|
50
|
+
message = formatted_message(msg, 'Passed')
|
51
|
+
logger.notify(message)
|
54
52
|
|
55
|
-
raise(
|
53
|
+
raise(PassTest, message)
|
56
54
|
end
|
57
55
|
|
58
56
|
# Raises PendingTest Exception and logs an error message
|
@@ -60,10 +58,10 @@ module Beaker
|
|
60
58
|
# @param [String] msg An optional message to log
|
61
59
|
# @raise [PendingTest]
|
62
60
|
def pending_test msg = nil
|
63
|
-
message = formatted_message(
|
64
|
-
logger.warn(
|
61
|
+
message = formatted_message(msg, 'is Pending')
|
62
|
+
logger.warn(message)
|
65
63
|
|
66
|
-
raise(
|
64
|
+
raise(PendingTest, message)
|
67
65
|
end
|
68
66
|
|
69
67
|
# Raises SkipTest Exception and logs a message
|
@@ -71,10 +69,10 @@ module Beaker
|
|
71
69
|
# @param [String] msg An optional message to log
|
72
70
|
# @raise [SkipTest]
|
73
71
|
def skip_test msg = nil
|
74
|
-
message = formatted_message(
|
75
|
-
logger.notify(
|
72
|
+
message = formatted_message(msg, 'was Skipped')
|
73
|
+
logger.notify(message)
|
76
74
|
|
77
|
-
raise(
|
75
|
+
raise(SkipTest, message)
|
78
76
|
end
|
79
77
|
|
80
78
|
# populate a TestCase's @exports[] with structured_data
|
@@ -93,7 +91,7 @@ module Beaker
|
|
93
91
|
#
|
94
92
|
# @return [String] A prettier string with helpful info
|
95
93
|
# @!visibility private
|
96
|
-
def formatted_message(message, default_str
|
94
|
+
def formatted_message(message, default_str)
|
97
95
|
msg = message ? "\n#{message}\n" : "\n#{self} #{default_str}.\n"
|
98
96
|
return msg
|
99
97
|
end
|
data/lib/beaker/dsl/patterns.rb
CHANGED
@@ -10,7 +10,6 @@ module Beaker
|
|
10
10
|
# and #to_s available and provide an array when #[]('roles') is called.
|
11
11
|
#
|
12
12
|
module Patterns
|
13
|
-
|
14
13
|
# Execute a block selecting the hosts that match with the provided criteria
|
15
14
|
# @param [Array<Host>, Host, String, Symbol] hosts_or_filter A host role as a String or Symbol that can be
|
16
15
|
# used to search for a set of Hosts, a host name
|
@@ -23,7 +22,7 @@ module Beaker
|
|
23
22
|
#
|
24
23
|
# @return [Array<Result>, Result, nil] An array of results, a result object, or nil.
|
25
24
|
# Check {Beaker::Shared::HostManager#run_block_on} for more details on this.
|
26
|
-
def block_on hosts_or_filter, opts={}, &block
|
25
|
+
def block_on hosts_or_filter, opts = {}, &block
|
27
26
|
block_hosts = nil
|
28
27
|
if defined? hosts
|
29
28
|
block_hosts = hosts
|
@@ -36,7 +35,6 @@ module Beaker
|
|
36
35
|
end
|
37
36
|
run_block_on block_hosts, filter, opts, &block
|
38
37
|
end
|
39
|
-
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
data/lib/beaker/dsl/roles.rb
CHANGED
@@ -14,7 +14,6 @@ module Beaker
|
|
14
14
|
# in error conditions
|
15
15
|
#
|
16
16
|
module Roles
|
17
|
-
|
18
17
|
# The hosts for which ['roles'] include 'agent'
|
19
18
|
#
|
20
19
|
# @return [Array<Host>] May be empty
|
@@ -100,7 +99,7 @@ module Beaker
|
|
100
99
|
# end
|
101
100
|
#
|
102
101
|
def not_controller(host)
|
103
|
-
controllers = [
|
102
|
+
controllers = %w[dashboard database master console]
|
104
103
|
matched_roles = host['roles'].select { |v| controllers.include?(v) }
|
105
104
|
matched_roles.length == 0
|
106
105
|
end
|
@@ -116,7 +115,7 @@ module Beaker
|
|
116
115
|
#
|
117
116
|
# @return [Boolean] True if agent-only, false otherwise
|
118
117
|
def agent_only(host)
|
119
|
-
|
118
|
+
host['roles'].length == 1 && host['roles'].include?('agent')
|
120
119
|
end
|
121
120
|
|
122
121
|
# Determine whether a host has an AIO version or not. If a host :pe_ver or
|
@@ -134,12 +133,13 @@ module Beaker
|
|
134
133
|
#
|
135
134
|
# @return [Boolean] whether or not a host is AIO-capable
|
136
135
|
def aio_version?(host)
|
137
|
-
[
|
136
|
+
%i[pe_ver version].each do |key|
|
138
137
|
version = host[key]
|
139
138
|
return !version_is_less(version, '4.0') if version && !version.empty?
|
140
139
|
end
|
141
140
|
return true if host[:roles] && host[:roles].include?('aio')
|
142
141
|
return true if host[:type] && /(\A|-)aio(\Z|-)/.match(host[:type])
|
142
|
+
|
143
143
|
false
|
144
144
|
end
|
145
145
|
|
@@ -160,31 +160,28 @@ module Beaker
|
|
160
160
|
host[:roles] = host[:roles] | [role]
|
161
161
|
end
|
162
162
|
|
163
|
-
#Create a new role method for a given arbitrary role name. Makes it possible to be able to run
|
164
|
-
#commands without having to refer to role by String or Symbol. Will not add a new method
|
165
|
-
#definition if the name is already in use.
|
163
|
+
# Create a new role method for a given arbitrary role name. Makes it possible to be able to run
|
164
|
+
# commands without having to refer to role by String or Symbol. Will not add a new method
|
165
|
+
# definition if the name is already in use.
|
166
166
|
# @param [String, Symbol, Array[String,Symbol]] role The role that you wish to create a definition for, either a String
|
167
167
|
# Symbol or an Array of Strings or Symbols.
|
168
168
|
# @example Basic usage
|
169
169
|
# add_role_def('myrole')
|
170
170
|
# on myrole, "run command"
|
171
171
|
def add_role_def role
|
172
|
-
if role.
|
172
|
+
if role.is_a?(Array)
|
173
173
|
role.each do |r|
|
174
174
|
add_role_def r
|
175
175
|
end
|
176
|
-
|
177
|
-
if
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
186
|
-
hosts_with_role
|
187
|
-
end
|
176
|
+
elsif not respond_to? role
|
177
|
+
if !/\A[[:alpha:]]+[a-zA-Z0-9_]*[!?=]?\Z/.match?(role)
|
178
|
+
raise ArgumentError, "Role name format error for '#{role}'. Allowed characters are: \na-Z\n0-9 (as long as not at the beginning of name)\n'_'\n'?', '!' and '=' (only as individual last character at end of name)"
|
179
|
+
end
|
180
|
+
|
181
|
+
self.class.send :define_method, role.to_s do
|
182
|
+
hosts_with_role = hosts_as role.to_sym
|
183
|
+
hosts_with_role = hosts_with_role.pop if hosts_with_role.length == 1
|
184
|
+
hosts_with_role
|
188
185
|
end
|
189
186
|
end
|
190
187
|
end
|
data/lib/beaker/dsl/structure.rb
CHANGED
@@ -37,32 +37,30 @@ module Beaker
|
|
37
37
|
def step step_name, &block
|
38
38
|
logger.notify "\n* #{step_name}\n"
|
39
39
|
set_current_step_name(step_name)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
return unless block
|
41
|
+
|
42
|
+
begin
|
43
|
+
logger.with_indent(&block)
|
44
|
+
rescue Exception => e
|
45
|
+
if @options.has_key?(:debug_errors) && @options[:debug_errors] == true
|
46
|
+
begin
|
47
|
+
require 'pry'
|
48
|
+
rescue LoadError
|
47
49
|
begin
|
48
|
-
require '
|
50
|
+
require 'debug'
|
49
51
|
rescue LoadError
|
50
|
-
|
51
|
-
require 'debug'
|
52
|
-
rescue LoadError
|
53
|
-
logger.exception('Unable to load pry and debug while debug_errors was true')
|
54
|
-
else
|
55
|
-
logger.info("Exception raised during step execution and debug-errors option is set, entering debug. Exception was: #{e.inspect}")
|
56
|
-
binding.break
|
57
|
-
end
|
52
|
+
logger.exception('Unable to load pry and debug while debug_errors was true')
|
58
53
|
else
|
59
|
-
logger.info("Exception raised during step execution and debug-errors option is set, entering
|
60
|
-
|
61
|
-
binding.pry # rubocop:disable Lint/Debugger
|
54
|
+
logger.info("Exception raised during step execution and debug-errors option is set, entering debug. Exception was: #{e.inspect}")
|
55
|
+
binding.break # rubocop:disable Lint/Debugger
|
62
56
|
end
|
57
|
+
else
|
58
|
+
logger.info("Exception raised during step execution and debug-errors option is set, entering pry. Exception was: #{e.inspect}")
|
59
|
+
logger.info("HINT: Use the pry 'backtrace' and 'up' commands to navigate to the test code")
|
60
|
+
binding.pry # rubocop:disable Lint/Debugger
|
63
61
|
end
|
64
|
-
raise e
|
65
62
|
end
|
63
|
+
raise e
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
@@ -72,7 +70,7 @@ module Beaker
|
|
72
70
|
def manual_step step_name
|
73
71
|
require 'readline'
|
74
72
|
logger.notify "\n* #{step_name}\n"
|
75
|
-
if
|
73
|
+
if !@options.has_key?(:exec_manual_tests)
|
76
74
|
# if the option -exec-manual-tests is not set then this has executed outside of a manual tests
|
77
75
|
# so we raise an error to avoid issues
|
78
76
|
raise('--exec-manual-tests option not set, this means a manual_step was used outside a manual_test')
|
@@ -90,12 +88,10 @@ module Beaker
|
|
90
88
|
fail_message = ''
|
91
89
|
loop do
|
92
90
|
fail_message = Readline.readline('What was the reason for failure? ', true).squeeze(" ").strip
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
break
|
98
|
-
end
|
91
|
+
break unless fail_message == ''
|
92
|
+
|
93
|
+
# if nothing is entered we tell the user to enter something
|
94
|
+
puts "No reason for failure given, please enter reason for failure."
|
99
95
|
end
|
100
96
|
raise Beaker::DSL::FailTest, fail_message
|
101
97
|
else
|
@@ -112,14 +108,14 @@ module Beaker
|
|
112
108
|
# @param [Proc] block The actions to be performed during this test.
|
113
109
|
#
|
114
110
|
def manual_test manual_test_name, &block
|
115
|
-
if
|
111
|
+
if @options.has_key?(:exec_manual_tests) && @options[:exec_manual_tests] == true
|
116
112
|
# here the option is set so we run the test as normal
|
117
113
|
test_name manual_test_name, &block
|
118
114
|
else
|
119
115
|
# here no option was set so we log the test name and skip it
|
120
116
|
test_name manual_test_name
|
121
|
-
raise(
|
122
|
-
|
117
|
+
raise(Beaker::DSL::SkipTest,
|
118
|
+
'--exec-manual-tests option not set, so skipping manual test')
|
123
119
|
end
|
124
120
|
end
|
125
121
|
|
@@ -128,14 +124,12 @@ module Beaker
|
|
128
124
|
# @param [String] my_name The name of the test to be logged.
|
129
125
|
# @param [Proc] block The actions to be performed during this test.
|
130
126
|
#
|
131
|
-
def test_name my_name
|
127
|
+
def test_name my_name, &block
|
132
128
|
logger.notify "\n#{my_name}\n"
|
133
129
|
set_current_test_name(my_name)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|
130
|
+
return unless block
|
131
|
+
|
132
|
+
logger.with_indent(&block)
|
139
133
|
end
|
140
134
|
|
141
135
|
# Declare a teardown process that will be called after a test case is
|
@@ -192,15 +186,15 @@ module Beaker
|
|
192
186
|
# @author Chris Cowell-Shah (<tt>ccs@puppetlabs.com</tt>)
|
193
187
|
def expect_failure(explanation)
|
194
188
|
begin
|
195
|
-
yield if block_given?
|
189
|
+
yield if block_given? # code block should contain an assert that you expect to fail
|
196
190
|
rescue Beaker::DSL::Assertions, Minitest::Assertion => e
|
197
191
|
# Yay! The assert in the code block failed, as expected.
|
198
192
|
# Swallow the failure so the test passes.
|
199
193
|
logger.notify 'An assertion was expected to fail, and did. ' +
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
194
|
+
'This is probably due to a known product bug, ' +
|
195
|
+
'and is probably not a problem. ' +
|
196
|
+
"Additional info: '#{explanation}' " +
|
197
|
+
"Failed assertion: '#{e}'"
|
204
198
|
return
|
205
199
|
end
|
206
200
|
# Uh-oh! The assert in the code block unexpectedly passed.
|
@@ -268,22 +262,22 @@ module Beaker
|
|
268
262
|
# @raise [SkipTest] Raises skip test if there are no valid hosts for
|
269
263
|
# this test case after confinement.
|
270
264
|
def confine(type, criteria, host_array = nil, &block)
|
271
|
-
hosts_to_modify = Array(
|
272
|
-
hosts_not_modified = hosts - hosts_to_modify #we aren't examining these hosts
|
265
|
+
hosts_to_modify = Array(host_array || hosts)
|
266
|
+
hosts_not_modified = hosts - hosts_to_modify # we aren't examining these hosts
|
273
267
|
case type
|
274
268
|
when :except
|
275
|
-
if criteria and (
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
269
|
+
hosts_to_modify = if criteria and (not criteria.empty?)
|
270
|
+
hosts_to_modify - select_hosts(criteria, hosts_to_modify, &block) + hosts_not_modified
|
271
|
+
else
|
272
|
+
# confining to all hosts *except* provided array of hosts
|
273
|
+
hosts_not_modified
|
274
|
+
end
|
281
275
|
if hosts_to_modify.empty?
|
282
276
|
logger.warn "No suitable hosts without: #{criteria.inspect}"
|
283
277
|
skip_test "No suitable hosts found without #{criteria.inspect}"
|
284
278
|
end
|
285
279
|
when :to
|
286
|
-
if criteria and (
|
280
|
+
if criteria and (not criteria.empty?)
|
287
281
|
hosts_to_modify = select_hosts(criteria, hosts_to_modify, &block) + hosts_not_modified
|
288
282
|
else
|
289
283
|
# confining to only hosts in provided array of hosts
|
@@ -305,12 +299,11 @@ module Beaker
|
|
305
299
|
#
|
306
300
|
# @see #confine
|
307
301
|
def confine_block(type, criteria, host_array = nil)
|
308
|
-
host_array = Array(
|
302
|
+
host_array = Array(host_array || hosts)
|
309
303
|
original_hosts = self.hosts.dup
|
310
304
|
confine(type, criteria, host_array)
|
311
305
|
|
312
306
|
yield
|
313
|
-
|
314
307
|
rescue Beaker::DSL::Outcomes::SkipTest => e
|
315
308
|
# I don't like this much, but adding options to confine is a breaking change
|
316
309
|
# to the DSL that would involve a major version bump
|
@@ -322,7 +315,7 @@ module Beaker
|
|
322
315
|
self.hosts = original_hosts
|
323
316
|
end
|
324
317
|
|
325
|
-
#Return a set of hosts that meet the given criteria
|
318
|
+
# Return a set of hosts that meet the given criteria
|
326
319
|
# @param [Hash{Symbol,String=>String,Regexp,Array<String,Regexp>}]
|
327
320
|
# criteria Specify the criteria with which a host should be
|
328
321
|
# considered for inclusion. The key is any attribute
|
@@ -340,33 +333,28 @@ module Beaker
|
|
340
333
|
# should return true if the host matches this additional criteria.
|
341
334
|
#
|
342
335
|
# @return [Array<Host>] Returns an array of hosts that meet the provided criteria
|
343
|
-
def select_hosts(criteria, host_array = nil)
|
336
|
+
def select_hosts(criteria, host_array = nil, &block)
|
344
337
|
hosts_to_select_from = host_array || hosts
|
345
338
|
criteria.each_pair do |property, value|
|
346
339
|
hosts_to_select_from = hosts_to_select_from.select do |host|
|
347
340
|
inspect_host host, property, value
|
348
341
|
end
|
349
342
|
end
|
350
|
-
if
|
351
|
-
hosts_to_select_from = hosts_to_select_from.select do |host|
|
352
|
-
yield host
|
353
|
-
end
|
354
|
-
end
|
343
|
+
hosts_to_select_from = hosts_to_select_from.select(&block) if block
|
355
344
|
hosts_to_select_from
|
356
345
|
end
|
357
346
|
|
358
347
|
# @!visibility private
|
359
348
|
def inspect_host(host, property, one_or_more_values)
|
360
|
-
|
361
|
-
return values.any? do |value|
|
362
|
-
true_false = false
|
349
|
+
Array(one_or_more_values).any? do |value|
|
363
350
|
case value
|
364
351
|
when String
|
365
|
-
|
352
|
+
host[property.to_s].include? value
|
366
353
|
when Regexp
|
367
|
-
|
354
|
+
value.match?(host[property.to_s])
|
355
|
+
else
|
356
|
+
false
|
368
357
|
end
|
369
|
-
true_false
|
370
358
|
end
|
371
359
|
end
|
372
360
|
end
|
@@ -12,7 +12,6 @@ module Beaker
|
|
12
12
|
# - {Beaker::Options::Validator#validate_tags} ensures test tag CLI params
|
13
13
|
# are valid for use by this module
|
14
14
|
module TestTagging
|
15
|
-
|
16
15
|
# Sets tags on the current {Beaker::TestCase}, and skips testing
|
17
16
|
# if necessary after checking this case's tags against the ones that are
|
18
17
|
# being included or excluded.
|
@@ -65,22 +64,21 @@ module Beaker
|
|
65
64
|
# @!visibility private
|
66
65
|
def platform_specific_tag_confines
|
67
66
|
@options[:platform_tag_confines_object] ||= PlatformTagConfiner.new(
|
68
|
-
@options[:platform_tag_confines]
|
67
|
+
@options[:platform_tag_confines],
|
69
68
|
)
|
70
69
|
confines = @options[:platform_tag_confines_object].confine_details(
|
71
|
-
metadata[:case][:tags]
|
70
|
+
metadata[:case][:tags],
|
72
71
|
)
|
73
72
|
confines.each do |confine_details|
|
74
|
-
logger.notify(
|
73
|
+
logger.notify(confine_details[:log_message])
|
75
74
|
confine(
|
76
75
|
confine_details[:type],
|
77
|
-
:platform => confine_details[:platform_regex]
|
76
|
+
:platform => confine_details[:platform_regex],
|
78
77
|
)
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
81
|
class PlatformTagConfiner
|
83
|
-
|
84
82
|
# Constructs the PlatformTagConfiner, transforming the user format
|
85
83
|
# into the internal structure for use by Beaker itself.
|
86
84
|
#
|
@@ -122,7 +120,7 @@ module Beaker
|
|
122
120
|
@tag_confine_details_hash[tag] << {
|
123
121
|
:platform_regex => entry[:platform],
|
124
122
|
:log_message => log_msg,
|
125
|
-
:type => :except
|
123
|
+
:type => :except,
|
126
124
|
}
|
127
125
|
end
|
128
126
|
end
|
@@ -143,7 +141,7 @@ module Beaker
|
|
143
141
|
tag_confine_array = @tag_confine_details_hash[tag]
|
144
142
|
next if tag_confine_array.nil?
|
145
143
|
|
146
|
-
details.push(
|
144
|
+
details.push(*tag_confine_array)
|
147
145
|
# tag_confine_array.each do |confine_details|
|
148
146
|
# details << confine_details
|
149
147
|
# end
|
@@ -151,7 +149,6 @@ module Beaker
|
|
151
149
|
details
|
152
150
|
end
|
153
151
|
end
|
154
|
-
|
155
152
|
end
|
156
153
|
end
|
157
|
-
end
|
154
|
+
end
|
data/lib/beaker/dsl/wrappers.rb
CHANGED
@@ -8,7 +8,6 @@ module Beaker
|
|
8
8
|
# I find most of these adapters of suspicious value and have deprecated
|
9
9
|
# many of them.
|
10
10
|
module Wrappers
|
11
|
-
|
12
11
|
# @param [String] command_string A string of to be interpolated
|
13
12
|
# within the context of a host in
|
14
13
|
# question
|
@@ -36,13 +35,13 @@ module Beaker
|
|
36
35
|
# powershell("", {'-File' => '/path/to/file'})
|
37
36
|
#
|
38
37
|
# @return [Command]
|
39
|
-
def powershell(command, args={})
|
38
|
+
def powershell(command, args = {})
|
40
39
|
ps_opts = {
|
41
40
|
'ExecutionPolicy' => 'Bypass',
|
42
|
-
'InputFormat'
|
43
|
-
'NoLogo'
|
44
|
-
'NoProfile'
|
45
|
-
'NonInteractive'
|
41
|
+
'InputFormat' => 'None',
|
42
|
+
'NoLogo' => '',
|
43
|
+
'NoProfile' => '',
|
44
|
+
'NonInteractive' => '',
|
46
45
|
}
|
47
46
|
encoded = false
|
48
47
|
ps_opts.merge!(args)
|
@@ -56,20 +55,20 @@ module Beaker
|
|
56
55
|
end
|
57
56
|
|
58
57
|
ps_opts.each do |k, v|
|
59
|
-
if v.eql?('') or v.nil?
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
ps_args << if v.eql?('') or v.nil?
|
59
|
+
"-#{k}"
|
60
|
+
else
|
61
|
+
"-#{k} #{v}"
|
62
|
+
end
|
64
63
|
end
|
65
64
|
|
66
65
|
# may not have a command if executing a file
|
67
66
|
if command && !command.empty?
|
68
|
-
if encoded
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
ps_args << if encoded
|
68
|
+
"-EncodedCommand #{encode_command(command)}"
|
69
|
+
else
|
70
|
+
"-Command #{command}"
|
71
|
+
end
|
73
72
|
end
|
74
73
|
|
75
74
|
Command.new("powershell.exe", ps_args)
|
data/lib/beaker/dsl.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
[
|
2
|
-
'structure', 'helpers', 'wrappers', 'test_tagging' ].each do |lib|
|
1
|
+
%w[install_utils roles outcomes assertions patterns structure helpers wrappers test_tagging].each do |lib|
|
3
2
|
require "beaker/dsl/#{lib}"
|
4
3
|
end
|
5
4
|
|
@@ -69,7 +68,7 @@ module Beaker
|
|
69
68
|
# end
|
70
69
|
# end
|
71
70
|
#
|
72
|
-
|
71
|
+
# @api dsl
|
73
72
|
module DSL
|
74
73
|
include Beaker::DSL::Roles
|
75
74
|
include Beaker::DSL::Outcomes
|
data/lib/beaker/host/aix/exec.rb
CHANGED
data/lib/beaker/host/aix/file.rb
CHANGED
data/lib/beaker/host/aix/user.rb
CHANGED
data/lib/beaker/host/aix.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
[
|
1
|
+
%w[host command_factory].each do |lib|
|
2
2
|
require "beaker/#{lib}"
|
3
3
|
end
|
4
4
|
|
5
5
|
module Aix
|
6
6
|
class Host < Unix::Host
|
7
|
-
[
|
8
|
-
|
7
|
+
%w[user group file exec].each do |lib|
|
8
|
+
require "beaker/host/aix/#{lib}"
|
9
9
|
end
|
10
10
|
|
11
11
|
include Aix::User
|
12
12
|
include Aix::Group
|
13
13
|
include Aix::File
|
14
14
|
include Aix::Exec
|
15
|
-
|
16
15
|
end
|
17
16
|
end
|