From dcb68d93c84806046339b83d42177d0fed4c4f5a Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 20 Oct 2016 09:24:48 -0700 Subject: [PATCH] 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 --- lib/anacondatest.pm | 8 ++++---- lib/fedoradistribution.pm | 10 +--------- lib/installedtest.pm | 10 +++++----- lib/packagetest.pm | 2 +- tests/base_service_manipulation.pm | 6 +++--- tests/upgrade_preinstall.pm | 2 +- 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/lib/anacondatest.pm b/lib/anacondatest.pm index 3edc4817..ae5ea9b9 100644 --- a/lib/anacondatest.pm +++ b/lib/anacondatest.pm @@ -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; } diff --git a/lib/fedoradistribution.pm b/lib/fedoradistribution.pm index d1c501a1..e551af6d 100644 --- a/lib/fedoradistribution.pm +++ b/lib/fedoradistribution.pm @@ -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: diff --git a/lib/installedtest.pm b/lib/installedtest.pm index b5737d04..30a08032 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -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; diff --git a/lib/packagetest.pm b/lib/packagetest.pm index c3d0fe22..a0a3e05d 100644 --- a/lib/packagetest.pm +++ b/lib/packagetest.pm @@ -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; diff --git a/tests/base_service_manipulation.pm b/tests/base_service_manipulation.pm index 51771267..118aa04f 100644 --- a/tests/base_service_manipulation.pm +++ b/tests/base_service_manipulation.pm @@ -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'; diff --git a/tests/upgrade_preinstall.pm b/tests/upgrade_preinstall.pm index c2e3a076..9dda0fca 100644 --- a/tests/upgrade_preinstall.pm +++ b/tests/upgrade_preinstall.pm @@ -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")) {