drop our implementation of script_run in favour of os-autoinst

Summary:
os-autoinst implements `script_run` itself now, we aren't
required to implement it ourselves any more. os-autoinst's
implementation is better than ours, as it allows for verifying
the script actually ran (via the redirect-output-to-serial-
console trick).

So this drops our implementation so we'll just use the upstream
one. Where I judged we don't want to bother with the 'check
the command actually ran' feature I've adjusted our direct
`script_run` calls to pass a wait time of 0, which skips the
'wait for command to run' stuff entirely and just does a simple
'type the string and hit enter'.

Because of how the inheritance works, our `assert_script_run`
calls already used the os-autoinst `script_run`, rather than
the one from our distribution.

This should prevent `prepare_test_packages` sometimes going
wrong right after removing the python3-kickstart package, as
we'll properly wait for that removal to complete now (before
we weren't, we'd just start typing the next command while it
was still running, which could result in lost keypresses).

Test Plan:
Check all tests still run OK (I've tried this on
staging and it seems fine).

Reviewers: jskladan, garretraziel

Reviewed By: garretraziel

Subscribers: tflink

Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D1034
This commit is contained in:
Adam Williamson 2016-10-20 09:24:48 -07:00
parent 7869c3d07a
commit dcb68d93c8
6 changed files with 15 additions and 23 deletions

View File

@ -36,20 +36,20 @@ sub post_fail_hook {
if ($has_traceback) {
# Upload Anaconda traceback logs
script_run "tar czf /tmp/anaconda_tb.tar.gz /tmp/anaconda-tb-*";
script_run "tar czf /tmp/anaconda_tb.tar.gz /tmp/anaconda-tb-*", 0;
upload_logs "/tmp/anaconda_tb.tar.gz";
}
# Upload all ABRT logs
script_run "tar czf /var/tmp/var_tmp.tar.gz /var/tmp";
script_run "tar czf /var/tmp/var_tmp.tar.gz /var/tmp", 0;
upload_logs "/var/tmp/var_tmp.tar.gz";
# Upload /var/log
script_run "tar czf /tmp/var_log.tar.gz /var/log";
script_run "tar czf /tmp/var_log.tar.gz /var/log", 0;
upload_logs "/tmp/var_log.tar.gz";
# Upload anaconda core dump, if there is one
script_run "ls /tmp/anaconda.core.* && tar czf /tmp/anaconda.core.tar.gz /tmp/anaconda.core.*";
script_run "ls /tmp/anaconda.core.* && tar czf /tmp/anaconda.core.tar.gz /tmp/anaconda.core.*", 0;
upload_logs "/tmp/anaconda.core.tar.gz", failok=>1;
}

View File

@ -10,11 +10,10 @@ use base 'distribution';
# ensure_installed
# x11_start_program
# become_root
# script_run
# script_sudo
# type_password
# importing whole testapi creates circular dependency, so import inly
# importing whole testapi creates circular dependency, so import only
# necessary functions from testapi
use testapi qw(send_key type_string wait_idle assert_screen);
@ -33,12 +32,5 @@ sub x11_start_program {
send_key "ret", 1;
}
sub script_run {
my ($self, $program, $timeout) = @_;
type_string $program;
send_key "ret", $timeout;
}
1;
# vim: set sw=4 et:

View File

@ -28,19 +28,19 @@ sub post_fail_hook {
my $vartmp = script_output "ls /var/tmp/abrt";
if ($vartmp ne '') {
# Upload /var/tmp ABRT logs
script_run "cd /var/tmp/abrt && tar czvf tmpabrt.tar.gz *";
script_run "cd /var/tmp/abrt && tar czvf tmpabrt.tar.gz *", 0;
upload_logs "/var/tmp/abrt/tmpabrt.tar.gz";
}
my $varspool = script_output "ls /var/spool/abrt";
if ($varspool ne '') {
# Upload /var/spool ABRT logs
script_run "cd /var/spool/abrt && tar czvf spoolabrt.tar.gz *";
script_run "cd /var/spool/abrt && tar czvf spoolabrt.tar.gz *", 0;
upload_logs "/var/spool/abrt/spoolabrt.tar.gz";
}
# Upload /var/log
# lastlog can mess up tar sometimes and it's not much use
script_run "tar czvf /tmp/var_log.tar.gz --exclude='lastlog' /var/log";
script_run "tar czvf /tmp/var_log.tar.gz --exclude='lastlog' /var/log", 0;
upload_logs "/tmp/var_log.tar.gz";
}
@ -90,8 +90,8 @@ sub repo_setup {
# and we don't want to bother testing or predicting its existence;
# assert_script_run doesn't buy you much with sed anyway as it'll
# return 0 even if it replaced nothing
script_run "sed -i -e 's,^metalink,#metalink,g' -e 's,^#baseurl.*basearch,baseurl=${location}/Everything/\$basearch,g' /etc/yum.repos.d/{fedora,fedora-rawhide}.repo";
script_run "cat /etc/yum.repos.d/{fedora,fedora-rawhide}.repo";
script_run "sed -i -e 's,^metalink,#metalink,g' -e 's,^#baseurl.*basearch,baseurl=${location}/Everything/\$basearch,g' /etc/yum.repos.d/{fedora,fedora-rawhide}.repo", 0;
script_run "cat /etc/yum.repos.d/{fedora,fedora-rawhide}.repo", 0;
}
1;

View File

@ -13,7 +13,7 @@ our @EXPORT = qw/prepare_test_packages verify_installed_packages verify_updated_
sub prepare_test_packages {
# remove python3-kickstart if installed (we don't use assert
# here in case it's not)
script_run 'dnf -y remove python3-kickstart';
script_run 'dnf -y remove python3-kickstart', 180;
# we seem to often lose keystrokes in the next command if we run
# it too fast, let's wait for idle first
wait_idle 20;

View File

@ -12,7 +12,7 @@ sub run {
# to force an expected starting state.
script_run "systemctl stop sshd.service";
script_run "systemctl disable sshd.service";
script_run "reboot";
script_run "reboot", 0;
boot_to_login_screen;
$self->root_console(tty=>3);
# note the use of ! here is a bash-ism, but it sure makes life easier
@ -31,14 +31,14 @@ sub run {
assert_script_run 'systemctl is-enabled sshd.service';
assert_script_run '! systemctl is-active sshd.service';
assert_script_run '! ps -C sshd';
script_run "reboot";
script_run "reboot", 0;
boot_to_login_screen;
$self->root_console(tty=>3);
assert_script_run 'systemctl is-enabled sshd.service';
assert_script_run 'systemctl is-active sshd.service';
assert_script_run 'ps -C sshd';
script_run "systemctl disable sshd.service";
script_run "reboot";
script_run "reboot", 0;
boot_to_login_screen;
$self->root_console(tty=>3);
assert_script_run '! systemctl is-enabled sshd.service';

View File

@ -18,7 +18,7 @@ sub run {
# upgrader should be installed on up-to-date system
assert_script_run 'dnf -y update', 1800;
script_run "reboot";
script_run "reboot", 0;
# decrypt if necessary
if (get_var("ENCRYPT_PASSWORD")) {