beaker 4.38.1 → 4.39.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 +72 -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 +9 -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 +3 -3
- 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 +2 -2
- 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 -59
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
@@ -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
data/spec/beaker/cli_spec.rb
CHANGED
@@ -13,9 +13,15 @@ end
|
|
13
13
|
module Beaker
|
14
14
|
describe CLI do
|
15
15
|
|
16
|
+
let(:cli) {
|
17
|
+
allow(File).to receive(:exist?).and_call_original
|
18
|
+
allow(File).to receive(:exist?).with('.beaker.yml').and_return(false)
|
19
|
+
described_class.new.parse_options
|
20
|
+
}
|
21
|
+
|
16
22
|
context 'initializing and parsing' do
|
17
23
|
let( :cli ) {
|
18
|
-
|
24
|
+
described_class.new
|
19
25
|
}
|
20
26
|
|
21
27
|
describe 'instance variable initialization' do
|
@@ -32,7 +38,7 @@ module Beaker
|
|
32
38
|
|
33
39
|
describe '#parse_options' do
|
34
40
|
it 'returns self' do
|
35
|
-
expect(cli.parse_options).to be_instance_of(
|
41
|
+
expect(cli.parse_options).to be_instance_of(described_class)
|
36
42
|
end
|
37
43
|
|
38
44
|
it 'replaces the logger object with a new one' do
|
@@ -67,8 +73,9 @@ module Beaker
|
|
67
73
|
before do
|
68
74
|
options = Beaker::Options::OptionsHash.new
|
69
75
|
options[:beaker_version] = 'version_number'
|
70
|
-
cli.instance_variable_set(
|
76
|
+
cli.instance_variable_set(:@options, options)
|
71
77
|
end
|
78
|
+
|
72
79
|
it 'prints the version and dumps the options' do
|
73
80
|
expect(cli.logger).to receive(:info).exactly(3).times
|
74
81
|
cli.print_version_and_options
|
@@ -76,13 +83,8 @@ module Beaker
|
|
76
83
|
end
|
77
84
|
end
|
78
85
|
|
79
|
-
let(:cli) {
|
80
|
-
allow(File).to receive(:exists?).and_return(true)
|
81
|
-
allow(File).to receive(:exists?).with('.beaker.yml').and_return(false)
|
82
|
-
Beaker::CLI.new.parse_options
|
83
|
-
}
|
84
86
|
|
85
|
-
|
87
|
+
describe '#configured_options' do
|
86
88
|
it 'returns a list of options that were not presets' do
|
87
89
|
attribution = cli.instance_variable_get(:@attribution)
|
88
90
|
attribution.each do |attribute, setter|
|
@@ -94,14 +96,16 @@ module Beaker
|
|
94
96
|
end
|
95
97
|
|
96
98
|
describe '#combined_instance_and_options_hosts' do
|
97
|
-
let
|
98
|
-
let
|
99
|
+
let(:options_host) { {'HOSTS' => {'ubuntu' => {:options_attribute => 'options'}} }}
|
100
|
+
let(:instance_host ) {
|
99
101
|
[Beaker::Host.create('ubuntu', {:platform => 'host'}, {} )]
|
100
102
|
}
|
103
|
+
|
101
104
|
before do
|
102
105
|
cli.instance_variable_set(:@options, options_host)
|
103
106
|
cli.instance_variable_set(:@hosts, instance_host)
|
104
107
|
end
|
108
|
+
|
105
109
|
it 'combines the options and instance host objects' do
|
106
110
|
merged_host = cli.combined_instance_and_options_hosts
|
107
111
|
expect(merged_host).to have_key('ubuntu')
|
@@ -112,11 +116,11 @@ module Beaker
|
|
112
116
|
end
|
113
117
|
|
114
118
|
context 'when hosts share IP addresses' do
|
115
|
-
let
|
119
|
+
let(:options_host) do
|
116
120
|
{'HOSTS' => {'host1' => {:options_attribute => 'options'},
|
117
121
|
'host2' => {:options_attribute => 'options'}}}
|
118
122
|
end
|
119
|
-
let
|
123
|
+
let(:instance_host ) do
|
120
124
|
[Beaker::Host.create('host1',
|
121
125
|
{:platform => 'host', :ip => '127.0.0.1'}, {} ),
|
122
126
|
Beaker::Host.create('host2',
|
@@ -133,7 +137,7 @@ module Beaker
|
|
133
137
|
end
|
134
138
|
|
135
139
|
context 'execute!' do
|
136
|
-
before
|
140
|
+
before do
|
137
141
|
stub_const("Beaker::Logger", double().as_null_object )
|
138
142
|
File.open("sample.cfg", "w+") do |file|
|
139
143
|
file.write("HOSTS:\n")
|
@@ -158,7 +162,7 @@ module Beaker
|
|
158
162
|
allow( cli ).to receive(:run_suite).with(:post_suite).and_return(true)
|
159
163
|
allow( cli ).to receive(:run_suite).with(:pre_cleanup).and_return(true)
|
160
164
|
|
161
|
-
expect( cli ).to receive(:run_suite).
|
165
|
+
expect( cli ).to receive(:run_suite).twice
|
162
166
|
expect{ cli.execute! }.to raise_error
|
163
167
|
expect(cli.instance_variable_get(:@attribution)[:logger]).to be == 'runtime'
|
164
168
|
expect(cli.instance_variable_get(:@attribution)[:timestamp]).to be == 'runtime'
|
@@ -226,7 +230,7 @@ module Beaker
|
|
226
230
|
cli.instance_variable_set(:@network_manager, netmanager)
|
227
231
|
expect( netmanager ).to receive(:cleanup).once
|
228
232
|
|
229
|
-
expect{ cli.execute! }.
|
233
|
+
expect{ cli.execute! }.not_to raise_error
|
230
234
|
|
231
235
|
end
|
232
236
|
|
@@ -246,9 +250,9 @@ module Beaker
|
|
246
250
|
|
247
251
|
netmanager = double(:netmanager)
|
248
252
|
cli.instance_variable_set(:@network_manager, netmanager)
|
249
|
-
expect( netmanager ).
|
253
|
+
expect( netmanager ).not_to receive(:cleanup)
|
250
254
|
|
251
|
-
expect{ cli.execute! }.
|
255
|
+
expect{ cli.execute! }.not_to raise_error
|
252
256
|
|
253
257
|
end
|
254
258
|
|
@@ -264,7 +268,7 @@ module Beaker
|
|
264
268
|
|
265
269
|
netmanager = double(:netmanager)
|
266
270
|
cli.instance_variable_set(:@network_manager, netmanager)
|
267
|
-
expect( netmanager ).
|
271
|
+
expect( netmanager ).not_to receive(:cleanup)
|
268
272
|
|
269
273
|
expect{ cli.execute! }.to raise_error
|
270
274
|
end
|
@@ -283,7 +287,7 @@ module Beaker
|
|
283
287
|
cli.instance_variable_set(:@network_manager, netmanager)
|
284
288
|
expect( netmanager ).to receive(:cleanup).once
|
285
289
|
|
286
|
-
expect{ cli.execute! }.
|
290
|
+
expect{ cli.execute! }.not_to raise_error
|
287
291
|
|
288
292
|
end
|
289
293
|
|
@@ -299,7 +303,7 @@ module Beaker
|
|
299
303
|
|
300
304
|
netmanager = double(:netmanager)
|
301
305
|
cli.instance_variable_set(:@network_manager, netmanager)
|
302
|
-
expect( netmanager ).
|
306
|
+
expect( netmanager ).not_to receive(:cleanup)
|
303
307
|
|
304
308
|
expect{ cli.execute! }.to raise_error
|
305
309
|
|
@@ -338,9 +342,9 @@ module Beaker
|
|
338
342
|
|
339
343
|
netmanager = double(:netmanager)
|
340
344
|
cli.instance_variable_set(:@network_manager, netmanager)
|
341
|
-
expect( netmanager ).
|
345
|
+
expect( netmanager ).not_to receive(:cleanup)
|
342
346
|
|
343
|
-
expect{ cli.execute! }.
|
347
|
+
expect{ cli.execute! }.not_to raise_error
|
344
348
|
end
|
345
349
|
end
|
346
350
|
|
@@ -381,7 +385,7 @@ module Beaker
|
|
381
385
|
|
382
386
|
describe 'hosts file saving when preserve_hosts should happen' do
|
383
387
|
|
384
|
-
before
|
388
|
+
before do
|
385
389
|
options = cli.instance_variable_get(:@options)
|
386
390
|
options[:fail_mode] = 'fast'
|
387
391
|
options[:preserve_hosts] = 'onpass'
|
@@ -400,7 +404,7 @@ module Beaker
|
|
400
404
|
|
401
405
|
netmanager = double(:netmanager)
|
402
406
|
cli.instance_variable_set(:@network_manager, netmanager)
|
403
|
-
expect( netmanager ).
|
407
|
+
expect( netmanager ).not_to receive(:cleanup)
|
404
408
|
|
405
409
|
|
406
410
|
allow( cli ).to receive( :print_env_vars_affecting_beaker )
|
@@ -414,7 +418,7 @@ module Beaker
|
|
414
418
|
Dir.mktmpdir do |dir|
|
415
419
|
options[:log_dated_dir] = File.absolute_path(dir)
|
416
420
|
|
417
|
-
expect{ cli.execute! }.
|
421
|
+
expect{ cli.execute! }.not_to raise_error
|
418
422
|
end
|
419
423
|
end
|
420
424
|
|
@@ -426,7 +430,7 @@ module Beaker
|
|
426
430
|
cli.execute!
|
427
431
|
|
428
432
|
copied_hosts_file = File.join(File.absolute_path(dir), 'hosts_preserved.yml')
|
429
|
-
expect( File
|
433
|
+
expect( File ).to exist(copied_hosts_file)
|
430
434
|
end
|
431
435
|
end
|
432
436
|
|
@@ -438,7 +442,7 @@ module Beaker
|
|
438
442
|
cli.execute!
|
439
443
|
|
440
444
|
copied_hosts_file = File.join(File.absolute_path(dir), 'hosts_preserved.yml')
|
441
|
-
expect{ load_yaml_file(copied_hosts_file) }.
|
445
|
+
expect{ load_yaml_file(copied_hosts_file) }.not_to raise_error
|
442
446
|
end
|
443
447
|
end
|
444
448
|
|
@@ -460,9 +464,9 @@ module Beaker
|
|
460
464
|
Dir.mktmpdir do |dir|
|
461
465
|
options[:log_dated_dir] = File.absolute_path(dir)
|
462
466
|
|
463
|
-
expect( options.
|
467
|
+
expect( options ).not_to have_key(:hosts_preserved_yaml_file)
|
464
468
|
cli.execute!
|
465
|
-
expect( options.
|
469
|
+
expect( options ).to have_key(:hosts_preserved_yaml_file)
|
466
470
|
|
467
471
|
copied_hosts_file = File.join(File.absolute_path(dir), 'hosts_preserved.yml')
|
468
472
|
expect( options[:hosts_preserved_yaml_file] ).to be === copied_hosts_file
|
@@ -478,9 +482,9 @@ module Beaker
|
|
478
482
|
copied_hosts_file = File.join(File.absolute_path(dir), options[:hosts_file])
|
479
483
|
|
480
484
|
logger = cli.instance_variable_get(:@logger)
|
481
|
-
expect( logger ).
|
482
|
-
expect( logger ).
|
483
|
-
expect( logger ).
|
485
|
+
expect( logger ).not_to receive( :send ).with( anything, "\nYou can re-run commands against the already provisioned SUT(s) by following these steps:\n")
|
486
|
+
expect( logger ).not_to receive( :send ).with( anything, "- change the hosts file to #{copied_hosts_file}")
|
487
|
+
expect( logger ).not_to receive( :send ).with( anything, '- use the --no-provision flag')
|
484
488
|
|
485
489
|
cli.execute!
|
486
490
|
end
|
@@ -490,7 +494,6 @@ module Beaker
|
|
490
494
|
options = cli.instance_variable_get(:@options)
|
491
495
|
Dir.mktmpdir do |dir|
|
492
496
|
options[:log_dated_dir] = File.absolute_path(dir)
|
493
|
-
copied_hosts_file = File.join(File.absolute_path(dir), options[:hosts_file])
|
494
497
|
|
495
498
|
hosts = cli.instance_variable_get(:@hosts)
|
496
499
|
hosts << make_host('fusion', { :hypervisor => 'fusion' })
|
@@ -510,7 +513,6 @@ module Beaker
|
|
510
513
|
options = cli.instance_variable_get(:@options)
|
511
514
|
Dir.mktmpdir do |dir|
|
512
515
|
options[:log_dated_dir] = File.absolute_path(dir)
|
513
|
-
copied_hosts_file = File.join(File.absolute_path(dir), options[:hosts_file])
|
514
516
|
|
515
517
|
hosts = cli.instance_variable_get(:@hosts)
|
516
518
|
hosts << make_host('fusion', { :hypervisor => 'fusion' })
|
@@ -538,10 +540,10 @@ module Beaker
|
|
538
540
|
hosts << make_host('docker', { :hypervisor => 'docker' })
|
539
541
|
|
540
542
|
logger = cli.instance_variable_get(:@logger)
|
541
|
-
expect( logger ).
|
542
|
-
expect( logger ).
|
543
|
-
expect( logger ).
|
544
|
-
expect( logger ).
|
543
|
+
expect( logger ).not_to receive( :send ).with( anything, "\nYou can re-run commands against the already provisioned SUT(s) with:\n")
|
544
|
+
expect( logger ).not_to receive( :send ).with( anything, '(docker support is untested for this feature. please reference the docs for more info)')
|
545
|
+
expect( logger ).not_to receive( :send ).with( anything, "- change the hosts file to #{copied_hosts_file}")
|
546
|
+
expect( logger ).not_to receive( :send ).with( anything, '- use the --no-provision flag')
|
545
547
|
|
546
548
|
cli.execute!
|
547
549
|
end
|
@@ -550,6 +552,7 @@ module Beaker
|
|
550
552
|
|
551
553
|
end
|
552
554
|
end
|
555
|
+
|
553
556
|
describe '#build_hosts_preserved_reproducing_command' do
|
554
557
|
|
555
558
|
it 'replaces the hosts file' do
|
@@ -558,7 +561,7 @@ module Beaker
|
|
558
561
|
command_correct = "p --log-level debug --hosts #{new_hosts_file} jam --jankies --flag-business"
|
559
562
|
|
560
563
|
answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, new_hosts_file)
|
561
|
-
expect( answer
|
564
|
+
expect( answer ).to be_start_with(command_correct)
|
562
565
|
end
|
563
566
|
|
564
567
|
it 'doesn\'t replace an entry if no --hosts key is found' do
|
@@ -566,7 +569,7 @@ module Beaker
|
|
566
569
|
command_correct = 'p --log-level debug johnnypantaloons7 --jankies --flag-business'
|
567
570
|
|
568
571
|
answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, 'john/deer/plans.txt')
|
569
|
-
expect( answer
|
572
|
+
expect( answer ).to be_start_with(command_correct)
|
570
573
|
end
|
571
574
|
|
572
575
|
it 'removes any old --provision flags' do
|
@@ -574,7 +577,7 @@ module Beaker
|
|
574
577
|
command_correct = 'jam --jankies --flag-business'
|
575
578
|
|
576
579
|
answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, 'can/talk/to/pigs.yml')
|
577
|
-
expect( answer
|
580
|
+
expect( answer ).to be_start_with(command_correct)
|
578
581
|
end
|
579
582
|
|
580
583
|
it 'removes any old --no-provision flags' do
|
@@ -582,7 +585,7 @@ module Beaker
|
|
582
585
|
command_correct = 'jam --jankoos --flag-businesses'
|
583
586
|
|
584
587
|
answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, 'can/talk/to/bears.yml')
|
585
|
-
expect( answer
|
588
|
+
expect( answer ).to be_start_with(command_correct)
|
586
589
|
end
|
587
590
|
end
|
588
591
|
|