2015-08-06 09:01:41 +00:00
|
|
|
package installedtest;
|
2020-02-13 21:31:05 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2017-01-18 07:15:44 +00:00
|
|
|
use base 'basetest';
|
2015-05-13 11:00:46 +00:00
|
|
|
|
2015-08-05 06:23:59 +00:00
|
|
|
# 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...
|
|
|
|
|
2020-07-08 00:35:32 +00:00
|
|
|
use testapi qw(is_serial_terminal :DEFAULT);
|
2017-01-18 07:15:44 +00:00
|
|
|
use utils;
|
2015-05-13 11:00:46 +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
|
|
|
sub root_console {
|
2018-03-09 04:31:14 +00:00
|
|
|
# Switch to a default or specified TTY and log in as root.
|
2015-05-13 11:00:46 +00:00
|
|
|
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 = (
|
2022-07-28 20:32:57 +00:00
|
|
|
tty => 1, # what TTY to login to
|
|
|
|
timeout => 0, # passed through to console_login
|
|
|
|
@_
|
|
|
|
);
|
2019-11-06 12:55:27 +00:00
|
|
|
if (get_var("SERIAL_CONSOLE")) {
|
|
|
|
# select the first virtio terminal, for now we assume we can
|
|
|
|
# always use that (we may have to make this smarter in future)
|
2019-11-20 16:39:28 +00:00
|
|
|
select_console("virtio-console");
|
2019-11-06 12:55:27 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# For normal terminal emulation, use key combo to reach a tty
|
|
|
|
send_key "ctrl-alt-f$args{tty}";
|
|
|
|
}
|
2022-07-28 20:32:57 +00:00
|
|
|
console_login(timeout => $args{timeout}); # Do the login.
|
2015-07-15 05:00:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub post_fail_hook {
|
|
|
|
my $self = shift;
|
|
|
|
|
2020-10-28 22:21:03 +00:00
|
|
|
if (check_screen ['emergency_rescue', 'emergency_rescue_nopassword'], 3) {
|
|
|
|
if (match_has_tag 'emergency_rescue') {
|
|
|
|
my $password = get_var("ROOT_PASSWORD", "weakpassword");
|
|
|
|
type_string "$password";
|
|
|
|
}
|
|
|
|
send_key 'ret';
|
2017-01-31 10:29:59 +00:00
|
|
|
# bring up network so we can upload logs
|
|
|
|
assert_script_run "dhclient";
|
|
|
|
}
|
|
|
|
else {
|
2022-07-28 20:32:57 +00:00
|
|
|
$self->root_console(tty => 6);
|
2018-12-14 00:29:53 +00:00
|
|
|
# fix up keyboard layout, if we failed before the test did this
|
|
|
|
# itself; if it's already been done, should be safe, will just
|
|
|
|
# fail and carry on
|
|
|
|
console_loadkeys_us;
|
2017-01-31 10:29:59 +00:00
|
|
|
}
|
2015-05-13 11:00:46 +00:00
|
|
|
|
2019-01-16 19:24:06 +00:00
|
|
|
# if we're in dracut, do things different
|
|
|
|
my $dracut = 0;
|
|
|
|
if (check_screen "root_console_dracut", 0) {
|
|
|
|
$dracut = 1;
|
|
|
|
script_run "dhclient";
|
|
|
|
}
|
|
|
|
|
2017-01-31 10:29:59 +00:00
|
|
|
# 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
|
2020-07-06 23:38:12 +00:00
|
|
|
# why), so try it. if we don't get a return code, process may be
|
|
|
|
# stuck waiting on network or something, so hit ctrl-c
|
2020-07-08 00:35:32 +00:00
|
|
|
unless (script_run "dnf -y install tar", 180) {
|
|
|
|
unless (is_serial_terminal) {
|
|
|
|
send_key "ctrl-c";
|
|
|
|
}
|
|
|
|
}
|
2018-12-12 19:40:58 +00:00
|
|
|
|
|
|
|
# if we don't have tar or a network connection, we'll try and at
|
|
|
|
# least send out *some* kinda info via the serial line
|
2018-12-12 19:57:53 +00:00
|
|
|
my $hostip = testapi::host_ip();
|
2018-12-12 20:28:23 +00:00
|
|
|
if ((script_run "rpm -q tar") || (script_run "ping -c 2 ${hostip}")) {
|
2019-01-16 19:24:06 +00:00
|
|
|
if ($dracut) {
|
|
|
|
script_run 'printf "\n** RDSOSREPORT **\n" > /dev/' . $serialdev;
|
|
|
|
script_run "cat /run/initramfs/rdsosreport.txt > /dev/${serialdev}";
|
|
|
|
return;
|
|
|
|
}
|
2018-12-12 20:28:23 +00:00
|
|
|
script_run 'printf "\n** IP ADDR **\n" > /dev/' . $serialdev;
|
|
|
|
script_run "ip addr > /dev/${serialdev} 2>&1";
|
|
|
|
script_run 'printf "\n** IP ROUTE **\n" > /dev/' . $serialdev;
|
|
|
|
script_run "ip route > /dev/${serialdev} 2>&1";
|
|
|
|
script_run 'printf "\n** NETWORKMANAGER.SERVICE STATUS **\n" > /dev/' . $serialdev;
|
2018-12-12 20:36:21 +00:00
|
|
|
script_run "systemctl --no-pager -l status NetworkManager.service > /dev/${serialdev} 2>&1";
|
2018-12-12 20:28:23 +00:00
|
|
|
script_run 'printf "\n** JOURNAL **\n" > /dev/' . $serialdev;
|
2022-05-11 23:13:52 +00:00
|
|
|
script_run "journalctl --no-pager > /dev/${serialdev}";
|
2018-12-12 19:40:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-10-28 00:07:20 +00:00
|
|
|
|
2019-01-16 19:24:06 +00:00
|
|
|
if ($dracut) {
|
2022-07-28 20:32:57 +00:00
|
|
|
upload_logs "/run/initramfs/rdsosreport.txt", failok => 1;
|
2019-01-16 19:24:06 +00:00
|
|
|
# that's all that's really useful, so...
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-31 18:41:10 +00:00
|
|
|
# Note: script_run returns the exit code, so the logic looks weird.
|
|
|
|
# We're testing that the directory exists and contains something.
|
2019-08-16 18:29:30 +00:00
|
|
|
unless (script_run 'test -n "$(ls -A /var/tmp/abrt)" && cd /var/tmp/abrt && tar czvf tmpabrt.tar.gz *') {
|
|
|
|
upload_logs "/var/tmp/abrt/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
|
|
|
}
|
2016-10-31 18:41:10 +00:00
|
|
|
|
2019-08-16 18:29:30 +00:00
|
|
|
unless (script_run 'test -n "$(ls -A /var/spool/abrt)" && cd /var/spool/abrt && tar czvf spoolabrt.tar.gz *') {
|
|
|
|
upload_logs "/var/spool/abrt/spoolabrt.tar.gz";
|
2015-11-04 13:38:36 +00:00
|
|
|
}
|
2015-05-13 11:00:46 +00:00
|
|
|
|
2018-04-04 19:08:34 +00:00
|
|
|
# upload any core dump files caught by coredumpctl
|
2019-08-16 18:29:30 +00:00
|
|
|
unless (script_run 'test -n "$(ls -A /var/lib/systemd/coredump)" && cd /var/lib/systemd/coredump && tar czvf coredump.tar.gz *') {
|
|
|
|
upload_logs "/var/lib/systemd/coredump/coredump.tar.gz";
|
2018-04-04 19:08:34 +00:00
|
|
|
}
|
|
|
|
|
2019-05-02 01:59:52 +00:00
|
|
|
# upload bind log (for FreeIPA server test)
|
2019-08-16 18:29:30 +00:00
|
|
|
unless (script_run 'test -f /var/named/data/named.run') {
|
|
|
|
upload_logs "/var/named/data/named.run";
|
2019-05-02 01:59:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 23:18:32 +00:00
|
|
|
# update PostgreSQL initialization log (for database_server test)
|
|
|
|
unless (script_run 'test -f /var/lib/pgsql/initdb_postgresql.log') {
|
|
|
|
upload_logs "/var/lib/pgsql/initdb_postgresql.log";
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:00:46 +00:00
|
|
|
# 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
|
2019-08-16 18:29:30 +00:00
|
|
|
unless (script_run "tar czvf /tmp/var_log.tar.gz --exclude='lastlog' /var/log") {
|
2016-10-31 18:41:10 +00:00
|
|
|
upload_logs "/tmp/var_log.tar.gz";
|
|
|
|
}
|
2017-03-16 19:36:33 +00:00
|
|
|
|
|
|
|
# Sometimes useful for diagnosing FreeIPA issues
|
2022-07-28 20:32:57 +00:00
|
|
|
upload_logs "/etc/nsswitch.conf", failok => 1;
|
2018-08-31 20:34:12 +00:00
|
|
|
|
2019-01-29 14:56:01 +00:00
|
|
|
if (get_var("FLAVOR") eq "updates-everything-boot-iso") {
|
|
|
|
# for installer creation test
|
|
|
|
script_run "df -h";
|
2022-07-28 20:32:57 +00:00
|
|
|
upload_logs "/root/imgbuild/pylorax.log", failok => 1;
|
|
|
|
upload_logs "/root/imgbuild/lorax.log", failok => 1;
|
|
|
|
upload_logs "/root/imgbuild/program.log", failok => 1;
|
2019-01-29 14:56:01 +00:00
|
|
|
}
|
|
|
|
|
2019-04-13 01:54:36 +00:00
|
|
|
if (get_var("TEST") eq "live_build") {
|
2019-01-29 14:56:01 +00:00
|
|
|
# for live image creation test
|
|
|
|
script_run "df -h";
|
|
|
|
script_run 'mock -r openqa --chroot "ls -l /chroot_tmpdir/lmc-logs/anaconda"';
|
|
|
|
unless (script_run "mock -r openqa --copyout /chroot_tmpdir/lmc-logs/livemedia-out.log .") {
|
|
|
|
upload_logs "livemedia-out.log";
|
|
|
|
}
|
|
|
|
unless (script_run "mock -r openqa --copyout /chroot_tmpdir/lmc-logs/anaconda/ anaconda") {
|
|
|
|
assert_script_run "tar cvzf anaconda.tar.gz anaconda/";
|
|
|
|
upload_logs "anaconda.tar.gz";
|
|
|
|
}
|
|
|
|
}
|
2015-05-13 11:00:46 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 20:32:57 +00:00
|
|
|
# For update tests, let's do the update package info log stuff,
|
|
|
|
# it may be useful for diagnosing the cause of the failure
|
|
|
|
advisory_get_installed_packages;
|
|
|
|
advisory_check_nonmatching_packages(fatal => 0);
|
2018-12-13 02:09:38 +00:00
|
|
|
|
2015-05-13 11:00:46 +00:00
|
|
|
1;
|
|
|
|
|
|
|
|
# vim: set sw=4 et:
|