1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-04 23:24:21 +00:00
os-autoinst-distri-fedora/lib/installedtest.pm

65 lines
1.9 KiB
Perl
Raw Normal View History

package installedtest;
use base 'basetest';
# base class for tests that run on installed system
# should be used when with tests, where system is already installed, e. g all parts
# of upgrade tests, postinstall phases...
use testapi;
use utils;
create fedora base class, factor out console login Summary: Root console in anaconda got broken by RHBZ #1222413 - no shell on tty2. Decided to clean up console use in general as part of fixing it. This creates a class 'fedorabase' and has 'anacondalog' and 'fedoralog' both inherit from it. boot_to_login_screen is moved there (as it seems appropriate) and it has a new method, console_login, which basically handles 'get me a shell on a console': if we're already at one it returns, if not it'll type the user name and the password *if necessary* (sometimes it's not) and return once it sees a prompt. It takes a hash of named parameters for user, password and 'check', which is whether it should die if it fails to reach a console or not (some users don't want it to). anacondalog and fedoralog both get 'root_console' methods which do something appropriate and then call console_login; both have a hash of named parameters, anacondalog's version only bothers with 'check', while fedoralog's also accepts 'tty' to pick the tty to use. This also adjusts all things which try to get to a console prompt to use either root_console or console_login as appropriate. It also tweaks the needle tags a bit, drops some unneeded needles, and adds a new 'user console prompt' needle; we really just need two versions of the root prompt needle and two of the user prompt needle (one for <F23, one for F23+ - the console font changed in F23, and the @ character at least doesn't match between the two). I think we still need the <F23 case for upgrade tests, for now. Test Plan: Do a full test run and see that more tests succeed. I've done a run on happyassassin with a hack to workaround the SELinux issue for interactive installs, and the results look good. I also fiddled about a bit to test some different cases, like forcing a failure in a live test to test post_fail_hook (and hence root_console) in that scenario, and forcing failures after some console commands had been run to check that it DTRT when we've already reached a console, etc. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D462
2015-07-22 18:24:40 +00:00
sub root_console {
# Switch to a default or specified TTY and log in as root.
my $self = shift;
create fedora base class, factor out console login Summary: Root console in anaconda got broken by RHBZ #1222413 - no shell on tty2. Decided to clean up console use in general as part of fixing it. This creates a class 'fedorabase' and has 'anacondalog' and 'fedoralog' both inherit from it. boot_to_login_screen is moved there (as it seems appropriate) and it has a new method, console_login, which basically handles 'get me a shell on a console': if we're already at one it returns, if not it'll type the user name and the password *if necessary* (sometimes it's not) and return once it sees a prompt. It takes a hash of named parameters for user, password and 'check', which is whether it should die if it fails to reach a console or not (some users don't want it to). anacondalog and fedoralog both get 'root_console' methods which do something appropriate and then call console_login; both have a hash of named parameters, anacondalog's version only bothers with 'check', while fedoralog's also accepts 'tty' to pick the tty to use. This also adjusts all things which try to get to a console prompt to use either root_console or console_login as appropriate. It also tweaks the needle tags a bit, drops some unneeded needles, and adds a new 'user console prompt' needle; we really just need two versions of the root prompt needle and two of the user prompt needle (one for <F23, one for F23+ - the console font changed in F23, and the @ character at least doesn't match between the two). I think we still need the <F23 case for upgrade tests, for now. Test Plan: Do a full test run and see that more tests succeed. I've done a run on happyassassin with a hack to workaround the SELinux issue for interactive installs, and the results look good. I also fiddled about a bit to test some different cases, like forcing a failure in a live test to test post_fail_hook (and hence root_console) in that scenario, and forcing failures after some console commands had been run to check that it DTRT when we've already reached a console, etc. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D462
2015-07-22 18:24:40 +00:00
my %args = (
tty => 1, # what TTY to login to
create fedora base class, factor out console login Summary: Root console in anaconda got broken by RHBZ #1222413 - no shell on tty2. Decided to clean up console use in general as part of fixing it. This creates a class 'fedorabase' and has 'anacondalog' and 'fedoralog' both inherit from it. boot_to_login_screen is moved there (as it seems appropriate) and it has a new method, console_login, which basically handles 'get me a shell on a console': if we're already at one it returns, if not it'll type the user name and the password *if necessary* (sometimes it's not) and return once it sees a prompt. It takes a hash of named parameters for user, password and 'check', which is whether it should die if it fails to reach a console or not (some users don't want it to). anacondalog and fedoralog both get 'root_console' methods which do something appropriate and then call console_login; both have a hash of named parameters, anacondalog's version only bothers with 'check', while fedoralog's also accepts 'tty' to pick the tty to use. This also adjusts all things which try to get to a console prompt to use either root_console or console_login as appropriate. It also tweaks the needle tags a bit, drops some unneeded needles, and adds a new 'user console prompt' needle; we really just need two versions of the root prompt needle and two of the user prompt needle (one for <F23, one for F23+ - the console font changed in F23, and the @ character at least doesn't match between the two). I think we still need the <F23 case for upgrade tests, for now. Test Plan: Do a full test run and see that more tests succeed. I've done a run on happyassassin with a hack to workaround the SELinux issue for interactive installs, and the results look good. I also fiddled about a bit to test some different cases, like forcing a failure in a live test to test post_fail_hook (and hence root_console) in that scenario, and forcing failures after some console commands had been run to check that it DTRT when we've already reached a console, etc. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D462
2015-07-22 18:24:40 +00:00
@_);
create fedora base class, factor out console login Summary: Root console in anaconda got broken by RHBZ #1222413 - no shell on tty2. Decided to clean up console use in general as part of fixing it. This creates a class 'fedorabase' and has 'anacondalog' and 'fedoralog' both inherit from it. boot_to_login_screen is moved there (as it seems appropriate) and it has a new method, console_login, which basically handles 'get me a shell on a console': if we're already at one it returns, if not it'll type the user name and the password *if necessary* (sometimes it's not) and return once it sees a prompt. It takes a hash of named parameters for user, password and 'check', which is whether it should die if it fails to reach a console or not (some users don't want it to). anacondalog and fedoralog both get 'root_console' methods which do something appropriate and then call console_login; both have a hash of named parameters, anacondalog's version only bothers with 'check', while fedoralog's also accepts 'tty' to pick the tty to use. This also adjusts all things which try to get to a console prompt to use either root_console or console_login as appropriate. It also tweaks the needle tags a bit, drops some unneeded needles, and adds a new 'user console prompt' needle; we really just need two versions of the root prompt needle and two of the user prompt needle (one for <F23, one for F23+ - the console font changed in F23, and the @ character at least doesn't match between the two). I think we still need the <F23 case for upgrade tests, for now. Test Plan: Do a full test run and see that more tests succeed. I've done a run on happyassassin with a hack to workaround the SELinux issue for interactive installs, and the results look good. I also fiddled about a bit to test some different cases, like forcing a failure in a live test to test post_fail_hook (and hence root_console) in that scenario, and forcing failures after some console commands had been run to check that it DTRT when we've already reached a console, etc. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D462
2015-07-22 18:24:40 +00:00
send_key "ctrl-alt-f$args{tty}";
console_login;
}
sub post_fail_hook {
my $self = shift;
if (check_screen 'emergency_rescue', 3) {
my $password = get_var("ROOT_PASSWORD", "weakpassword");
type_string "$password\n";
# bring up network so we can upload logs
assert_script_run "dhclient";
}
else {
$self->root_console(tty=>6);
}
# We can't rely on tar being in minimal installs, but we also can't
# rely on dnf always working (it fails in emergency mode, not sure
# why), so try it, then check if we have tar
script_run "dnf -y install tar", 180;
assert_script_run "rpm -q tar";
# Note: script_run returns the exit code, so the logic looks weird.
# We're testing that the directory exists and contains something.
unless (script_run 'test -n "$(ls -A /var/tmp/abrt)" && cd /var/tmp/abrt && tar czvf tmpabrt.tar.gz *') {
add a cockpit realmd FreeIPA join test Summary: This requires a few other changes: * turn clone_host_resolv into clone_host_file, letting you clone any given host file (cloning /etc/hosts seems to make both server deployment and client enrolment faster/more reliable) * allow loading of multiple POSTINSTALL tests (so we can share the freeipa_client_postinstall test). Note this is compatible, existing uses will work fine * move initial password change for the IPA test users into the server deployment test (so the client tests don't conflict over doing that) * add GRUB_POSTINSTALL, for specifying boot parameters for boot of the installed system, and make it work by tweaking _console_wait _login (doesn't work for _graphical_wait_login yet, as I didn't need that) * make the static networking config for tap tests into a library function so the tests can share it * handle ABRT problem dirs showing up in /var/spool/abrt as well as /var/tmp/abrt (because the enrol attempt hits #1330766 and the crash report shows up in /var/spool/abrt, don't ask me why the difference, I just work here) * specify the DNS servers from the worker host's resolv.conf as the forwarders for the FreeIPA server when deploying it; if we don't do this, rolekit defaults to using the root servers as forwarders(!) and thus we get the public, not phx2-appropriate, results for e.g. mirrors.fedoraproject.org, some of which the workers can't reach, so PackageKit package install always fails (boy, was it fun figuring THAT mess out) Even after all that, the test still doesn't actually pass, but I'm reasonably confident this is because it's hitting actual bugs, not because it's broken. It runs into #1330766 nearly every time (I think I saw *one* time the enrolment actually succeeded), and seems to run into a subsequent bug I hadn't seen before when trying to work around that by trying the join again (see https://bugzilla.redhat.com/show_bug.cgi?id=1330766#c37 ). Test Plan: Run the test, see what happens. If you're really lucky, it'll actually pass. But you'll probably run into #1330766#c37, I'm mostly posting for comment. You'll need a tap-capable openQA instance to test this. Reviewers: jskladan, garretraziel Reviewed By: garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D880
2016-06-07 20:00:39 +00:00
upload_logs "/var/tmp/abrt/tmpabrt.tar.gz";
}
unless (script_run 'test -n "$(ls -A /var/spool/abrt)" && cd /var/spool/abrt && tar czvf spoolabrt.tar.gz *') {
add a cockpit realmd FreeIPA join test Summary: This requires a few other changes: * turn clone_host_resolv into clone_host_file, letting you clone any given host file (cloning /etc/hosts seems to make both server deployment and client enrolment faster/more reliable) * allow loading of multiple POSTINSTALL tests (so we can share the freeipa_client_postinstall test). Note this is compatible, existing uses will work fine * move initial password change for the IPA test users into the server deployment test (so the client tests don't conflict over doing that) * add GRUB_POSTINSTALL, for specifying boot parameters for boot of the installed system, and make it work by tweaking _console_wait _login (doesn't work for _graphical_wait_login yet, as I didn't need that) * make the static networking config for tap tests into a library function so the tests can share it * handle ABRT problem dirs showing up in /var/spool/abrt as well as /var/tmp/abrt (because the enrol attempt hits #1330766 and the crash report shows up in /var/spool/abrt, don't ask me why the difference, I just work here) * specify the DNS servers from the worker host's resolv.conf as the forwarders for the FreeIPA server when deploying it; if we don't do this, rolekit defaults to using the root servers as forwarders(!) and thus we get the public, not phx2-appropriate, results for e.g. mirrors.fedoraproject.org, some of which the workers can't reach, so PackageKit package install always fails (boy, was it fun figuring THAT mess out) Even after all that, the test still doesn't actually pass, but I'm reasonably confident this is because it's hitting actual bugs, not because it's broken. It runs into #1330766 nearly every time (I think I saw *one* time the enrolment actually succeeded), and seems to run into a subsequent bug I hadn't seen before when trying to work around that by trying the join again (see https://bugzilla.redhat.com/show_bug.cgi?id=1330766#c37 ). Test Plan: Run the test, see what happens. If you're really lucky, it'll actually pass. But you'll probably run into #1330766#c37, I'm mostly posting for comment. You'll need a tap-capable openQA instance to test this. Reviewers: jskladan, garretraziel Reviewed By: garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D880
2016-06-07 20:00:39 +00:00
upload_logs "/var/spool/abrt/spoolabrt.tar.gz";
}
# Upload /var/log
add QA:Testcase_FreeIPA_password_change test Summary: again, added as a non-fatal module for realmd_join_cockpit as it's convenient to do it here. Also abstract a couple of ipa bits into a new exporter package in the style of SUSE's mm_network, rather than using ill-fitting class inheritance as we have before - we should probably convert our existing class based stuff to work this way. Also a few minor tweaks and clean-ups of the other tests: The path in console_login() where we detect login of a regular user when we want root or vice versa and log out was actually broken because it would 'wait' for the result of the 'exit' command, which obviously doesn't work (as it relies on running another command afterwards, and we're no longer at a shell). This commit no longer actually uses that path, but I spotted the bug with an earlier version of this which did, and we may as well keep the fix. /var/log/lastlog is an apparently-extremely-large sparse file. A couple of times it seemed to cause tar to run very slowly while creating the /var/log archive for upload on failure. It's no use for diagnosing bugs, so we may as well exclude it from the archive. I caught cockpit webUI login failing one time when testing the test, so threw in a wait_still_screen before starting to type the URL, as we have for the FreeIPA webUI. I also caught a timing issue with the openQA webUI policy add step; the test flips from the Users screen to the HBAC screen then clicks the 'add' button, but there's actually an identical 'add' button on *both* screens, so it could wind up trying to click the one on the Users screen instead, if the web UI took a few milliseconds to switch. So we throw in a needle match to make sure we're actually on the HBAC screen before clicking the button. We make the freeipa_webui test a 'milestone' so that if the new test fails, restoring to the last-known-good milestone doesn't take so long; it actually seems like openQA can get confused and try to cancel the test if restoring the milestone takes a *really* long time, and wind up with a zombie qemu process, which isn't good. This seems to avoid that happening. Test Plan: In the simple case, just run all the FreeIPA-related tests on Fedora 24 (as Rawhide is broken) and make sure they all work properly. To get a bit more advanced you can throw in an `assert_script_run 'false'` in either of the non-fatal tests to break it and make sure things go properly when that happens (the last milestone should be restored - which should be right after freeipa_webui, sitting at tty1 - and run properly; things are set up so each test starts with root logged in on tty1). Reviewers: jskladan, garretraziel Reviewed By: garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D935
2016-08-03 20:21:12 +00:00
# lastlog can mess up tar sometimes and it's not much use
unless (script_run "tar czvf /tmp/var_log.tar.gz --exclude='lastlog' /var/log") {
upload_logs "/tmp/var_log.tar.gz";
}
# Sometimes useful for diagnosing FreeIPA issues
upload_logs "/etc/nsswitch.conf", failok=>1;
}
1;
# vim: set sw=4 et: