Skip to content

Commit

Permalink
Add ability to flush also plan data before reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
pholica committed May 13, 2024
1 parent 09c3818 commit 73ff913
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tmt/steps/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def handle_restart(self) -> bool:

return True

def handle_reboot(self) -> bool:
def handle_reboot(self, flush_func=None) -> bool:
"""
Reboot the guest if the test requested it.
Expand Down Expand Up @@ -368,7 +368,10 @@ def handle_reboot(self) -> bool:
if flush_artifacts:
# Pull artifacts created in the plan data directory
self.logger.debug("Flush artifacts requested, pull the test data directory.", level=2)
self.guest.pull(source=self.test_data_path)
if flush_func:
flush_func()
else:
self.guest.pull(source=self.test_data_path)

os.remove(self.reboot_request_path)
self.guest.push(self.test_data_path)
Expand Down
5 changes: 4 additions & 1 deletion tmt/steps/execute/internal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dataclasses
import functools
import os
import subprocess
import textwrap
Expand Down Expand Up @@ -548,7 +549,9 @@ def _run_tests(
logger.verbose(
f"{duration} {test.name} [{progress}]", shift=shift)
try:
if invocation.handle_reboot():
if invocation.handle_reboot(
flush_func=functools.partial(guest.pull, source=self.step.plan.data_directory)
):
continue
except tmt.utils.RebootTimeoutError:
for result in invocation.results:
Expand Down

0 comments on commit 73ff913

Please sign in to comment.