Commit 9d92f4f9 authored by Robert Schmidt's avatar Robert Schmidt

CI: catch exceptions in CI code and print in HTML

parent 31d04336
...@@ -65,6 +65,7 @@ import logging ...@@ -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,150 +746,157 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -745,150 +746,157 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
continue continue
CiTestObj.ShowTestID() CiTestObj.ShowTestID()
GetParametersFromXML(action) GetParametersFromXML(action)
if action == 'Build_eNB': try:
RAN.BuildeNB(HTML) if action == 'Build_eNB':
elif action == 'WaitEndBuild_eNB': RAN.BuildeNB(HTML)
RAN.WaitBuildeNBisFinished(HTML) elif action == 'WaitEndBuild_eNB':
elif action == 'Custom_Command': RAN.WaitBuildeNBisFinished(HTML)
RAN.CustomCommand(HTML) elif action == 'Custom_Command':
if RAN.prematureExit: RAN.CustomCommand(HTML)
CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS) if RAN.prematureExit:
elif action == 'Initialize_eNB': CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
RAN.InitializeeNB(HTML, EPC) elif action == 'Initialize_eNB':
if RAN.prematureExit: RAN.InitializeeNB(HTML, EPC)
CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS) if RAN.prematureExit:
elif action == 'Terminate_eNB': CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
RAN.TerminateeNB(HTML, EPC) elif action == 'Terminate_eNB':
elif action == 'Initialize_UE': RAN.TerminateeNB(HTML, EPC)
CiTestObj.InitializeUE(HTML) elif action == 'Initialize_UE':
elif action == 'Terminate_UE': CiTestObj.InitializeUE(HTML)
CiTestObj.TerminateUE(HTML) elif action == 'Terminate_UE':
elif action == 'Attach_UE': CiTestObj.TerminateUE(HTML)
CiTestObj.AttachUE(HTML, RAN, EPC, CONTAINERS) elif action == 'Attach_UE':
elif action == 'Detach_UE': CiTestObj.AttachUE(HTML, RAN, EPC, CONTAINERS)
CiTestObj.DetachUE(HTML) elif action == 'Detach_UE':
elif action == 'DataDisable_UE': CiTestObj.DetachUE(HTML)
CiTestObj.DataDisableUE(HTML) elif action == 'DataDisable_UE':
elif action == 'DataEnable_UE': CiTestObj.DataDisableUE(HTML)
CiTestObj.DataEnableUE(HTML) elif action == 'DataEnable_UE':
elif action == 'CheckStatusUE': CiTestObj.DataEnableUE(HTML)
CiTestObj.CheckStatusUE(HTML) elif action == 'CheckStatusUE':
elif action == 'Build_OAI_UE': CiTestObj.CheckStatusUE(HTML)
CiTestObj.BuildOAIUE(HTML) elif action == 'Build_OAI_UE':
elif action == 'Initialize_OAI_UE': CiTestObj.BuildOAIUE(HTML)
CiTestObj.InitializeOAIUE(HTML,RAN,EPC,CONTAINERS) elif action == 'Initialize_OAI_UE':
elif action == 'Terminate_OAI_UE': CiTestObj.InitializeOAIUE(HTML,RAN,EPC,CONTAINERS)
CiTestObj.TerminateOAIUE(HTML,RAN,EPC,CONTAINERS) elif action == 'Terminate_OAI_UE':
elif action == 'Ping': CiTestObj.TerminateOAIUE(HTML,RAN,EPC,CONTAINERS)
CiTestObj.Ping(HTML,RAN,EPC,CONTAINERS) elif action == 'Ping':
elif action == 'Iperf': CiTestObj.Ping(HTML,RAN,EPC,CONTAINERS)
CiTestObj.Iperf(HTML,RAN,EPC,CONTAINERS) elif action == 'Iperf':
elif action == 'Initialize_HSS': CiTestObj.Iperf(HTML,RAN,EPC,CONTAINERS)
EPC.InitializeHSS(HTML) elif action == 'Initialize_HSS':
elif action == 'Terminate_HSS': EPC.InitializeHSS(HTML)
EPC.TerminateHSS(HTML) elif action == 'Terminate_HSS':
elif action == 'Initialize_MME': EPC.TerminateHSS(HTML)
EPC.InitializeMME(HTML) elif action == 'Initialize_MME':
elif action == 'Terminate_MME': EPC.InitializeMME(HTML)
EPC.TerminateMME(HTML) elif action == 'Terminate_MME':
elif action == 'Initialize_SPGW': EPC.TerminateMME(HTML)
EPC.InitializeSPGW(HTML) elif action == 'Initialize_SPGW':
elif action == 'Terminate_SPGW': EPC.InitializeSPGW(HTML)
EPC.TerminateSPGW(HTML) elif action == 'Terminate_SPGW':
elif action == 'Initialize_5GCN': EPC.TerminateSPGW(HTML)
EPC.Initialize5GCN(HTML) elif action == 'Initialize_5GCN':
elif action == 'Terminate_5GCN': EPC.Initialize5GCN(HTML)
EPC.Terminate5GCN(HTML) elif action == 'Terminate_5GCN':
elif action == 'Deploy_EPC': EPC.Terminate5GCN(HTML)
EPC.DeployEpc(HTML) elif action == 'Deploy_EPC':
elif action == 'Undeploy_EPC': EPC.DeployEpc(HTML)
EPC.UndeployEpc(HTML) elif action == 'Undeploy_EPC':
elif action == 'IdleSleep': EPC.UndeployEpc(HTML)
CiTestObj.IdleSleep(HTML) elif action == 'IdleSleep':
elif action == 'Perform_X2_Handover': CiTestObj.IdleSleep(HTML)
CiTestObj.Perform_X2_Handover(HTML,RAN,EPC) elif action == 'Perform_X2_Handover':
elif action == 'Build_PhySim': CiTestObj.Perform_X2_Handover(HTML,RAN,EPC)
HTML=ldpc.Build_PhySim(HTML,CONST) elif action == 'Build_PhySim':
if ldpc.exitStatus==1: HTML=ldpc.Build_PhySim(HTML,CONST)
RAN.prematureExit = True if ldpc.exitStatus==1:
elif action == 'Run_LDPCTest': RAN.prematureExit = True
HTML=ldpc.Run_LDPCTest(HTML,CONST,id) elif action == 'Run_LDPCTest':
if ldpc.exitStatus==1: HTML=ldpc.Run_LDPCTest(HTML,CONST,id)
RAN.prematureExit = True if ldpc.exitStatus==1:
elif action == 'Run_LDPCt1Test': RAN.prematureExit = True
HTML=ldpc.Run_LDPCt1Test(HTML,CONST,id) elif action == 'Run_LDPCt1Test':
if ldpc.exitStatus==1: HTML=ldpc.Run_LDPCt1Test(HTML,CONST,id)
RAN.prematureExit = True if ldpc.exitStatus==1:
elif action == 'Run_NRulsimTest': RAN.prematureExit = True
HTML=ldpc.Run_NRulsimTest(HTML,CONST,id) elif action == 'Run_NRulsimTest':
if ldpc.exitStatus==1: HTML=ldpc.Run_NRulsimTest(HTML,CONST,id)
RAN.prematureExit = True if ldpc.exitStatus==1:
elif action == 'Pull_Cluster_Image': RAN.prematureExit = True
if not CLUSTER.PullClusterImage(HTML,RAN): elif action == 'Pull_Cluster_Image':
RAN.prematureExit = True if not CLUSTER.PullClusterImage(HTML,RAN):
elif action == 'Build_Cluster_Image': RAN.prematureExit = True
if not CLUSTER.BuildClusterImage(HTML): elif action == 'Build_Cluster_Image':
RAN.prematureExit = True if not CLUSTER.BuildClusterImage(HTML):
elif action == 'Build_Image': RAN.prematureExit = True
success = CONTAINERS.BuildImage(HTML) elif action == 'Build_Image':
if not success: success = CONTAINERS.BuildImage(HTML)
RAN.prematureExit = True if not success:
elif action == 'Build_Run_Tests': RAN.prematureExit = True
success = CONTAINERS.BuildRunTests(HTML) elif action == 'Build_Run_Tests':
if not success: success = CONTAINERS.BuildRunTests(HTML)
RAN.prematureExit = True if not success:
elif action == 'Build_Proxy': RAN.prematureExit = True
success = CONTAINERS.BuildProxy(HTML) elif action == 'Build_Proxy':
if not success: success = CONTAINERS.BuildProxy(HTML)
RAN.prematureExit = True if not success:
elif action == 'Push_Local_Registry': RAN.prematureExit = True
success = CONTAINERS.Push_Image_to_Local_Registry(HTML) elif action == 'Push_Local_Registry':
if not success: success = CONTAINERS.Push_Image_to_Local_Registry(HTML)
RAN.prematureExit = True if not success:
elif action == 'Pull_Local_Registry': RAN.prematureExit = True
success = CONTAINERS.Pull_Image_from_Local_Registry(HTML) elif action == 'Pull_Local_Registry':
if not success: success = CONTAINERS.Pull_Image_from_Local_Registry(HTML)
RAN.prematureExit = True if not success:
elif action == 'Clean_Test_Server_Images': RAN.prematureExit = True
success = CONTAINERS.Clean_Test_Server_Images(HTML) elif action == 'Clean_Test_Server_Images':
if not success: success = CONTAINERS.Clean_Test_Server_Images(HTML)
RAN.prematureExit = True if not success:
elif action == 'Deploy_Object': RAN.prematureExit = True
CONTAINERS.DeployObject(HTML, EPC) elif action == 'Deploy_Object':
if CONTAINERS.exitStatus==1: CONTAINERS.DeployObject(HTML, EPC)
CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS) if CONTAINERS.exitStatus==1:
RAN.prematureExit = True CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
elif action == 'Undeploy_Object': RAN.prematureExit = True
CONTAINERS.UndeployObject(HTML, RAN) elif action == 'Undeploy_Object':
if CONTAINERS.exitStatus == 1: CONTAINERS.UndeployObject(HTML, RAN)
CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS) if CONTAINERS.exitStatus == 1:
RAN.prematureExit = True CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
elif action == 'Cppcheck_Analysis': RAN.prematureExit = True
SCA.CppCheckAnalysis(HTML) elif action == 'Cppcheck_Analysis':
elif action == 'LicenceAndFormattingCheck': SCA.CppCheckAnalysis(HTML)
ret = SCA.LicenceAndFormattingCheck(HTML) elif action == 'LicenceAndFormattingCheck':
if ret != 0: ret = SCA.LicenceAndFormattingCheck(HTML)
RAN.prematureExit = True if ret != 0:
elif action == 'Deploy_Run_PhySim': RAN.prematureExit = True
PHYSIM.Deploy_PhySim(HTML, RAN) elif action == 'Deploy_Run_PhySim':
elif action == 'DeployGenObject': PHYSIM.Deploy_PhySim(HTML, RAN)
CONTAINERS.DeployGenObject(HTML, RAN, CiTestObj) elif action == 'DeployGenObject':
if CONTAINERS.exitStatus==1: CONTAINERS.DeployGenObject(HTML, RAN, CiTestObj)
RAN.prematureExit = True if CONTAINERS.exitStatus==1:
elif action == 'UndeployGenObject': RAN.prematureExit = True
CONTAINERS.UndeployGenObject(HTML, RAN, CiTestObj) elif action == 'UndeployGenObject':
if CONTAINERS.exitStatus==1: CONTAINERS.UndeployGenObject(HTML, RAN, CiTestObj)
RAN.prematureExit = True if CONTAINERS.exitStatus==1:
elif action == 'IperfFromContainer': RAN.prematureExit = True
CONTAINERS.IperfFromContainer(HTML, RAN, CiTestObj) elif action == 'IperfFromContainer':
if CONTAINERS.exitStatus==1: CONTAINERS.IperfFromContainer(HTML, RAN, CiTestObj)
RAN.prematureExit = True if CONTAINERS.exitStatus==1:
elif action == 'StatsFromGenObject': RAN.prematureExit = True
CONTAINERS.StatsFromGenObject(HTML) elif action == 'StatsFromGenObject':
elif action == 'Push_Images_To_Test_Servers': CONTAINERS.StatsFromGenObject(HTML)
logging.debug('To be implemented') elif action == 'Push_Images_To_Test_Servers':
else: logging.debug('To be implemented')
sys.exit('Invalid class (action) from xml') else:
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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment