beaker 4.38.1 → 4.40.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +12 -0
- data/.rubocop.yml +62 -0
- data/.rubocop_todo.yml +215 -0
- data/CHANGELOG.md +80 -33
- data/Gemfile +8 -1
- data/HISTORY.md +103 -0
- data/Rakefile +10 -9
- data/acceptance/fixtures/module/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +2 -2
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
- data/acceptance/lib/helpers/test_helper.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
- data/acceptance/tests/base/dsl/structure_test.rb +4 -10
- data/acceptance/tests/base/host/file_test.rb +7 -7
- data/acceptance/tests/base/host/group_test.rb +2 -2
- data/acceptance/tests/base/host/host_test.rb +5 -5
- data/acceptance/tests/base/host/packages.rb +26 -28
- data/acceptance/tests/base/host/packages_unix.rb +4 -4
- data/acceptance/tests/base/host/user_test.rb +2 -2
- data/acceptance/tests/install/from_file.rb +2 -2
- data/beaker.gemspec +8 -9
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +1 -1
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/lib/beaker/cli.rb +6 -8
- data/lib/beaker/command.rb +3 -3
- data/lib/beaker/command_factory.rb +2 -2
- data/lib/beaker/dsl/assertions.rb +1 -1
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
- data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
- data/lib/beaker/dsl/helpers/web_helpers.rb +17 -5
- data/lib/beaker/dsl/outcomes.rb +4 -4
- data/lib/beaker/dsl/roles.rb +2 -2
- data/lib/beaker/dsl/structure.rb +10 -10
- data/lib/beaker/host/aix/group.rb +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/cisco.rb +11 -11
- data/lib/beaker/host/eos.rb +2 -2
- data/lib/beaker/host/mac/exec.rb +1 -1
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +6 -6
- data/lib/beaker/host/mac/user.rb +6 -6
- data/lib/beaker/host/pswindows/exec.rb +8 -8
- data/lib/beaker/host/pswindows/file.rb +1 -1
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +6 -6
- data/lib/beaker/host/pswindows/user.rb +2 -2
- data/lib/beaker/host/unix/exec.rb +6 -6
- data/lib/beaker/host/unix/file.rb +3 -4
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +17 -17
- data/lib/beaker/host/unix/user.rb +3 -3
- data/lib/beaker/host/unix.rb +10 -9
- data/lib/beaker/host/windows/exec.rb +3 -3
- data/lib/beaker/host/windows/file.rb +2 -2
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +6 -6
- data/lib/beaker/host/windows/user.rb +2 -2
- data/lib/beaker/host/windows.rb +2 -2
- data/lib/beaker/host.rb +7 -7
- data/lib/beaker/host_prebuilt_steps.rb +38 -45
- data/lib/beaker/hypervisor.rb +4 -4
- data/lib/beaker/local_connection.rb +3 -3
- data/lib/beaker/logger.rb +5 -11
- data/lib/beaker/logger_junit.rb +2 -2
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/hosts_file_parser.rb +21 -4
- data/lib/beaker/options/options_file_parser.rb +1 -1
- data/lib/beaker/options/options_hash.rb +1 -3
- data/lib/beaker/options/parser.rb +6 -6
- data/lib/beaker/options/presets.rb +2 -2
- data/lib/beaker/options/validator.rb +2 -2
- data/lib/beaker/perf.rb +9 -9
- data/lib/beaker/platform.rb +1 -1
- data/lib/beaker/shared/host_manager.rb +4 -5
- data/lib/beaker/shared/repetition.rb +4 -4
- data/lib/beaker/shared/semvar.rb +2 -2
- data/lib/beaker/shared/timed.rb +2 -2
- data/lib/beaker/ssh_connection.rb +9 -9
- data/lib/beaker/subcommand.rb +6 -6
- data/lib/beaker/tasks/quick_start.rb +2 -2
- data/lib/beaker/tasks/rake_task.rb +3 -3
- data/lib/beaker/test_suite.rb +2 -2
- data/lib/beaker/test_suite_result.rb +8 -11
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/cli_spec.rb +46 -43
- data/spec/beaker/command_spec.rb +17 -7
- data/spec/beaker/dsl/assertions_spec.rb +2 -11
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +11 -8
- data/spec/beaker/dsl/outcomes_spec.rb +1 -0
- data/spec/beaker/dsl/roles_spec.rb +48 -5
- data/spec/beaker/dsl/structure_spec.rb +22 -15
- data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
- data/spec/beaker/dsl/wrappers_spec.rb +7 -7
- data/spec/beaker/host/cisco_spec.rb +8 -8
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
- data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
- data/spec/beaker/host/mac/exec_spec.rb +3 -3
- data/spec/beaker/host/mac_spec.rb +6 -6
- data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
- data/spec/beaker/host/pswindows/file_spec.rb +6 -3
- data/spec/beaker/host/pswindows_spec.rb +1 -1
- data/spec/beaker/host/unix/exec_spec.rb +24 -24
- data/spec/beaker/host/unix/file_spec.rb +18 -17
- data/spec/beaker/host/unix/pkg_spec.rb +26 -22
- data/spec/beaker/host/unix_spec.rb +8 -8
- data/spec/beaker/host/windows/exec_spec.rb +4 -4
- data/spec/beaker/host/windows/file_spec.rb +4 -4
- data/spec/beaker/host/windows/group_spec.rb +12 -12
- data/spec/beaker/host/windows/pkg_spec.rb +5 -5
- data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
- data/spec/beaker/host_spec.rb +72 -63
- data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
- data/spec/beaker/localhost_connection_spec.rb +6 -4
- data/spec/beaker/logger_junit_spec.rb +16 -17
- data/spec/beaker/logger_spec.rb +54 -52
- data/spec/beaker/network_manager_spec.rb +5 -5
- data/spec/beaker/options/command_line_parser_spec.rb +2 -2
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_file_parser_spec.rb +1 -1
- data/spec/beaker/options/options_hash_spec.rb +4 -4
- data/spec/beaker/options/parser_spec.rb +23 -23
- data/spec/beaker/options/presets_spec.rb +2 -2
- data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
- data/spec/beaker/options/validator_spec.rb +18 -18
- data/spec/beaker/perf_spec.rb +29 -28
- data/spec/beaker/platform_spec.rb +3 -2
- data/spec/beaker/shared/error_handler_spec.rb +1 -1
- data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
- data/spec/beaker/shared/host_manager_spec.rb +7 -7
- data/spec/beaker/shared/repetition_spec.rb +9 -9
- data/spec/beaker/ssh_connection_spec.rb +14 -12
- data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
- data/spec/beaker/subcommand_spec.rb +30 -28
- data/spec/beaker/test_case_spec.rb +11 -15
- data/spec/beaker/test_suite_spec.rb +24 -24
- data/spec/matchers.rb +1 -1
- data/spec/mocks.rb +5 -5
- data/spec/spec_helper.rb +0 -3
- metadata +59 -73
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
data/lib/beaker/perf.rb
CHANGED
@@ -29,7 +29,7 @@ module Beaker
|
|
29
29
|
def setup_perf_on_host(host)
|
30
30
|
@logger.perf_output("Setup perf on host: " + host)
|
31
31
|
# Install sysstat if required
|
32
|
-
if host['platform']
|
32
|
+
if PERF_SUPPORTED_PLATFORMS.match?(host['platform'])
|
33
33
|
PERF_PACKAGES.each do |pkg|
|
34
34
|
if not host.check_for_package pkg
|
35
35
|
host.install_package pkg
|
@@ -39,22 +39,22 @@ module Beaker
|
|
39
39
|
@logger.perf_output("Perf (sysstat) not supported on host: " + host)
|
40
40
|
end
|
41
41
|
|
42
|
-
if host['platform']
|
42
|
+
if /debian|ubuntu|cumulus/.match?(host['platform'])
|
43
43
|
@logger.perf_output("Modify /etc/default/sysstat on Debian and Ubuntu platforms")
|
44
44
|
host.exec(Command.new('sed -i s/ENABLED=\"false\"/ENABLED=\"true\"/ /etc/default/sysstat'))
|
45
|
-
elsif host['platform']
|
45
|
+
elsif /opensuse|sles/.match?(host['platform'])
|
46
46
|
@logger.perf_output("Creating symlink from /etc/sysstat/sysstat.cron to /etc/cron.d")
|
47
47
|
host.exec(Command.new('ln -s /etc/sysstat/sysstat.cron /etc/cron.d'),:acceptable_exit_codes => [0,1])
|
48
48
|
end
|
49
|
-
if @options[:collect_perf_data]
|
49
|
+
if @options[:collect_perf_data]&.include?('aggressive')
|
50
50
|
@logger.perf_output("Enabling aggressive sysstat polling")
|
51
|
-
if host['platform']
|
51
|
+
if /debian|ubuntu/.match?(host['platform'])
|
52
52
|
host.exec(Command.new('sed -i s/5-55\\\/10/*/ /etc/cron.d/sysstat'))
|
53
|
-
elsif
|
53
|
+
elsif /centos|el|fedora|oracle|redhat|scientific/.match?(host['platform'])
|
54
54
|
host.exec(Command.new('sed -i s/*\\\/10/*/ /etc/cron.d/sysstat'))
|
55
55
|
end
|
56
56
|
end
|
57
|
-
if host['platform']
|
57
|
+
if PERF_START_PLATFORMS.match?(host['platform']) # SLES doesn't need this step
|
58
58
|
host.exec(Command.new('service sysstat start'))
|
59
59
|
end
|
60
60
|
end
|
@@ -73,8 +73,8 @@ module Beaker
|
|
73
73
|
# @return [void] The report is sent to the logging output
|
74
74
|
def get_perf_data(host, perf_start, perf_end)
|
75
75
|
@logger.perf_output("Getting perf data for host: " + host)
|
76
|
-
if host['platform']
|
77
|
-
if not @options[:collect_perf_data]
|
76
|
+
if PERF_SUPPORTED_PLATFORMS.match?(host['platform']) # All flavours of Linux
|
77
|
+
if not @options[:collect_perf_data]&.include?('aggressive')
|
78
78
|
host.exec(Command.new("sar -A -s #{perf_start.strftime("%H:%M:%S")} -e #{perf_end.strftime("%H:%M:%S")}"),:acceptable_exit_codes => [0,1,2])
|
79
79
|
end
|
80
80
|
if (defined? @options[:graphite_server] and not @options[:graphite_server].nil?) and
|
data/lib/beaker/platform.rb
CHANGED
@@ -24,7 +24,7 @@ module Beaker
|
|
24
24
|
#@return [Array<Host>] The hosts that have the desired name/vmhostname/ip
|
25
25
|
def hosts_with_name(hosts, name = nil)
|
26
26
|
hosts.select do |host|
|
27
|
-
name.nil? or host.name
|
27
|
+
name.nil? or host.name&.start_with?(name) or host[:vmhostname]&.start_with?(name) or host[:ip]&.start_with?(name)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -59,16 +59,15 @@ module Beaker
|
|
59
59
|
def find_at_most_one_host_with_role(hosts, role)
|
60
60
|
raise ArgumentError, "role cannot be nil." if role.nil?
|
61
61
|
role_hosts = hosts_with_role(hosts, role)
|
62
|
-
host_with_role = nil
|
63
62
|
case role_hosts.length
|
64
63
|
when 0
|
64
|
+
nil
|
65
65
|
when 1
|
66
|
-
|
66
|
+
role_hosts[0]
|
67
67
|
else
|
68
68
|
host_string = ( role_hosts.map { |host| host.name } ).join( ', ')
|
69
69
|
raise ArgumentError, "There should be only one host with #{role} defined, but I found #{role_hosts.length} (#{host_string})"
|
70
70
|
end
|
71
|
-
host_with_role
|
72
71
|
end
|
73
72
|
|
74
73
|
# Execute a block selecting the hosts that match with the provided criteria
|
@@ -107,7 +106,7 @@ module Beaker
|
|
107
106
|
if block_hosts.length > 0
|
108
107
|
if run_in_parallel? opts
|
109
108
|
# Pass caller[1] - the line that called block_on - for logging purposes.
|
110
|
-
result = block_hosts.map.each_in_parallel(caller
|
109
|
+
result = block_hosts.map.each_in_parallel(caller(2..2).first) do |h|
|
111
110
|
run_block_on h, &block
|
112
111
|
end
|
113
112
|
hosts.each{|host| host.close}# For some reason, I have to close the SSH connection
|
@@ -7,22 +7,22 @@ module Beaker
|
|
7
7
|
repeat_for_and_wait seconds, 1, &block
|
8
8
|
end
|
9
9
|
|
10
|
-
def repeat_for_and_wait seconds, wait
|
10
|
+
def repeat_for_and_wait seconds, wait
|
11
11
|
timeout = Time.now + seconds
|
12
12
|
done = false
|
13
13
|
until done or timeout < Time.now do
|
14
|
-
done =
|
14
|
+
done = yield
|
15
15
|
sleep wait unless done
|
16
16
|
end
|
17
17
|
return done
|
18
18
|
end
|
19
19
|
|
20
|
-
def repeat_fibonacci_style_for attempts
|
20
|
+
def repeat_fibonacci_style_for attempts
|
21
21
|
done = false
|
22
22
|
attempt = 1
|
23
23
|
last_wait, wait = 0, 1
|
24
24
|
while not done and attempt <= attempts do
|
25
|
-
done =
|
25
|
+
done = yield
|
26
26
|
attempt += 1
|
27
27
|
sleep wait unless done
|
28
28
|
last_wait, wait = wait, last_wait + wait
|
data/lib/beaker/shared/semvar.rb
CHANGED
@@ -29,10 +29,10 @@ module Beaker
|
|
29
29
|
#checks all dots, they are equal so examine the rest
|
30
30
|
a_rest = a.split('-').drop(1)
|
31
31
|
a_is_release = a_rest.empty?
|
32
|
-
a_is_rc = !a_is_release &&
|
32
|
+
a_is_rc = !a_is_release && /rc\d+/.match?(a_rest[0])
|
33
33
|
b_rest = b.split('-').drop(1)
|
34
34
|
b_is_release = b_rest.empty?
|
35
|
-
b_is_rc = !b_is_release &&
|
35
|
+
b_is_rc = !b_is_release && /rc\d+/.match?(b_rest[0])
|
36
36
|
|
37
37
|
if a_is_release && b_is_release
|
38
38
|
# They are equal
|
data/lib/beaker/shared/timed.rb
CHANGED
@@ -108,7 +108,7 @@ module Beaker
|
|
108
108
|
while (not @ssh) && (not methods.empty?) do
|
109
109
|
unless instance_variable_get("@#{methods[0]}").nil?
|
110
110
|
if SUPPORTED_CONNECTION_METHODS.include?(methods[0])
|
111
|
-
@ssh = connect_block(instance_variable_get("@#{methods[0]
|
111
|
+
@ssh = connect_block(instance_variable_get("@#{methods[0]}"), @user, @ssh_opts, options)
|
112
112
|
else
|
113
113
|
@logger.warn "Beaker does not support #{methods[0]} to SSH to host, trying next available method."
|
114
114
|
@ssh_connection_preference.delete(methods[0])
|
@@ -243,7 +243,7 @@ module Beaker
|
|
243
243
|
end
|
244
244
|
|
245
245
|
def request_terminal_for channel, command
|
246
|
-
channel.request_pty do |
|
246
|
+
channel.request_pty do |_ch, success|
|
247
247
|
if success
|
248
248
|
@logger.debug "Allocated a PTY on #{@hostname} for #{command.inspect}"
|
249
249
|
else
|
@@ -254,7 +254,7 @@ module Beaker
|
|
254
254
|
end
|
255
255
|
|
256
256
|
def register_stdout_for channel, output, callback = nil
|
257
|
-
channel.on_data do |
|
257
|
+
channel.on_data do |_ch, data|
|
258
258
|
callback[data] if callback
|
259
259
|
output.stdout << data
|
260
260
|
output.output << data
|
@@ -262,7 +262,7 @@ module Beaker
|
|
262
262
|
end
|
263
263
|
|
264
264
|
def register_stderr_for channel, output, callback = nil
|
265
|
-
channel.on_extended_data do |
|
265
|
+
channel.on_extended_data do |_ch, type, data|
|
266
266
|
if type == 1
|
267
267
|
callback[data] if callback
|
268
268
|
output.stderr << data
|
@@ -272,7 +272,7 @@ module Beaker
|
|
272
272
|
end
|
273
273
|
|
274
274
|
def register_exit_code_for channel, output
|
275
|
-
channel.on_request("exit-status") do |
|
275
|
+
channel.on_request("exit-status") do |_ch, data|
|
276
276
|
output.exit_code = data.read_long
|
277
277
|
end
|
278
278
|
end
|
@@ -301,9 +301,9 @@ module Beaker
|
|
301
301
|
begin
|
302
302
|
# This is probably windows with an environment variable so we need to
|
303
303
|
# expand it.
|
304
|
-
target = self.execute(%{echo "#{target}"}).output.strip.
|
304
|
+
target = self.execute(%{echo "#{target}"}).output.strip.delete('"') if target.include?('%')
|
305
305
|
|
306
|
-
@ssh.scp.upload! source, target, local_opts do |
|
306
|
+
@ssh.scp.upload! source, target, local_opts do |_ch, name, sent, total|
|
307
307
|
result.stdout << "\tcopying %s: %10d/%d\n" % [name, sent, total]
|
308
308
|
end
|
309
309
|
rescue => e
|
@@ -337,9 +337,9 @@ module Beaker
|
|
337
337
|
begin
|
338
338
|
# This is probably windows with an environment variable so we need to
|
339
339
|
# expand it.
|
340
|
-
source = self.execute(%{echo "#{source}"}).output.strip.
|
340
|
+
source = self.execute(%{echo "#{source}"}).output.strip.delete('"') if source.include?('%')
|
341
341
|
|
342
|
-
@ssh.scp.download! source, target, local_opts do |
|
342
|
+
@ssh.scp.download! source, target, local_opts do |_ch, name, sent, total|
|
343
343
|
result.stdout << "\tcopying %s: %10d/%d\n" % [name, sent, total]
|
344
344
|
end
|
345
345
|
rescue => e
|
data/lib/beaker/subcommand.rb
CHANGED
@@ -28,7 +28,7 @@ module Beaker
|
|
28
28
|
class_option :'pre-suite', :type => :string, :group => 'Beaker run'
|
29
29
|
class_option :'post-suite', :type => :string, :group => 'Beaker run'
|
30
30
|
class_option :'pre-cleanup', :type => :string, :group => 'Beaker run'
|
31
|
-
class_option :
|
31
|
+
class_option :provision, :type => :boolean, :group => 'Beaker run'
|
32
32
|
class_option :'preserve-hosts', :type => :string, :group => 'Beaker run'
|
33
33
|
class_option :'preserve-state', :type => :boolean, :group => 'Beaker run'
|
34
34
|
class_option :'root-keys', :type => :boolean, :group => 'Beaker run'
|
@@ -48,14 +48,14 @@ module Beaker
|
|
48
48
|
class_option :'repo-proxy', :type => :boolean, :group => 'Beaker run'
|
49
49
|
class_option :'add-el-extras', :type => :boolean, :group => 'Beaker run'
|
50
50
|
class_option :'package-proxy', :type => :string, :group => 'Beaker run'
|
51
|
-
class_option :
|
51
|
+
class_option :validate, :type => :boolean, :group => 'Beaker run'
|
52
52
|
class_option :'collect-perf-data', :type => :boolean, :group => 'Beaker run'
|
53
53
|
class_option :'parse-only', :type => :boolean, :group => 'Beaker run'
|
54
54
|
class_option :tag, :type => :string, :group => 'Beaker run'
|
55
55
|
class_option :'exclude-tags', :type => :string, :group => 'Beaker run'
|
56
56
|
class_option :'xml-time-order', :type => :boolean, :group => 'Beaker run'
|
57
57
|
class_option :'debug-errors', :type => :boolean, :group => 'Beaker run'
|
58
|
-
class_option :
|
58
|
+
class_option :exec_manual_tests, :type => :boolean, :group => 'Beaker run'
|
59
59
|
class_option :'test-tag-exclude', :type => :string, :group => 'Beaker run'
|
60
60
|
class_option :'test-tag-and', :type => :string, :group => 'Beaker run'
|
61
61
|
class_option :'test-tag-or', :type => :string, :group => 'Beaker run'
|
@@ -124,7 +124,7 @@ module Beaker
|
|
124
124
|
|
125
125
|
# Update each host provisioned with a flag indicating that it no longer needs
|
126
126
|
# provisioning
|
127
|
-
cleaned_hosts.each do |
|
127
|
+
cleaned_hosts.each do |_host, host_hash|
|
128
128
|
host_hash['provision'] = false
|
129
129
|
end
|
130
130
|
|
@@ -186,11 +186,11 @@ module Beaker
|
|
186
186
|
path.to_s
|
187
187
|
end
|
188
188
|
end.flatten
|
189
|
-
elsif resources.all? { |r|
|
189
|
+
elsif resources.all? { |r| /^(pre-suite|tests|post-suite|pre-cleanup)$/.match?(r) }
|
190
190
|
# The regex match here is loose so that users can supply multiple suites,
|
191
191
|
# such as `beaker exec pre-suite,tests`.
|
192
192
|
beaker_suites.each do |suite|
|
193
|
-
@cli.options[suite] = [] unless resource.
|
193
|
+
@cli.options[suite] = [] unless resource.tr('-', '_').match(suite.to_s)
|
194
194
|
end
|
195
195
|
else
|
196
196
|
raise ArgumentError, "Unable to parse #{resource} with beaker exec"
|
@@ -10,7 +10,7 @@ VMPOOLER = ['redhat7-64default.mdcal-redhat7-64af']
|
|
10
10
|
namespace :beaker_quickstart do
|
11
11
|
|
12
12
|
desc 'Generate Default Beaker Host Config File, valid options are: vmpooler or vagrant.'
|
13
|
-
task :gen_hosts, [:hypervisor] do |
|
13
|
+
task :gen_hosts, [:hypervisor] do |_t, args|
|
14
14
|
hosts_file = "#{CONFIG_DIR}/default_#{args[:hypervisor]}_hosts.yaml"
|
15
15
|
if args[:hypervisor] == 'vagrant'
|
16
16
|
cli = VAGRANT
|
@@ -72,7 +72,7 @@ end")
|
|
72
72
|
desc 'Run Default Smoke Test, after generating default host config and test files, valid options are: vmpooler or vagrant.'
|
73
73
|
task :run_test, [:hypervisor] => ["beaker_quickstart:gen_hosts", 'beaker_quickstart:gen_pre_suite',
|
74
74
|
'beaker_quickstart:gen_smoke_test'] do
|
75
|
-
|
|
75
|
+
|_t, args|
|
76
76
|
hypervisor = args[:hypervisor] ||='vagrant'
|
77
77
|
system_args = Hash.new
|
78
78
|
system_args[:hosts] = "acceptance/config/default_#{hypervisor}_hosts.yaml"
|
@@ -64,7 +64,7 @@ module Beaker
|
|
64
64
|
.application.last_comment)
|
65
65
|
task name, *args do |_, task_args|
|
66
66
|
RakeFileUtils.__send__(:verbose, verbose) do
|
67
|
-
|
67
|
+
yield(*[self, task_args].slice(0, task_block.arity)) if task_block
|
68
68
|
run_task verbose
|
69
69
|
end
|
70
70
|
end
|
@@ -75,7 +75,7 @@ module Beaker
|
|
75
75
|
# if no other options file is provided
|
76
76
|
#
|
77
77
|
def check_for_beaker_type_config
|
78
|
-
if !@options_file && File.
|
78
|
+
if !@options_file && File.exist?("#{@acceptance_root}/.beaker-#{@type}.cfg")
|
79
79
|
@options_file = File.join(@acceptance_root, ".beaker-#{@type}.cfg")
|
80
80
|
end
|
81
81
|
end
|
@@ -84,7 +84,7 @@ module Beaker
|
|
84
84
|
# Check for existence of ENV variables for test if !@tests is undef
|
85
85
|
#
|
86
86
|
def check_env_variables
|
87
|
-
if File.
|
87
|
+
if File.exist?(File.join(DEFAULT_ACCEPTANCE_ROOT, 'tests'))
|
88
88
|
@tests = File.join(DEFAULT_ACCEPTANCE_ROOT, 'tests')
|
89
89
|
end
|
90
90
|
@tests = ENV['TESTS'] || ENV['TEST'] if !@tests
|
data/lib/beaker/test_suite.rb
CHANGED
@@ -77,10 +77,10 @@ module Beaker
|
|
77
77
|
@logger.warn msg
|
78
78
|
when :fail
|
79
79
|
@logger.error msg
|
80
|
-
break if
|
80
|
+
break if !@fail_mode.to_s.include?('slow') #all failure modes except slow cause us to kick out early on failure
|
81
81
|
when :error
|
82
82
|
@logger.warn msg
|
83
|
-
break if
|
83
|
+
break if !@fail_mode.to_s.include?('slow') #all failure modes except slow cause us to kick out early on failure
|
84
84
|
end
|
85
85
|
end
|
86
86
|
@test_suite_results.stop_time = Time.now
|
@@ -18,9 +18,6 @@ module Beaker
|
|
18
18
|
@logger = options[:logger]
|
19
19
|
@name = name
|
20
20
|
@test_cases = []
|
21
|
-
#Set some defaults, just in case you attempt to print without including them
|
22
|
-
start_time = Time.at(0)
|
23
|
-
stop_time = Time.at(1)
|
24
21
|
end
|
25
22
|
|
26
23
|
#Add a {TestCase} to this {TestSuiteResult} instance, used in calculating {TestSuiteResult} data.
|
@@ -36,27 +33,27 @@ module Beaker
|
|
36
33
|
|
37
34
|
#How many passed {TestCase} instances are in this {TestSuiteResult}
|
38
35
|
def passed_tests
|
39
|
-
@test_cases.
|
36
|
+
@test_cases.count { |c| c.test_status == :pass }
|
40
37
|
end
|
41
38
|
|
42
39
|
#How many errored {TestCase} instances are in this {TestSuiteResult}
|
43
40
|
def errored_tests
|
44
|
-
@test_cases.
|
41
|
+
@test_cases.count { |c| c.test_status == :error }
|
45
42
|
end
|
46
43
|
|
47
44
|
#How many failed {TestCase} instances are in this {TestSuiteResult}
|
48
45
|
def failed_tests
|
49
|
-
@test_cases.
|
46
|
+
@test_cases.count { |c| c.test_status == :fail }
|
50
47
|
end
|
51
48
|
|
52
49
|
#How many skipped {TestCase} instances are in this {TestSuiteResult}
|
53
50
|
def skipped_tests
|
54
|
-
@test_cases.
|
51
|
+
@test_cases.count { |c| c.test_status == :skip }
|
55
52
|
end
|
56
53
|
|
57
54
|
#How many pending {TestCase} instances are in this {TestSuiteResult}
|
58
55
|
def pending_tests
|
59
|
-
@test_cases.
|
56
|
+
@test_cases.count {|c| c.test_status == :pending}
|
60
57
|
end
|
61
58
|
|
62
59
|
#How many {TestCase} instances failed in this {TestSuiteResult}
|
@@ -178,7 +175,7 @@ module Beaker
|
|
178
175
|
stylesheet = File.join(@options[:project_root], @options[:xml_stylesheet])
|
179
176
|
|
180
177
|
begin
|
181
|
-
LoggerJunit.write_xml(xml_file, stylesheet) do |
|
178
|
+
LoggerJunit.write_xml(xml_file, stylesheet) do |_doc, suites|
|
182
179
|
|
183
180
|
meta_info = suites.add_element(REXML::Element.new('meta_test_info'))
|
184
181
|
unless file_to_link.nil?
|
@@ -229,7 +226,7 @@ module Beaker
|
|
229
226
|
status = item.add_element(REXML::Element.new('failure'))
|
230
227
|
status.add_attribute('type', test.test_status.to_s)
|
231
228
|
if test.exception
|
232
|
-
status.add_attribute('message', test.exception.to_s.
|
229
|
+
status.add_attribute('message', test.exception.to_s.delete("\e"))
|
233
230
|
data = LoggerJunit.format_cdata(test.exception.backtrace.join('\n'))
|
234
231
|
REXML::CData.new(data, true, status)
|
235
232
|
end
|
@@ -259,7 +256,7 @@ module Beaker
|
|
259
256
|
end
|
260
257
|
end
|
261
258
|
rescue Exception => e
|
262
|
-
@logger.error "failure in XML output: \n#{e
|
259
|
+
@logger.error "failure in XML output: \n#{e}" + e.backtrace.join("\n")
|
263
260
|
end
|
264
261
|
end
|
265
262
|
|
data/lib/beaker/version.rb
CHANGED