CI: catch exceptions in CI code and print in HTML

This commit is contained in:
Robert Schmidt
2024-01-29 12:51:20 +01:00
parent 31d043363a
commit 9d92f4f91c
+8
View File
@@ -65,6 +65,7 @@ import logging
import datetime import datetime
import signal import signal
import subprocess import subprocess
import traceback
from multiprocessing import Process, Lock, SimpleQueue from multiprocessing import Process, Lock, SimpleQueue
logging.basicConfig( logging.basicConfig(
level=logging.DEBUG, level=logging.DEBUG,
@@ -745,6 +746,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
continue continue
CiTestObj.ShowTestID() CiTestObj.ShowTestID()
GetParametersFromXML(action) GetParametersFromXML(action)
try:
if action == 'Build_eNB': if action == 'Build_eNB':
RAN.BuildeNB(HTML) RAN.BuildeNB(HTML)
elif action == 'WaitEndBuild_eNB': elif action == 'WaitEndBuild_eNB':
@@ -889,6 +891,12 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
logging.debug('To be implemented') logging.debug('To be implemented')
else: else:
sys.exit('Invalid class (action) from xml') sys.exit('Invalid class (action) from xml')
except Exception as e:
s = traceback.format_exc()
logging.error(f'while running CI, an exception occurred:\n{s}')
HTML.CreateHtmlTestRowQueue("N/A", 'KO', [f"CI test code encountered an exception:\n{s}"])
RAN.prematureExit = True
if RAN.prematureExit: if RAN.prematureExit:
if CiTestObj.testCase_id == CiTestObj.testMinStableId: if CiTestObj.testCase_id == CiTestObj.testMinStableId:
logging.warning('Scenario has reached minimal stability point') logging.warning('Scenario has reached minimal stability point')