os-autoinst-distri-rocky-mi.../lib/installedtest.pm

85 lines
2.2 KiB
Perl
Raw Normal View History

package installedtest;
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
use base 'fedorabase';
# 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;
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 {
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
check => 1, # whether to fail when console wasn't reached
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}";
$self->console_login(check=>$args{check});
}
sub post_fail_hook {
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
$self->root_console(tty=>2);
# If /var/tmp/abrt directory isn't empty (ls doesn't return empty string)
my $vartmp = script_output "ls /var/tmp/abrt";
if ($vartmp ne '') {
# Upload all ABRT logs
script_run "cd /var/tmp/abrt && tar czvf abrt.tar.gz *";
upload_logs "/var/tmp/abrt/abrt.tar.gz";
}
# Upload /var/log
script_run "tar czvf /tmp/var_log.tar.gz /var/log";
upload_logs "/tmp/var_log.tar.gz";
}
convert upgrade tests to dnf-plugin-system-upgrade Summary: This is a first cut which more or less works for now. Issues: 1) We're not really testing the BUILD, here. All the test does is try and upgrade to the specified VERSION - so it'll be using the latest 'stable' for the given VERSION at the time the test runs. This isn't really that terrible, but especially for TC/RC validation, we might want to make things a bit more elaborate and set up the repo for the actual BUILD (and disable the main repos). 2) We'd actually need --nogpgcheck for non-Rawhide, at one specific point in the release cycle - after Branching but before Bodhi activation (which is when we can be sure all packages are signed). This won't matter until 24 branches, and maybe releng will have it fixed by then...if not, I'll tweak it. 3) We don't really test that the upgrade actually *happened* for desktop, at the moment - the only thing in the old test that really checked that was where we checked for the fedup boot menu entry, but that has no analog in dnf. What we should probably do is check that GUI login works, then switch to a console and check /etc/fedora-release just as the minimal test does. Test Plan: Run the tests. Note that creating the desktop disk image doesn't work ATM, so I can't verify the desktop test works, but the minimal one seems to (with D565). There'll be a matching diff for openqa_fedora_tools to update the test case names there. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D567
2015-09-10 21:49:13 +00:00
sub check_release {
my $self = shift;
my $release = shift;
my $check_command = "grep SUPPORT_PRODUCT_VERSION /usr/lib/os.release.d/os-release-fedora";
validate_script_output $check_command, sub { $_ =~ m/REDHAT_SUPPORT_PRODUCT_VERSION=$release/ };
convert upgrade tests to dnf-plugin-system-upgrade Summary: This is a first cut which more or less works for now. Issues: 1) We're not really testing the BUILD, here. All the test does is try and upgrade to the specified VERSION - so it'll be using the latest 'stable' for the given VERSION at the time the test runs. This isn't really that terrible, but especially for TC/RC validation, we might want to make things a bit more elaborate and set up the repo for the actual BUILD (and disable the main repos). 2) We'd actually need --nogpgcheck for non-Rawhide, at one specific point in the release cycle - after Branching but before Bodhi activation (which is when we can be sure all packages are signed). This won't matter until 24 branches, and maybe releng will have it fixed by then...if not, I'll tweak it. 3) We don't really test that the upgrade actually *happened* for desktop, at the moment - the only thing in the old test that really checked that was where we checked for the fedup boot menu entry, but that has no analog in dnf. What we should probably do is check that GUI login works, then switch to a console and check /etc/fedora-release just as the minimal test does. Test Plan: Run the tests. Note that creating the desktop disk image doesn't work ATM, so I can't verify the desktop test works, but the minimal one seems to (with D565). There'll be a matching diff for openqa_fedora_tools to update the test case names there. Reviewers: jskladan, garretraziel Reviewed By: jskladan, garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D567
2015-09-10 21:49:13 +00:00
}
sub menu_launch_type {
my $self = shift;
my $app = shift;
# super does not work on KDE, because fml
send_key 'alt-f1';
# srsly KDE y u so slo
wait_still_screen 3;
type_string "$app";
wait_still_screen 3;
send_key 'ret';
}
add cockpit_default and cockpit_basic tests Summary: This adds tests for the Server_cockpit_default and cockpit_basic test cases. Some notes: I was initially thinking of combining these into a single test with multiple test modules and coming up with a system for doing wiki reporting based on individual test module status, but because we'll also want to do a cockpit FreeIPA enrol test, I decided against it. We don't really want to combine all three because then we would skip the cockpit tests whenever FreeIPA server deployment failed, which isn't ideal. So since we'll need a separate FreeIPA enrolment test anyway it doesn't really make sense to go to the trouble of designing a system for loading multiple postinstall tests (though I have an idea for that!) and a per-module wiki reporting system. This was the most minimal and hopefully reliable method for running Cockpit from a stock Server install that I could think of. An alternative approach would be to have, say, the most recent stable Workstation live as a 'stock' asset and have two tests, one which runs a stock Server install and just waits and another which boots the live image and accesses the cockpit running on the other box, but that seems a bit over-complex. It is not possible to have dependencies between tests for different ISOs, in case you were wondering about having a Workstation live test which runs parallel with a Server DVD test, we can't do that. One funny thing is the font that winds up getting used for the desktop, but I don't *think* that should be a problem. Picking needles was a bit tricky; any improvement suggestions are welcome. I'm hoping it turns out to be safe to rely on some dbus log messages being present; I think logging into Cockpit triggers activation of the realmd dbus interface, so there *should* always be some messages related to that. An alternative would just be to match on a sliver of the dark grey table header and the light grey row beneath it and assume that'll always be the first message (whatever the message is), but then we have to find some area of the message details screen which is always present for any message, and it just seems a tad more likely to result in false passes. Similary I'm making an assumption that auditd is always going to show up on the first page of the Services screen and the details screen will always show that 'loaded...enabled' text. Test Plan: Run the tests and see if they work! See https://openqa.stg.fedoraproject.org/tests/21373 and https://openqa.stg.fedoraproject.org/tests/21371 for my tests. Reviewers: garretraziel Reviewed By: garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D874
2016-06-01 16:05:33 +00:00
sub start_cockpit {
my $self = shift;
my $login = shift || 0;
# run firefox directly in X as root. never do this, kids!
type_string "startx /usr/bin/firefox\n";
assert_screen "firefox";
# open a new tab so we don't race with the default page load
# (also focuses the location bar for us)
send_key "ctrl-t";
type_string "http://localhost:9090";
# firefox's stupid 'smart' url bar is a pain. wait for things to settle.
wait_still_screen 3;
send_key "ret";
assert_screen "cockpit_login";
if ($login) {
type_string "root";
send_key "tab";
type_string get_var("ROOT_PASSWORD", "weakpassword");
send_key "ret";
assert_screen "cockpit_main";
}
}
1;
# vim: set sw=4 et: