1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-21 13:33:08 +00:00

Run update repo setup steps from a serial console

This is a surprisingly large change as we want to go back to
the console we were previously on after doing it. To do that we
need to know what console we were on, and to know *that*, we need
to port everything that currently uses (ctrl-)alt-fX to switch
consoles to use select_console instead.

This is primarily intended to make running setup_repos.py faster
when it has to download a lot of packages (as typing in hundreds
of package names is quite slow). But it actually makes the whole
thing faster, even when only downloading one or two packages.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2024-01-09 10:37:57 -08:00
parent d445a80016
commit 5f702b0be8
16 changed files with 60 additions and 37 deletions

View File

@ -313,14 +313,13 @@ sub crash_anaconda_text {
# It is used in the `install_text.pm` test and can be switched on by using the CRASH_REPORT
# variable set to 1.
#
# First let us navigate to reach the shell window in Anaconda using the alt-f3 combo,
# this should take us to another terminal, where we can simulate the crash.
send_key "alt-f3";
# tty3 has a shell on all f31+ installer and live images
select_console "tty3-console";
assert_screen("anaconda_text_install_shell");
# We use the trigger command to do the simulated crash.
type_string "kill -USR1 `cat /var/run/anaconda.pid`\n";
# And navigate back to the main panel of Anaconda. This should require
send_key "alt-f1";
select_console "tty1-console";
assert_screen("anaconda_text_install_main");
# We wait until the crash menu appears. This usually takes some time,
# so let's try for 300 seconds, this should be long enough.

View File

@ -141,7 +141,7 @@ sub root_console {
}
else {
# tty3 has a shell on all f31+ installer and live images
send_key "ctrl-alt-f3";
select_console "tty3-console";
}
console_login(user => "root", timeout => $args{timeout});
}

View File

@ -20,7 +20,7 @@ use Cwd;
# importing whole testapi creates circular dependency, so import only
# necessary functions from testapi
use testapi qw(check_var get_var send_key type_string assert_screen check_screen assert_script_run validate_script_output enter_cmd type_password);
use testapi qw(check_var get_var send_key type_string assert_screen check_screen assert_script_run validate_script_output enter_cmd type_password select_console);
use utils qw(console_login desktop_vt menu_launch_type);
# Class constructor
@ -48,6 +48,12 @@ sub init() {
# "virtio-console1", third as "virtio-console2" etc.
$self->add_console('virtio-console' . $num, 'virtio_terminal', {socked_path => cwd() . '/virtio_console' . $num});
}
$self->add_console('tty1-console', 'tty-console', {tty => 1});
$self->add_console('tty2-console', 'tty-console', {tty => 2});
$self->add_console('tty3-console', 'tty-console', {tty => 3});
$self->add_console('tty4-console', 'tty-console', {tty => 4});
$self->add_console('tty5-console', 'tty-console', {tty => 5});
$self->add_console('tty6-console', 'tty-console', {tty => 6});
}
}
@ -79,7 +85,7 @@ sub ensure_installed {
# In that case, we want to return to GUI after the routine finishes.
$stay_on_console = 0;
# From GUI we need to switch to the console.
send_key("ctrl-alt-f3");
select_console "tty3-console";
# Let's wait to allow for screen changes.
sleep 5;
# And do the login.

View File

@ -9,7 +9,7 @@ use base 'basetest';
# should be used when with tests, where system is already installed, e. g all parts
# of upgrade tests, postinstall phases...
use testapi qw(is_serial_terminal :DEFAULT);
use testapi qw(is_serial_terminal :DEFAULT select_console);
use utils;
sub root_console {
@ -27,7 +27,7 @@ sub root_console {
}
else {
# For normal terminal emulation, use key combo to reach a tty
send_key "ctrl-alt-f$args{tty}";
select_console "tty$args{tty}-console";
}
console_login(timeout => $args{timeout}); # Do the login.
}

View File

@ -6,7 +6,7 @@ use base 'Exporter';
use Exporter;
use lockapi;
use testapi;
use testapi qw(is_serial_terminal :DEFAULT);
our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp/;
@ -163,7 +163,7 @@ sub console_login {
# and let us simplify the process.
# We will check if we are logged in, and if so, we will log out to
# enable a new proper login based on the user variable.
if (get_var("SERIAL_CONSOLE")) {
if (get_var("SERIAL_CONSOLE") || is_serial_terminal()) {
# Check for the usual prompt.
if (wait_serial("~\][#\$]", timeout => 5, quiet => 1)) {
type_string "logout\n";
@ -173,7 +173,7 @@ sub console_login {
# Do the new login.
type_string $args{user};
type_string "\n";
sleep 2;
wait_serial("Password:", timeout => 2, quiet => 1);
type_string $args{password};
type_string "\n";
# Let's perform a simple login test. This is the same as
@ -285,7 +285,7 @@ sub desktop_vt {
while ($xout =~ /tty(\d)/g) {
$tty = $1; # most recent match is probably best
}
send_key "ctrl-alt-f${tty}";
select_console "tty${tty}-console";
# work around https://gitlab.gnome.org/GNOME/gnome-software/issues/582
# if it happens. As of 2019-05, seeing something similar on KDE too
my $desktop = get_var('DESKTOP');
@ -302,10 +302,10 @@ sub desktop_vt {
click_lastmatch if ($desktop eq 'kde');
if (match_has_tag "auth_required_fprint") {
my $user = get_var("USER_LOGIN", "test");
send_key "ctrl-alt-f6";
select_console "tty6-console";
console_login;
assert_script_run "echo SCAN ${user}-finger-1 | socat STDIN UNIX-CONNECT:/run/fprintd-virt";
send_key "ctrl-alt-f${tty}";
select_console "tty${tty}-console";
}
elsif (match_has_tag "auth_required_locked") {
# When console operation takes a long time, the screen locks
@ -636,7 +636,23 @@ sub _repo_setup_updates {
# unless (script_run 'pushd /etc/yum.repos.d && tar czvf yumreposd.tar.gz * && popd') {
# upload_logs "/etc/yum.repos.d/yumreposd.tar.gz";
# }
# if no current console is registered, assume we're on tty1
my $currcon = current_console || "tty1-console";
# do all this setup from a serial console for speed (especially when
# downloading large updates)
# the console we register as 'virtio-console' is the first virtio
# serial console, 'virtio_console' on the qemu command line.
# on most platforms, this console is /dev/hvc0 (and the default
# qemu serial console, which for openQA is backed by a ringbuf
# device and logged as serial0.txt, is /dev/ttyS0). however, on
# Power, the default serial console is /dev/hvc0 and the first
# virtio serial console is /dev/hvc1.
# it seems we get a getty on ttyS0 and hvc0 by default, but we
# don't get one on hvc1. so on Power, start a tty on hvc1
assert_script_run 'systemctl start serial-getty@hvc1.service' if (get_var("OFW"));
script_run "echo 'Package download and repo creation happening on serial console...'";
select_console("virtio-console");
console_login();
# prepare the directory the packages will be downloaded to, unless we're
# testing a side tag
_prepare_update_mount() unless ($tag);
@ -644,8 +660,8 @@ sub _repo_setup_updates {
# on CANNED, we need to enter the toolbox at this point
if (get_var("CANNED")) {
type_string "toolbox -y enter\n";
# look for the little purple dot
assert_screen "console_in_toolbox", 180;
# this is simply to wait till we're in the toolbox
assert_script_run "true", 180;
}
# use mirrorlist not metalink in repo configs
@ -687,8 +703,10 @@ sub _repo_setup_updates {
# exit the toolbox on CANNED
if (get_var("CANNED")) {
type_string "exit\n";
wait_still_screen 5;
wait_serial "# ";
}
# flip back to whatever console we were on before
select_console $currcon;
}
sub repo_setup {

View File

@ -79,7 +79,7 @@ sub run {
# just for convenience - sometimes it's useful to see this log
# for a success case
upload_logs "/tmp/packaging.log", failok => 1;
send_key "ctrl-alt-f6";
select_console "tty6-console";
# Anaconda hub
assert_screen "anaconda_main_hub", 30;

View File

@ -5,7 +5,7 @@ use utils;
sub run {
my $self = shift;
send_key "ctrl-alt-f3";
select_console "tty3-console";
# do user login unless USER_LOGIN is set to string 'false'
# Since there is no console support for arabic, so we cannot let the user log in
# with a password that requires Arabic support.

View File

@ -90,7 +90,7 @@ sub run {
if (get_var("IMAGE_DEPLOY")) {
# if this was an image deployment, we also need to create
# root user now, for subsequent tests to work
send_key "ctrl-alt-f3";
select_console "tty3-console";
console_login(user => get_var("USER_LOGIN", "test"), password => get_var("USER_PASSWORD", "weakpassword"));
type_string "sudo su\n";
type_string "$password\n";

View File

@ -22,7 +22,7 @@ sub run {
# line looks like:
# 07:40:26,614 DBG ui.lib.software: Selecting the 'custom-environment' environment.
assert_script_run "grep 'Selecting the.*environment' /tmp/anaconda.log /tmp/packaging.log | tail -1 | grep $env";
send_key "ctrl-alt-f6";
select_console "tty6-console";
assert_screen "anaconda_main_hub", 30;
return;
}

View File

@ -31,7 +31,7 @@ sub run {
# desktop_vt subroutine, but since we do not have networking
# it does not work reliably. Ergo, we will use the old known
# ctrl-alt-f2
send_key("ctrl-alt-f2");
select_console "tty2-console";
sleep(3);
# Toggle network

View File

@ -22,7 +22,7 @@ sub run {
# we need to use script_run as regular user
assert_script_run "chmod ugo+w /dev/" . $serialdev;
# let's go to another tty and login as regular user
send_key "alt-f2";
select_console "tty2-console";
console_login(user => "test", password => "weakpassword");
assert_script_run "curl -O https://fedorapeople.org/groups/qa/tunirtests.tar.gz";
assert_script_run "tar xvf tunirtests.tar.gz";
@ -51,7 +51,7 @@ sub run {
# we need to use script_run as regular user again
assert_script_run "sudo chmod ugo+w /dev/" . $serialdev;
# let's go to another tty and login as regular user again
send_key "alt-f2";
select_console "tty2-console";
console_login(user => "test", password => "weakpassword");
_soft_fail_run "tunirtests.testreboot.TestReboot";
assert_script_run "sudo python3 -m unittest tunirtests.cloudservice.TestServiceManipulation -v";
@ -63,7 +63,7 @@ sub run {
# we need to use script_run as regular user again
assert_script_run "sudo chmod ugo+w /dev/" . $serialdev;
# let's go to another tty and login as regular user again
send_key "alt-f2";
select_console "tty2-console";
console_login(user => "test", password => "weakpassword");
assert_script_run "sudo python3 -m unittest tunirtests.cloudservice.TestServiceAfter -v";
if (get_var("CANNED")) {

View File

@ -43,7 +43,7 @@ sub run {
# the GDM tty needs to be active when the scan happens, so we will
# schedule the scan to happen in 20 seconds then go deal with gdm
type_string "sleep 20; echo SCAN $user-finger-1 | socat STDIN UNIX-CONNECT:/run/fprintd-virt\n";
send_key "ctrl-alt-f1";
select_console "tty1-console";
mouse_hide;
send_key_until_needlematch("graphical_login_input", "ret", 3, 5);
# now we check that we see the "or scan fingerprint" message, then
@ -59,7 +59,7 @@ sub run {
# we're doing the same as before, but scanning the 'wrong thing'
# (note finger-2 not finger-1)
type_string "sleep 20; echo SCAN $user-finger-2 | socat STDIN UNIX-CONNECT:/run/fprintd-virt\n";
send_key "ctrl-alt-f1";
select_console "tty1-console";
mouse_hide;
send_key_until_needlematch("graphical_login_input", "ret", 3, 5);
assert_screen "graphical_login_fprint";

View File

@ -15,7 +15,7 @@ sub run {
# switch to tty1 (we're usually there already, but just in case
# we're carrying on from a failed freeipa_webui that didn't fail
# at tty1)
send_key "ctrl-alt-f1";
select_console "tty1-console";
wait_still_screen 1;
if (get_var("KICKSTART")) {
# we don't have sssd debugging enabled yet
@ -52,7 +52,7 @@ sub run {
# Set a longer timeout for login(1) to workaround RHBZ #1661273
assert_script_run 'echo "LOGIN_TIMEOUT 180" >> /etc/login.defs';
# switch to tty2 for login tests
send_key "ctrl-alt-f2";
select_console "tty2-console";
# try and login as test1, should work
console_login(user => "test1\@$domain", password => 'batterystaple');
type_string "exit\n";

View File

@ -49,7 +49,7 @@ sub run {
assert_script_run 'printf "correcthorse\nbatterystaple\nbatterystaple" | kinit test3@TEST.OPENQA.FEDORAPROJECT.ORG';
assert_script_run 'printf "correcthorse\nbatterystaple\nbatterystaple" | kinit test4@TEST.OPENQA.FEDORAPROJECT.ORG';
# switch to tty4 (boy, the tty jugglin')
send_key "ctrl-alt-f4";
select_console "tty4-console";
# try and login as test3, should work
console_login(user => 'test3@TEST.OPENQA.FEDORAPROJECT.ORG', password => 'batterystaple');
type_string "exit\n";
@ -63,7 +63,7 @@ sub run {
type_string "batterystaple\n";
assert_screen "login_permission_denied";
# back to tty1
send_key "ctrl-alt-f1";
select_console "tty1-console";
}
sub test_flags {

View File

@ -77,8 +77,8 @@ sub run {
assert_script_run 'ipa-server-install -U --uninstall', 300;
# try and un-garble the screen that the above sometimes garbles
# ...we may be on tty1 or tty3 now, so flip between them
send_key "ctrl-alt-f1";
send_key "ctrl-alt-f3";
select_console "tty1-console";
select_console "tty3-console";
}
else {
assert_script_run "echo '${admin_pw}' | realm join --user=${admin_user} ${server}", 300;

View File

@ -36,8 +36,8 @@ sub run {
assert_script_run 'ipa-server-install -U --uninstall', 300;
# try and un-garble the screen that the above sometimes garbles
# ...we may be on tty1 or tty3 now, so flip between them
send_key "ctrl-alt-f1";
send_key "ctrl-alt-f3";
select_console "tty1-console";
select_console "tty3-console";
# FIXME check server is decommissioned...how?
}