Skip to content

Commit

Permalink
fix(event_analyzer): call 'kill_test' only once
Browse files Browse the repository at this point in the history
We may get flooded with the CRITICAL events and each of them will
trigger call of "kill_test" method where we send SIGUSR2 signal to
python main thread.
At first, we should call this method only once.
At second, we will fall into endless loop of failures where we
catch following old python bug: https://bugs.python.org/issue24283

So, run "kill_test" method only once to avoid endless failure loop.
  • Loading branch information
vponomaryov committed Apr 14, 2023
1 parent e37d416 commit ff47755
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sdcm/sct_events/events_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,18 @@ def run(self) -> None:
except TestFailure:
self.kill_test(sys.exc_info())

def kill_test(self, backtrace_with_reason) -> None:
def kill_test(self, backtrace_with_reason, memo={}) -> None: # pylint: disable=dangerous-default-value
self.terminate()
if tester := TestConfig().tester_obj():
if memo:
# NOTE: in some cases we may get flooded with the CRITICAL events.
# And we should call 'kill_test' only once to avoid following:
# - Long awaiting of the events handler closing in the tearDown stage.
# It won't return until all the events are processed causing job timeout.
# - Catching old python bug: https://bugs.python.org/issue24283
# Also, in general, it makes no sense to kill test more than once.
return
memo["kill_test_has_run"] = True
tester.kill_test(backtrace_with_reason)
else:
LOGGER.error("No test was registered using `TestConfig.set_tester_obj()', do not kill")
Expand Down

0 comments on commit ff47755

Please sign in to comment.