Skip to content

Commit

Permalink
squash: more logging and do overwrite results after reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Mar 4, 2024
1 parent 9c2c03e commit 3048fc8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions tmt/checks/avc.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ def after_test(
name='avc',
result=ResultOutcome.SKIP)]

if invocation.hard_reboot_requested:
return [CheckResult(name='dmesg', result=ResultOutcome.SKIP)]

assert invocation.phase.step.workdir is not None # narrow type

outcome, path = create_final_report(invocation, logger)
Expand Down
3 changes: 3 additions & 0 deletions tmt/checks/dmesg.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def after_test(
if not invocation.guest.facts.has_capability(GuestCapability.SYSLOG_ACTION_READ_ALL):
return [CheckResult(name='dmesg', result=ResultOutcome.SKIP)]

if invocation.hard_reboot_requested:
return [CheckResult(name='dmesg', result=ResultOutcome.SKIP)]

outcome, path = cls._save_dmesg(invocation, CheckEvent.AFTER_TEST, logger)

return [CheckResult(name='dmesg', result=outcome, log=[path])]
15 changes: 14 additions & 1 deletion tmt/checks/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ def before_test(
watchdog_logger.labels.append('watchdog')

# Create a guest context for the guest we've been given
guest_context = invocation.check_data[check.how] = GuestContext()
invocation.check_data[check.how] = GuestContext()

guest_context: GuestContext = invocation.check_data[check.how]

if check.ping and not isinstance(invocation.guest, PINGABLE_GUEST_CLASSES):
watchdog_logger.warn('Ping against this guest is not supported, disabling.')
Expand All @@ -410,6 +412,10 @@ def before_test(
def watchdog(guest_context: GuestContext) -> None:
""" Watchdog thread code """

tid = threading.get_ident()

watchdog_logger.debug(f'Watchdog starts in thread {tid}')

while guest_context.keep_running:
if check.ping:
check.do_ping(invocation, guest_context, watchdog_logger)
Expand All @@ -419,6 +425,8 @@ def watchdog(guest_context: GuestContext) -> None:

time.sleep(check.interval)

watchdog_logger.debug(f'Watchdog finished in thread {tid}')

guest_context.thread = threading.Thread(
target=watchdog,
args=(guest_context,),
Expand All @@ -438,9 +446,14 @@ def after_test(
environment: Optional[tmt.utils.Environment] = None,
logger: tmt.log.Logger) -> list[CheckResult]:

watchdog_logger = logger.clone()
watchdog_logger.labels.append('watchdog')

guest_context: GuestContext = invocation.check_data[check.how]

if guest_context.thread:
watchdog_logger.debug(f'Terminating watchdog in thread {guest_context.thread.ident}')

guest_context.keep_running = False
guest_context.thread.join()

Expand Down
14 changes: 7 additions & 7 deletions tmt/steps/execute/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _save_process(

# TODO: do we want timestamps? Yes, we do, leaving that for refactoring later,
# to use some reusable decorator.
invocation.check_results += self.run_checks_before_test(
invocation.check_results = self.run_checks_before_test(
invocation=invocation,
environment=environment,
logger=logger
Expand Down Expand Up @@ -433,13 +433,13 @@ def _save_process(
# results after a successful reboot in the middle of a test.
invocation.results = self.extract_results(invocation, logger)

if not invocation.hard_reboot_requested:
invocation.check_results += self.run_checks_after_test(
invocation=invocation,
environment=environment,
logger=logger
)
invocation.check_results += self.run_checks_after_test(
invocation=invocation,
environment=environment,
logger=logger
)

if not invocation.hard_reboot_requested:
# Fetch #2: after-test checks might have produced remote files as well,
# we need to fetch them too.
guest.pull(
Expand Down

0 comments on commit 3048fc8

Please sign in to comment.