Enable python-based tests in Linux AR

Signed-off-by: sweeneys <sweeneys@amazon.com>
This commit is contained in:
sweeneys
2021-11-10 15:34:08 -08:00
parent 04326673cb
commit c29ca07d54
4 changed files with 11 additions and 10 deletions
@@ -20,6 +20,7 @@ _PROCESS_OUTPUT_ENCODING = 'utf-8'
# Default list of processes names to kill
LY_PROCESS_KILL_LIST = [
'AssetBuilder', 'AssetProcessor', 'AssetProcessorBatch',
'CrySCompileServer', 'Editor',
'Profiler', 'RemoteConsole',
'rc' # Resource Compiler
@@ -376,18 +377,18 @@ def _safe_kill_processes(processes):
logger.info(f"Terminating process '{proc.name()}' with id '{proc.pid}'")
proc.kill()
except psutil.AccessDenied:
logger.warning("Termination failed, Access Denied", exc_info=True)
logger.warning("Termination failed, Access Denied with stacktrace:", exc_info=True)
except psutil.NoSuchProcess:
logger.debug("Termination request ignored, process was already terminated during iteration", exc_info=True)
logger.debug("Termination request ignored, process was already terminated during iteration with stacktrace:", exc_info=True)
except Exception: # purposefully broad
logger.warning("Unexpected exception ignored while terminating process", exc_info=True)
logger.debug("Unexpected exception ignored while terminating process, with stacktrace:", exc_info=True)
def on_terminate(proc):
logger.info(f"process '{proc.name()}' with id '{proc.pid}' terminated with exit code {proc.returncode}")
try:
psutil.wait_procs(processes, timeout=30, callback=on_terminate)
except Exception: # purposefully broad
logger.warning("Unexpected exception while waiting for processes to terminate", exc_info=True)
logger.debug("Unexpected exception while waiting for processes to terminate, with stacktrace:", exc_info=True)
def _terminate_and_confirm_dead(proc):
@@ -371,15 +371,15 @@ class TestProcessMatching(unittest.TestCase):
mock_log_warn.assert_called()
@mock.patch('psutil.wait_procs')
@mock.patch('logging.Logger.warning')
def test_SafeKillProcList_RaisesError_NoRaiseAndLogsError(self, mock_log_warn, mock_wait_procs):
@mock.patch('logging.Logger.debug')
def test_SafeKillProcList_RaisesError_NoRaiseAndLogsError(self, mock_log, mock_wait_procs):
mock_wait_procs.side_effect = psutil.PermissionError()
proc_mock = mock.MagicMock()
process_utils._safe_kill_processes(proc_mock)
mock_wait_procs.assert_called()
mock_log_warn.assert_called()
mock_log.assert_called()
@mock.patch('psutil.process_iter')
@mock.patch('logging.Logger.debug')