Skip to content

Commit

Permalink
Fix a few failures in post_fail_hook which make guests failed to be r…
Browse files Browse the repository at this point in the history
…estored
  • Loading branch information
Julie-CAO authored and alice-suse committed May 31, 2023
1 parent eca3ca5 commit 48d5a75
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/virt_autotest/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ sub remove_additional_nic {

sub collect_virt_system_logs {
if (script_run("test -f /var/log/libvirt/*d.log") == 0) {
upload_logs("/var/log/libvirt/*d.log");
script_run('tar czvf /tmp/libvirt_daemons.tar.gz /var/log/libvirt/*d.log');
upload_asset("/tmp/libvirt_daemons.tar.gz");
}
else {
record_info "File /var/log/libvirt/*d.log does not exist.";
Expand Down Expand Up @@ -930,6 +931,8 @@ sub restore_original_guests {
record_info("Fail to restore guest!", "$guest", result => 'softfail');
}
}
script_run("virsh list --all");
save_screenshot;
}

sub upload_virt_logs {
Expand Down
9 changes: 6 additions & 3 deletions lib/virt_feature_test_base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ sub analyzeResult {
#the correctness and effectivenees of entire JUnit log
if ($status eq 'FAILED' && $self->{"fail_nums"} eq '0') {
$self->{"fail_nums"} = '1';
my $uncheckpoint_failure = script_output("cat /root/commands_history | tail -3 | head -1");
my $uncheckpoint_failure = "";
$uncheckpoint_failure = script_output("cat /root/commands_history | tail -3 | head -1", 60, proceed_on_failure => 1);
$uncheckpoint_failure = "echo 'NOT found the failure from commands history'" if $uncheckpoint_failure eq '';
my @involved_failure_guest = grep { $uncheckpoint_failure =~ /$_/img } (keys %virt_autotest::common::guests);
my $uncheckpoint_failure_guest = "";
if (!scalar @involved_failure_guest) {
Expand Down Expand Up @@ -179,7 +181,8 @@ sub post_fail_hook {
virt_utils::stop_monitor_guest_console() if (!(get_var("TEST", '') =~ /qam/) && (is_xen_host() || is_kvm_host()));
#(caller(0))[3] can help pass calling subroutine name into called subroutine
$self->junit_log_provision((caller(0))[3]) if get_var("VIRT_AUTOTEST");
collect_virt_system_logs();
# virt logs are included in next step "virt_utils::collect_host_and_guest_logs"
collect_virt_system_logs() unless get_var("VIRT_AUTOTEST");

virt_utils::collect_host_and_guest_logs;
upload_logs("/var/log/clean_up_virt_logs.log");
Expand All @@ -191,7 +194,7 @@ sub post_fail_hook {
$self->upload_coredumps;
save_screenshot;
alp_workloads::kvm_workload_utils::collect_kvm_container_setup_logs if (version_utils::is_alp);
alp_workloads::kvm_workload_utils::enter_kvm_container_sh;
alp_workloads::kvm_workload_utils::enter_kvm_container_sh if is_alp;
}

sub get_virt_disk_and_available_space {
Expand Down
2 changes: 1 addition & 1 deletion tests/virt_autotest/sriov_network_card_pci_passthrough.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sub run_test {
#reboot the guest
record_info("VM reboot", "$guest");
script_run "ssh root\@$guest 'reboot'"; #don't use assert_script_run, or may fail on xen guests
wait_guest_online($guest);
wait_guest_online($guest, 30);
save_network_device_status_logs($log_dir, $guest, $passthru_vf_count + 3 . '-after_guest_reboot');

#check host and guest to make sure they work well
Expand Down

0 comments on commit 48d5a75

Please sign in to comment.