From 0f5281f3898d26981a8feb11d62616b92d5a4fcc Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 12 Dec 2018 11:40:58 -0800 Subject: [PATCH] In post_fail_hooks, try using serial line if no network Sometimes we get a test failing because the SUT isn't connecting to the network for some reason. In this case we never get any logs, because `upload_logs` relies on being able to reacht at least the worker host system via the network. This attempts to detect when we can't ping the worker host, and in that case, send some info out over the serial line instead. Signed-off-by: Adam Williamson --- lib/anacondatest.pm | 25 +++++++++++++++++++++++++ lib/installedtest.pm | 16 +++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/anacondatest.pm b/lib/anacondatest.pm index feb46331..1e2b2ae6 100644 --- a/lib/anacondatest.pm +++ b/lib/anacondatest.pm @@ -25,6 +25,31 @@ sub post_fail_hook { save_screenshot; $self->root_console(); + # 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 + my $hostip = $testapi::host_ip(); + if (script_run "ping -c 2 ${hostip}") { + script_run 'printf "\n** X.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/X.log > /dev/ttyS0"; + script_run 'printf "\n** ANACONDA.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/anaconda.log > /dev/ttyS0"; + script_run 'printf "\n** PACKAGING.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/packaging.log > /dev/ttyS0"; + script_run 'printf "\n** STORAGE.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/storage.log > /dev/ttyS0"; + script_run 'printf "\n** SYSLOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/syslog > /dev/ttyS0"; + script_run 'printf "\n** PROGRAM.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/program.log > /dev/ttyS0"; + script_run 'printf "\n** DNF.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/dnf.log > /dev/ttyS0"; + script_run 'printf "\n** DNF.LIBREPO.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/dnf.librepo.log > /dev/ttyS0"; + script_run 'printf "\n** DNF.RPM.LOG **\n" > /dev/ttyS0'; + script_run "cat /tmp/dnf.rpm.log > /dev/ttyS0"; + return; + } + upload_logs "/tmp/X.log", failok=>1; upload_logs "/tmp/anaconda.log", failok=>1; upload_logs "/tmp/packaging.log", failok=>1; diff --git a/lib/installedtest.pm b/lib/installedtest.pm index 26de22db..c7cf862c 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -37,7 +37,21 @@ sub post_fail_hook { # 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"; + + # 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 + my $hostip = $testapi::host_ip(); + if (script_run "rpm -q tar" || script_run "ping -c 2 ${hostip}") { + script_run 'printf "\n** IP ADDR **\n" > /dev/ttyS0'; + script_run "ip addr > /dev/ttyS0 2>&1"; + script_run 'printf "\n** IP ROUTE **\n" > /dev/ttyS0'; + script_run "ip route > /dev/ttyS0 2>&1"; + script_run 'printf "\n** NETWORKMANAGER.SERVICE STATUS **\n" > /dev/ttyS0'; + script_run "systemctl --no-pager status NetworkManager.service > /dev/ttyS0 2>&1"; + script_run 'printf "\n** JOURNAL **\n" > /dev/ttyS0'; + script_run "journalctl -b --no-pager > /dev/ttyS0"; + return; + } # Note: script_run returns the exit code, so the logic looks weird. # We're testing that the directory exists and contains something.