@@ -631,20 +631,33 @@ def _save_process(
631
631
# overwrite it.
632
632
self .write (invocation .path / TEST_OUTPUT_FILENAME , stdout or '' , mode = 'a' , level = 3 )
633
633
634
+ def pull_from_guest () -> None :
635
+ if not invocation .is_guest_healthy :
636
+ return
637
+
638
+ try :
639
+ guest .pull (
640
+ source = invocation .path ,
641
+ extend_options = [
642
+ * test .test_framework .get_pull_options (invocation , logger ),
643
+ '--exclude' ,
644
+ str (invocation .path / TEST_OUTPUT_FILENAME ),
645
+ ],
646
+ )
647
+
648
+ # Fetch plan data content as well in order to prevent
649
+ # losing logs if the guest becomes later unresponsive.
650
+ guest .pull (source = self .step .plan .data_directory )
651
+
652
+ # Handle failing to pull test artifacts after guest becoming
653
+ # unresponsive. If not handled test would stay in 'pending' state.
654
+ # See issue https://github.com/teemtee/tmt/issues/3647.
655
+ except tmt .utils .RunError :
656
+ pass
657
+
634
658
# Fetch #1: we need logs and everything the test produced so we could
635
659
# collect its results.
636
- if invocation .is_guest_healthy :
637
- guest .pull (
638
- source = invocation .path ,
639
- extend_options = [
640
- * test .test_framework .get_pull_options (invocation , logger ),
641
- '--exclude' ,
642
- str (invocation .path / TEST_OUTPUT_FILENAME ),
643
- ],
644
- )
645
- # Fetch plan data content as well in order to prevent
646
- # losing logs if the guest becomes later unresponsive.
647
- guest .pull (source = self .step .plan .data_directory )
660
+ pull_from_guest ()
648
661
649
662
# Run after-test checks before extracting results
650
663
invocation .check_results += self .run_checks_after_test (
@@ -656,20 +669,9 @@ def _save_process(
656
669
# results after a successful reboot in the middle of a test.
657
670
invocation .results = self .extract_results (invocation , logger )
658
671
659
- if invocation .is_guest_healthy :
660
- # Fetch #2: after-test checks might have produced remote files as well,
661
- # we need to fetch them too.
662
- guest .pull (
663
- source = invocation .path ,
664
- extend_options = [
665
- * test .test_framework .get_pull_options (invocation , logger ),
666
- '--exclude' ,
667
- str (invocation .path / TEST_OUTPUT_FILENAME ),
668
- ],
669
- )
670
- # Fetch plan data content as well in order to prevent
671
- # losing logs if the guest becomes later unresponsive.
672
- guest .pull (source = self .step .plan .data_directory )
672
+ # Fetch #2: after-test checks might have produced remote files as well,
673
+ # we need to fetch them too.
674
+ pull_from_guest ()
673
675
674
676
# Attach check results to every test result. There might be more than one,
675
677
# and it's hard to pick the main one, who knows what custom results might
0 commit comments