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
@@ -54,11 +54,11 @@ module Beaker
|
|
54
54
|
logger.notify "NTP date succeeded on #{host}"
|
55
55
|
else
|
56
56
|
case
|
57
|
-
when
|
57
|
+
when /el-[89]|fedora/.match?(host['platform'])
|
58
58
|
ntp_command = "chronyc add server #{ntp_server} prefer trust;chronyc makestep;chronyc burst 1/2"
|
59
|
-
when host['platform']
|
59
|
+
when /opensuse-|sles-/.match?(host['platform'])
|
60
60
|
ntp_command = "sntp #{ntp_server}"
|
61
|
-
when host['platform']
|
61
|
+
when host['platform'].include?('cisco_nexus')
|
62
62
|
ntp_server = host.exec(Command.new("getent hosts #{NTPSERVER} | head -n1 |cut -d \" \" -f1"), :acceptable_exit_codes => [0]).stdout
|
63
63
|
ntp_command = "sudo -E sh -c 'export DCOS_CONTEXT=2;/isan/bin/ntpdate -u -t 20 #{ntp_server}'"
|
64
64
|
else
|
@@ -146,7 +146,7 @@ module Beaker
|
|
146
146
|
when /fedora/
|
147
147
|
FEDORA_PACKAGES
|
148
148
|
else
|
149
|
-
if
|
149
|
+
if !/aix|solaris|osx-|f5-|netscaler|cisco_/.match?(host['platform'])
|
150
150
|
UNIX_PACKAGES
|
151
151
|
else
|
152
152
|
[]
|
@@ -197,9 +197,9 @@ module Beaker
|
|
197
197
|
block_on host do |host|
|
198
198
|
logger.notify "Sync root authorized_keys from github on #{host.name}"
|
199
199
|
# Allow all exit code, as this operation is unlikely to cause problems if it fails.
|
200
|
-
if host['platform']
|
200
|
+
if /solaris|eos/.match?(host['platform'])
|
201
201
|
host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "bash"), :accept_all_exit_codes => true)
|
202
|
-
elsif host['platform']
|
202
|
+
elsif host['platform'].include?('aix')
|
203
203
|
host.exec(Command.new(ROOT_KEYS_SYNC_CMD_AIX % "env PATH=/usr/gnu/bin:$PATH bash"), :accept_all_exit_codes => true)
|
204
204
|
else
|
205
205
|
host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "env PATH=\"/usr/gnu/bin:$PATH\" bash"), :accept_all_exit_codes => true)
|
@@ -215,7 +215,7 @@ module Beaker
|
|
215
215
|
# @param [Host, Array<Host>] hosts One or more hosts to act upon
|
216
216
|
def apt_get_update hosts
|
217
217
|
block_on hosts do |host|
|
218
|
-
if
|
218
|
+
if /ubuntu|debian|cumulus/.match?(host[:platform])
|
219
219
|
host.exec(Command.new("apt-get update"))
|
220
220
|
end
|
221
221
|
end
|
@@ -249,11 +249,11 @@ module Beaker
|
|
249
249
|
logger = opts[:logger]
|
250
250
|
block_on host do |host|
|
251
251
|
case
|
252
|
-
when host['platform']
|
252
|
+
when /ubuntu|debian|cumulus/.match?(host['platform'])
|
253
253
|
host.exec(Command.new("if test -f /etc/apt/apt.conf; then mv /etc/apt/apt.conf /etc/apt/apt.conf.bk; fi"))
|
254
254
|
copy_file_to_remote(host, '/etc/apt/apt.conf', APT_CFG)
|
255
255
|
apt_get_update(host)
|
256
|
-
when host['platform']
|
256
|
+
when host['platform'].include?('solaris-11')
|
257
257
|
host.exec(Command.new("/usr/bin/pkg unset-publisher solaris || :"))
|
258
258
|
host.exec(Command.new("/usr/bin/pkg set-publisher -g %s solaris" % IPS_PKG_REPO))
|
259
259
|
else
|
@@ -275,7 +275,6 @@ module Beaker
|
|
275
275
|
#add_el_extras
|
276
276
|
#only supports el-* platforms
|
277
277
|
logger = opts[:logger]
|
278
|
-
debug_opt = opts[:debug] ? 'vh' : ''
|
279
278
|
block_on host do |host|
|
280
279
|
case
|
281
280
|
when el_based?(host) && ['6','7'].include?(host['platform'].version)
|
@@ -302,7 +301,7 @@ module Beaker
|
|
302
301
|
def get_domain_name(host)
|
303
302
|
domain = nil
|
304
303
|
search = nil
|
305
|
-
if host['platform']
|
304
|
+
if host['platform'].include?('windows')
|
306
305
|
if host.is_cygwin?
|
307
306
|
resolv_conf = host.exec(Command.new("cat /cygdrive/c/Windows/System32/drivers/etc/hosts")).stdout
|
308
307
|
else
|
@@ -337,15 +336,15 @@ module Beaker
|
|
337
336
|
# @param [Host] host the host to act upon
|
338
337
|
# @param [String] etc_hosts The string to append to the /etc/hosts file
|
339
338
|
def set_etc_hosts(host, etc_hosts)
|
340
|
-
if host['platform']
|
339
|
+
if host['platform'].include?('freebsd')
|
341
340
|
host.echo_to_file(etc_hosts, '/etc/hosts')
|
342
|
-
elsif ((host['platform']
|
341
|
+
elsif ((host['platform'].include?('windows')) and not host.is_cygwin?)
|
343
342
|
host.exec(Command.new("echo '#{etc_hosts}' >> C:\\Windows\\System32\\drivers\\etc\\hosts"))
|
344
343
|
else
|
345
344
|
host.exec(Command.new("echo '#{etc_hosts}' >> /etc/hosts"))
|
346
345
|
end
|
347
346
|
# AIX must be configured to prefer local DNS over external
|
348
|
-
if host['platform']
|
347
|
+
if host['platform'].include?('aix')
|
349
348
|
aix_netsvc = '/etc/netsvc.conf'
|
350
349
|
aix_local_resolv = 'hosts = local, bind'
|
351
350
|
unless host.exec(Command.new("grep '#{aix_local_resolv}' #{aix_netsvc}"), :accept_all_exit_codes => true).exit_code == 0
|
@@ -362,10 +361,10 @@ module Beaker
|
|
362
361
|
logger = opts[:logger]
|
363
362
|
block_on host do |host|
|
364
363
|
logger.debug "Give root a copy of current user's keys, on #{host.name}"
|
365
|
-
if host['platform']
|
364
|
+
if host['platform'].include?('windows') and host.is_cygwin?
|
366
365
|
host.exec(Command.new('cp -r .ssh /cygdrive/c/Users/Administrator/.'))
|
367
366
|
host.exec(Command.new('chown -R Administrator /cygdrive/c/Users/Administrator/.ssh'))
|
368
|
-
elsif host['platform']
|
367
|
+
elsif host['platform'].include?('windows') and not host.is_cygwin?
|
369
368
|
# from https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true:
|
370
369
|
# /i : If Source is a directory or contains wildcards and Destination
|
371
370
|
# does not exist, xcopy assumes destination specifies a directory
|
@@ -376,16 +375,12 @@ module Beaker
|
|
376
375
|
# /y : Suppresses prompting to confirm that you want to overwrite an
|
377
376
|
# existing destination file.
|
378
377
|
host.exec(Command.new("if exist .ssh (xcopy .ssh C:\\Users\\Administrator\\.ssh /s /e /y /i)"))
|
379
|
-
elsif host['platform']
|
378
|
+
elsif host['platform'].include?('osx')
|
380
379
|
host.exec(Command.new('sudo cp -r .ssh /var/root/.'), {:pty => true})
|
381
|
-
elsif host['platform']
|
380
|
+
elsif /(free|open)bsd/.match?(host['platform']) || host['platform'].include?('solaris-11')
|
382
381
|
host.exec(Command.new('sudo cp -r .ssh /root/.'), {:pty => true})
|
383
|
-
elsif host['platform']
|
384
|
-
host.exec(Command.new('sudo cp -r .ssh /root/.'), {:pty => true})
|
385
|
-
elsif host['platform'] =~ /solaris-10/
|
382
|
+
elsif host['platform'].include?('solaris-10')
|
386
383
|
host.exec(Command.new('sudo cp -r .ssh /.'), {:pty => true})
|
387
|
-
elsif host['platform'] =~ /solaris-11/
|
388
|
-
host.exec(Command.new('sudo cp -r .ssh /root/.'), {:pty => true})
|
389
384
|
else
|
390
385
|
host.exec(Command.new('sudo su -c "cp -r .ssh /root/."'), {:pty => true})
|
391
386
|
end
|
@@ -404,7 +399,7 @@ module Beaker
|
|
404
399
|
# @param [Host, Array<Host>] hosts An array of hosts to act upon
|
405
400
|
# @param [Hash{Symbol=>String}] opts Options to alter execution.
|
406
401
|
# @option opts [Beaker::Logger] :logger A {Beaker::Logger} object
|
407
|
-
def hack_etc_hosts hosts,
|
402
|
+
def hack_etc_hosts hosts, _opts
|
408
403
|
etc_hosts = "127.0.0.1\tlocalhost localhost.localdomain\n"
|
409
404
|
hosts.each do |host|
|
410
405
|
ip = host['vm_ip'] || host['ip'].to_s
|
@@ -423,7 +418,7 @@ module Beaker
|
|
423
418
|
def disable_updates hosts, opts
|
424
419
|
logger = opts[:logger]
|
425
420
|
hosts.each do |host|
|
426
|
-
next if host['platform']
|
421
|
+
next if host['platform'].include?('netscaler')
|
427
422
|
logger.notify "Disabling updates.puppetlabs.com by modifying hosts file to resolve updates to 127.0.0.1 on #{host}"
|
428
423
|
set_etc_hosts(host, "127.0.0.1\tupdates.puppetlabs.com\n")
|
429
424
|
end
|
@@ -440,42 +435,40 @@ module Beaker
|
|
440
435
|
logger = opts[:logger]
|
441
436
|
block_on host do |host|
|
442
437
|
logger.debug "Update sshd_config to allow root login"
|
443
|
-
if host['platform']
|
438
|
+
if host['platform'].include?('osx')
|
444
439
|
# If osx > 10.10 use '/private/etc/ssh/sshd_config', else use '/etc/sshd_config'
|
445
440
|
ssh_config_file = '/private/etc/ssh/sshd_config'
|
446
|
-
ssh_config_file = '/etc/sshd_config' if
|
441
|
+
ssh_config_file = '/etc/sshd_config' if /^osx-10\.(9|10)/i.match?(host['platform'])
|
447
442
|
|
448
443
|
host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin no/PermitRootLogin Yes/g' #{ssh_config_file}"))
|
449
444
|
host.exec(Command.new("sudo sed -i '' 's/#PermitRootLogin yes/PermitRootLogin Yes/g' #{ssh_config_file}"))
|
450
|
-
elsif host['platform']
|
445
|
+
elsif host['platform'].include?('freebsd')
|
451
446
|
host.exec(Command.new("sudo sed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true} )
|
452
|
-
elsif host['platform']
|
447
|
+
elsif host['platform'].include?('openbsd')
|
453
448
|
host.exec(Command.new("sudo perl -pi -e 's/^PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config"), {:pty => true} )
|
454
|
-
elsif host['platform']
|
449
|
+
elsif host['platform'].include?('solaris-10')
|
455
450
|
host.exec(Command.new("sudo gsed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true} )
|
456
|
-
elsif host['platform']
|
451
|
+
elsif host['platform'].include?('solaris-11')
|
457
452
|
host.exec(Command.new("if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi"), {:pty => true} )
|
458
453
|
host.exec(Command.new("sudo gsed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true} )
|
459
|
-
elsif host['platform']
|
454
|
+
elsif host['platform'].include?('f5') || host.is_powershell?
|
460
455
|
#interacting with f5 should using tmsh
|
461
456
|
logger.warn("Attempting to enable root login non-supported platform: #{host.name}: #{host['platform']}")
|
462
457
|
elsif host.is_cygwin?
|
463
458
|
host.exec(Command.new("sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config"), {:pty => true})
|
464
|
-
elsif host.is_powershell?
|
465
|
-
logger.warn("Attempting to enable root login non-supported platform: #{host.name}: #{host['platform']}")
|
466
459
|
else
|
467
460
|
host.exec(Command.new("sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""), {:pty => true})
|
468
461
|
end
|
469
462
|
#restart sshd
|
470
|
-
if host['platform']
|
463
|
+
if /debian|ubuntu|cumulus/.match?(host['platform'])
|
471
464
|
host.exec(Command.new("sudo su -c \"service ssh restart\""), {:pty => true})
|
472
|
-
elsif
|
465
|
+
elsif /arch|(centos|el|redhat)-[789]|fedora-(1[4-9]|2[0-9]|3[0-9])/.match?(host['platform'])
|
473
466
|
host.exec(Command.new("sudo -E systemctl restart sshd.service"), {:pty => true})
|
474
|
-
elsif
|
467
|
+
elsif /centos|el-|redhat|fedora|eos/.match?(host['platform'])
|
475
468
|
host.exec(Command.new("sudo -E /sbin/service sshd reload"), {:pty => true})
|
476
|
-
elsif host['platform']
|
469
|
+
elsif /(free|open)bsd/.match?(host['platform'])
|
477
470
|
host.exec(Command.new("sudo /etc/rc.d/sshd restart"))
|
478
|
-
elsif host['platform']
|
471
|
+
elsif host['platform'].include?('solaris')
|
479
472
|
host.exec(Command.new("sudo -E svcadm restart network/ssh"), {:pty => true} )
|
480
473
|
else
|
481
474
|
logger.warn("Attempting to update ssh on non-supported platform: #{host.name}: #{host['platform']}")
|
@@ -490,11 +483,11 @@ module Beaker
|
|
490
483
|
def disable_se_linux host, opts
|
491
484
|
logger = opts[:logger]
|
492
485
|
block_on host do |host|
|
493
|
-
if
|
494
|
-
|
486
|
+
if /centos|el-|redhat|fedora|eos/.match?(host['platform'])
|
487
|
+
logger.debug("Disabling se_linux on #{host.name}")
|
495
488
|
host.exec(Command.new("sudo su -c \"setenforce 0\""), {:pty => true})
|
496
489
|
else
|
497
|
-
|
490
|
+
logger.warn("Attempting to disable SELinux on non-supported platform: #{host.name}: #{host['platform']}")
|
498
491
|
end
|
499
492
|
end
|
500
493
|
end
|
@@ -506,7 +499,7 @@ module Beaker
|
|
506
499
|
def disable_iptables host, opts
|
507
500
|
logger = opts[:logger]
|
508
501
|
block_on host do |host|
|
509
|
-
if
|
502
|
+
if /centos|el-|redhat|fedora|eos/.match?(host['platform'])
|
510
503
|
logger.debug("Disabling iptables on #{host.name}")
|
511
504
|
host.exec(Command.new("sudo su -c \"/etc/init.d/iptables stop\""), {:pty => true})
|
512
505
|
else
|
@@ -550,7 +543,7 @@ module Beaker
|
|
550
543
|
def additive_hash_merge h1, h2
|
551
544
|
merged_hash = {}
|
552
545
|
normalized_h2 = h2.inject({}) { |h, (k, v)| h[k.to_s.upcase] = v; h }
|
553
|
-
h1.each_pair do |key,
|
546
|
+
h1.each_pair do |key, _val|
|
554
547
|
normalized_key = key.to_s.upcase
|
555
548
|
if normalized_h2.has_key?(normalized_key)
|
556
549
|
merged_hash[key] = [h1[key], normalized_h2[normalized_key]]
|
@@ -594,7 +587,7 @@ module Beaker
|
|
594
587
|
|
595
588
|
logger.debug("setting local environment on #{host.name}")
|
596
589
|
|
597
|
-
if host['platform']
|
590
|
+
if host['platform'].include?('windows') && host.is_cygwin?
|
598
591
|
env['CYGWIN'] = 'nodosfilewarning'
|
599
592
|
end
|
600
593
|
|
data/lib/beaker/hypervisor.rb
CHANGED
@@ -56,7 +56,7 @@ module Beaker
|
|
56
56
|
|
57
57
|
DEFAULT_CONNECTION_PREFERENCE = [:ip, :vmhostname, :hostname]
|
58
58
|
# SSH connection method preference. Can be overwritten by hypervisor to change the order
|
59
|
-
def connection_preference(
|
59
|
+
def connection_preference(_host)
|
60
60
|
DEFAULT_CONNECTION_PREFERENCE
|
61
61
|
end
|
62
62
|
|
@@ -105,9 +105,9 @@ module Beaker
|
|
105
105
|
if @options[:disable_updates]
|
106
106
|
disable_updates(@hosts, @options)
|
107
107
|
end
|
108
|
-
rescue SignalException =>
|
109
|
-
if
|
110
|
-
report_and_raise(@logger,
|
108
|
+
rescue SignalException => e
|
109
|
+
if e.signo == 15 #SIGTERM
|
110
|
+
report_and_raise(@logger, e, "configure")
|
111
111
|
end
|
112
112
|
raise
|
113
113
|
end
|
@@ -19,7 +19,7 @@ module Beaker
|
|
19
19
|
connection
|
20
20
|
end
|
21
21
|
|
22
|
-
def connect
|
22
|
+
def connect _options = {}
|
23
23
|
@logger.debug "Local connection, no connection to start"
|
24
24
|
end
|
25
25
|
|
@@ -35,7 +35,7 @@ module Beaker
|
|
35
35
|
ENV.replace(backup)
|
36
36
|
end
|
37
37
|
|
38
|
-
def execute command,
|
38
|
+
def execute command, _options = {}, stdout_callback = nil, _stderr_callback = stdout_callback
|
39
39
|
result = Result.new(@hostname, command)
|
40
40
|
envs = {}
|
41
41
|
if File.readable?(@ssh_env_file)
|
@@ -46,7 +46,7 @@ module Beaker
|
|
46
46
|
end
|
47
47
|
|
48
48
|
begin
|
49
|
-
clean_env = ENV.reject{ |k|
|
49
|
+
clean_env = ENV.reject{ |k| /^BUNDLE|^RUBY|^GEM/.match?(k) }
|
50
50
|
|
51
51
|
with_env(clean_env) do
|
52
52
|
std_out, std_err, status = Open3.capture3(envs, command)
|
data/lib/beaker/logger.rb
CHANGED
@@ -65,8 +65,6 @@ module Beaker
|
|
65
65
|
@log_level = :trace
|
66
66
|
when /debug/i, :debug
|
67
67
|
@log_level = :debug
|
68
|
-
when /verbose/i, :verbose
|
69
|
-
@log_level = :verbose
|
70
68
|
when /info/i, :info
|
71
69
|
@log_level = :info
|
72
70
|
when /notify/i, :notify
|
@@ -132,9 +130,7 @@ module Beaker
|
|
132
130
|
# @param [Array<IO, String>] dest Array of strings (each used as a file path) and IO steams that messages will be printed to
|
133
131
|
def add_destination(dest)
|
134
132
|
case dest
|
135
|
-
when IO
|
136
|
-
@destinations << dest
|
137
|
-
when StringIO
|
133
|
+
when IO, StringIO
|
138
134
|
@destinations << dest
|
139
135
|
when String
|
140
136
|
@destinations << File.open(dest, 'w')
|
@@ -147,9 +143,7 @@ module Beaker
|
|
147
143
|
# @param [String, IO] dest String representing a file path or IO stream
|
148
144
|
def remove_destination(dest)
|
149
145
|
case dest
|
150
|
-
when IO
|
151
|
-
@destinations.delete(dest)
|
152
|
-
when StringIO
|
146
|
+
when IO, StringIO
|
153
147
|
@destinations.delete(dest)
|
154
148
|
when String
|
155
149
|
@destinations.delete_if {|d| d.respond_to?(:path) and d.path == dest}
|
@@ -220,7 +214,7 @@ module Beaker
|
|
220
214
|
prefix_log_line s
|
221
215
|
end
|
222
216
|
else
|
223
|
-
line.
|
217
|
+
line.delete!("\r")
|
224
218
|
has_ending_newline = line.end_with?("\n")
|
225
219
|
actual_lines = line.split("\n")
|
226
220
|
actual_lines.map! do |actual_line|
|
@@ -233,7 +227,7 @@ module Beaker
|
|
233
227
|
end
|
234
228
|
|
235
229
|
# Indent the step level for the duration of block.
|
236
|
-
def with_indent(
|
230
|
+
def with_indent()
|
237
231
|
old_line_prefix = self.line_prefix.dup
|
238
232
|
self.line_prefix << ' '
|
239
233
|
yield
|
@@ -444,7 +438,7 @@ module Beaker
|
|
444
438
|
end
|
445
439
|
|
446
440
|
# And remove lines that contain our program name in them
|
447
|
-
|
441
|
+
mostly_purged.reject {|line| line.include? $0 }
|
448
442
|
end
|
449
443
|
|
450
444
|
# Utility method that takes a path as input, checks each component
|
data/lib/beaker/logger_junit.rb
CHANGED
@@ -21,7 +21,7 @@ module Beaker
|
|
21
21
|
def self.write_xml(xml_file, stylesheet, &block)
|
22
22
|
doc, suites = self.get_xml_contents(xml_file, name, stylesheet)
|
23
23
|
|
24
|
-
if
|
24
|
+
if block
|
25
25
|
case block.arity
|
26
26
|
when 2
|
27
27
|
yield doc, suites
|
@@ -86,7 +86,7 @@ module Beaker
|
|
86
86
|
suites = REXML::XPath.first(doc, "testsuites")
|
87
87
|
#remove old data
|
88
88
|
suites.elements.each("testsuite") do |e|
|
89
|
-
if
|
89
|
+
if /#{name}/.match?(e.name)
|
90
90
|
suites.delete_element e
|
91
91
|
end
|
92
92
|
end
|
@@ -17,7 +17,7 @@ module Beaker
|
|
17
17
|
def provision? options, host
|
18
18
|
command_line_says = options[:provision]
|
19
19
|
host_says = host['hypervisor'] && (host.has_key?('provision') ? host['provision'] : true)
|
20
|
-
(command_line_says && host_says) or
|
20
|
+
(command_line_says && host_says) or host['hypervisor'].include?('vagrant')
|
21
21
|
end
|
22
22
|
|
23
23
|
attr_accessor :hosts, :hypervisors
|
@@ -53,7 +53,7 @@ module Beaker
|
|
53
53
|
end
|
54
54
|
@hypervisors = {}
|
55
55
|
#sort hosts by their hypervisor, use hypervisor 'none' if no hypervisor is specified
|
56
|
-
hostless_options = Beaker::Options::OptionsHash.new.merge(@options.select{ |k,
|
56
|
+
hostless_options = Beaker::Options::OptionsHash.new.merge(@options.select{ |k,_v| !k.to_s.include?('HOSTS')})
|
57
57
|
@options['HOSTS'].each_key do |name|
|
58
58
|
host_hash = @options['HOSTS'][name]
|
59
59
|
hypervisor = host_hash['hypervisor']
|
@@ -191,7 +191,7 @@ module Beaker
|
|
191
191
|
'slow (attempt to continue run post test failure)',
|
192
192
|
'stop (DEPRECATED, please use fast)',
|
193
193
|
'(default: slow)' do |mode|
|
194
|
-
@cmd_options[:fail_mode] = mode
|
194
|
+
@cmd_options[:fail_mode] = mode.include?('stop') ? 'fast' : mode
|
195
195
|
end
|
196
196
|
|
197
197
|
opts.on '--test-results-file /FILE/TO/SAVE/TO.rb',
|
@@ -2,7 +2,24 @@ module Beaker
|
|
2
2
|
module Options
|
3
3
|
#A set of functions to parse hosts files
|
4
4
|
module HostsFileParser
|
5
|
-
PERMITTED_YAML_CLASSES = [
|
5
|
+
PERMITTED_YAML_CLASSES = [
|
6
|
+
'Beaker',
|
7
|
+
'Beaker::Logger',
|
8
|
+
'Beaker::Options::OptionsHash',
|
9
|
+
'Beaker::Platform',
|
10
|
+
'Beaker::Result',
|
11
|
+
'File',
|
12
|
+
'IO',
|
13
|
+
'Logger',
|
14
|
+
'Logger::Formatter',
|
15
|
+
'Logger::LogDevice',
|
16
|
+
'Monitor',
|
17
|
+
'Net::SSH::Prompt',
|
18
|
+
'StringifyHash',
|
19
|
+
'StringIO',
|
20
|
+
'Symbol',
|
21
|
+
'Time',
|
22
|
+
]
|
6
23
|
|
7
24
|
# Read the contents of the hosts.cfg into an OptionsHash, merge the 'CONFIG' section into the OptionsHash, return OptionsHash
|
8
25
|
# @param [String] hosts_file_path The path to the hosts file
|
@@ -75,7 +92,7 @@ module Beaker
|
|
75
92
|
# @param [String] error_message Message to print if {::Psych::SyntaxError}
|
76
93
|
# is raised during block execution
|
77
94
|
# @return [OptionsHash] Updated host_options with host info merged
|
78
|
-
def self.merge_hosts_yaml( host_options, error_message
|
95
|
+
def self.merge_hosts_yaml( host_options, error_message )
|
79
96
|
begin
|
80
97
|
loaded_host_options = yield
|
81
98
|
rescue Psych::SyntaxError => e
|
@@ -98,9 +115,9 @@ module Beaker
|
|
98
115
|
ERB.new(template, nil, '-')
|
99
116
|
end
|
100
117
|
if RUBY_VERSION >= '2.6'
|
101
|
-
YAML.safe_load(erb_obj.result(b), permitted_classes: PERMITTED_YAML_CLASSES)
|
118
|
+
YAML.safe_load(erb_obj.result(b), permitted_classes: PERMITTED_YAML_CLASSES, aliases: true)
|
102
119
|
else
|
103
|
-
YAML.load(erb_obj.result(b))
|
120
|
+
YAML.load(erb_obj.result(b)) # rubocop:disable Security/YAMLLoad
|
104
121
|
end
|
105
122
|
end
|
106
123
|
end
|
@@ -28,7 +28,7 @@ module Beaker
|
|
28
28
|
result = Beaker::Options::OptionsHash.new
|
29
29
|
if options_file_path
|
30
30
|
options_file_path = File.expand_path(options_file_path)
|
31
|
-
unless File.
|
31
|
+
unless File.exist?(options_file_path)
|
32
32
|
raise ArgumentError, "Specified options file '#{options_file_path}' does not exist!"
|
33
33
|
end
|
34
34
|
# This eval will allow the specified options file to have access to our
|
@@ -15,7 +15,7 @@ module Beaker
|
|
15
15
|
#
|
16
16
|
# @return [Boolean]
|
17
17
|
def is_pe?
|
18
|
-
self[:type] ? self[:type]
|
18
|
+
self[:type] ? self[:type].include?('pe') : true
|
19
19
|
end
|
20
20
|
|
21
21
|
# Determine the puppet type of the ObjectHash
|
@@ -31,8 +31,6 @@ module Beaker
|
|
31
31
|
case self[:type]
|
32
32
|
when /pe/
|
33
33
|
:pe
|
34
|
-
when /foss/
|
35
|
-
:foss
|
36
34
|
else
|
37
35
|
:foss
|
38
36
|
end
|
@@ -43,7 +43,7 @@ module Beaker
|
|
43
43
|
arry = []
|
44
44
|
if arg.is_a?(Array)
|
45
45
|
arry += arg
|
46
|
-
elsif arg
|
46
|
+
elsif arg.include?(',')
|
47
47
|
arry += arg.split(',')
|
48
48
|
else
|
49
49
|
arry << arg
|
@@ -281,7 +281,7 @@ module Beaker
|
|
281
281
|
# @raise [ArgumentError] if a hosts file is generated, but it can't
|
282
282
|
# be read by the HostsFileParser
|
283
283
|
def parse_hosts_options
|
284
|
-
if @options[:hosts_file].nil? || File.
|
284
|
+
if @options[:hosts_file].nil? || File.exist?(@options[:hosts_file])
|
285
285
|
#read the hosts file that contains the node configuration and hypervisor info
|
286
286
|
return Beaker::Options::HostsFileParser.parse_hosts_file(@options[:hosts_file])
|
287
287
|
end
|
@@ -298,11 +298,11 @@ module Beaker
|
|
298
298
|
bhg_cli = BeakerHostGenerator::CLI.new(host_generator_options)
|
299
299
|
bhg_cli.execute
|
300
300
|
rescue BeakerHostGenerator::Exceptions::Error,
|
301
|
-
BeakerHostGenerator::Exceptions::InvalidNodeSpecError =>
|
301
|
+
BeakerHostGenerator::Exceptions::InvalidNodeSpecError => e
|
302
302
|
error_message = "\nbeaker-hostgenerator was not able to use this value as input."
|
303
303
|
error_message << "\nExiting with an Error.\n\n"
|
304
304
|
$stderr.puts error_message
|
305
|
-
raise
|
305
|
+
raise e
|
306
306
|
end
|
307
307
|
|
308
308
|
@options[:hosts_file_generated] = true
|
@@ -375,7 +375,7 @@ module Beaker
|
|
375
375
|
#check that windows/el-4 boxes are only agents (solaris can be a master in foss cases)
|
376
376
|
@options[:HOSTS].each_key do |name|
|
377
377
|
host = @options[:HOSTS][name]
|
378
|
-
if
|
378
|
+
if /windows|el-4/.match?(host[:platform])
|
379
379
|
test_host_roles(name, host)
|
380
380
|
end
|
381
381
|
|
@@ -461,7 +461,7 @@ module Beaker
|
|
461
461
|
exclude_roles = %w(master database dashboard)
|
462
462
|
host_roles = host_hash[:roles]
|
463
463
|
unless (host_roles & exclude_roles).empty?
|
464
|
-
@validator.parser_error "#{host_hash[:platform]
|
464
|
+
@validator.parser_error "#{host_hash[:platform]} box '#{host_name}' may not have roles: #{exclude_roles.join(', ')}."
|
465
465
|
end
|
466
466
|
end
|
467
467
|
|
@@ -45,7 +45,7 @@ module Beaker
|
|
45
45
|
def select_env_by_regex regex
|
46
46
|
envs = Beaker::Options::OptionsHash.new
|
47
47
|
ENV.each_pair do | k, v |
|
48
|
-
if
|
48
|
+
if /#{regex}/.match?(k.to_s)
|
49
49
|
envs[k] = v
|
50
50
|
end
|
51
51
|
end
|
@@ -105,7 +105,7 @@ module Beaker
|
|
105
105
|
found = found.merge(format_found_env_vars( collect_env_vars( ENVIRONMENT_SPEC )))
|
106
106
|
found[:answers] = select_env_by_regex('\\Aq_')
|
107
107
|
|
108
|
-
found.delete_if {|
|
108
|
+
found.delete_if {|_key, value| value.nil? or value.empty? }
|
109
109
|
found
|
110
110
|
end
|
111
111
|
|
@@ -52,7 +52,7 @@ module Beaker
|
|
52
52
|
# @return [nil] Does not return anything
|
53
53
|
def validate_fail_mode(fail_mode)
|
54
54
|
#check for valid fail mode
|
55
|
-
|
55
|
+
unless fail_mode.is_a?(String) && VALID_FAIL_MODES.match?(fail_mode)
|
56
56
|
validator_error "--fail-mode must be one of fast or slow, not '#{fail_mode}'"
|
57
57
|
end
|
58
58
|
end
|
@@ -63,7 +63,7 @@ module Beaker
|
|
63
63
|
# @return [nil] Does not return anything
|
64
64
|
def validate_preserve_hosts(hosts_setting)
|
65
65
|
#check for valid preserve_hosts option
|
66
|
-
|
66
|
+
unless hosts_setting.is_a?(String) && VALID_PRESERVE_HOSTS.match?(hosts_setting)
|
67
67
|
validator_error("--preserve_hosts must be one of always, onfail, onpass or never, not '#{hosts_setting}'")
|
68
68
|
end
|
69
69
|
end
|
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
|