Commit 041b2b2d authored by Robert Schmidt's avatar Robert Schmidt

Remove prematureExit/exitStatus, and implement in task main loop

Use the previous commit on returning success from each task execution
function, and implement handling of errors in the main loop. Add a
script with which this is visible using Custom_Commands.
parent 7b895488
...@@ -84,7 +84,6 @@ def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTarge ...@@ -84,7 +84,6 @@ def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTarge
if sshSession.getBefore().count(f'HEAD is now at {ranCommitID[:6]}') != 1: if sshSession.getBefore().count(f'HEAD is now at {ranCommitID[:6]}') != 1:
sshSession.command('git log --oneline | head -n5', '\$', 5) sshSession.command('git log --oneline | head -n5', '\$', 5)
logging.error(f'problems during checkout, is at: {sshSession.getBefore()}') logging.error(f'problems during checkout, is at: {sshSession.getBefore()}')
self.exitStatus = 1
return False return False
else: else:
logging.debug('successful checkout') logging.debug('successful checkout')
...@@ -319,7 +318,6 @@ class Containerize(): ...@@ -319,7 +318,6 @@ class Containerize():
self.yamlPath = ['', '', ''] self.yamlPath = ['', '', '']
self.services = ['', '', ''] self.services = ['', '', '']
self.nb_healthy = [0, 0, 0] self.nb_healthy = [0, 0, 0]
self.exitStatus = 0
self.eNB_logFile = ['', '', ''] self.eNB_logFile = ['', '', '']
self.testCase_id = '' self.testCase_id = ''
...@@ -991,7 +989,6 @@ class Containerize(): ...@@ -991,7 +989,6 @@ class Containerize():
deployStatus,allServices = DeployServices(mySSH,self.services[self.eNB_instance]) deployStatus,allServices = DeployServices(mySSH,self.services[self.eNB_instance])
if deployStatus != 0: if deployStatus != 0:
mySSH.close() mySSH.close()
self.exitStatus = 1
logging.error('Could not deploy') logging.error('Could not deploy')
HTML.CreateHtmlTestRow('Could not deploy', 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('Could not deploy', 'KO', CONST.ALL_PROCESSES_OK)
return False return False
...@@ -1014,7 +1011,6 @@ class Containerize(): ...@@ -1014,7 +1011,6 @@ class Containerize():
imagesInfo += ("Healthy deployment!") imagesInfo += ("Healthy deployment!")
HTML.CreateHtmlTestRowQueue('N/A', 'OK', [(imagesInfo)]) HTML.CreateHtmlTestRowQueue('N/A', 'OK', [(imagesInfo)])
else: else:
self.exitStatus = 1
imagesInfo += ("Unhealthy deployment! -- Check logs for reason!") imagesInfo += ("Unhealthy deployment! -- Check logs for reason!")
HTML.CreateHtmlTestRowQueue('N/A', 'KO', [(imagesInfo)]) HTML.CreateHtmlTestRowQueue('N/A', 'KO', [(imagesInfo)])
return status return status
...@@ -1035,14 +1031,16 @@ class Containerize(): ...@@ -1035,14 +1031,16 @@ class Containerize():
if not copyin_res: if not copyin_res:
HTML.htmleNBFailureMsg='Could not copy logfile(s) to analyze it!' HTML.htmleNBFailureMsg='Could not copy logfile(s) to analyze it!'
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE)
self.exitStatus = 1
return False return False
else: else:
log_results = [CheckLogs(self, mySSH, self.yamlPath[0].split('/'), service_name, HTML, RAN) for service_name, _ in services] log_results = [CheckLogs(self, mySSH, self.yamlPath[0].split('/'), service_name, HTML, RAN) for service_name, _ in services]
self.exitStatus = 1 if any(log_results) else 0 success = any(log_results)
logging.info('\u001B[1m Undeploying OAI Object Pass\u001B[0m') if self.exitStatus == 0 else logging.error('\u001B[1m Undeploying OAI Object Failed\u001B[0m')
mySSH.close() mySSH.close()
return self.exitStatus == 0 if success:
logging.info('\u001B[1m Undeploying OAI Object Pass\u001B[0m')
else:
logging.error('\u001B[1m Undeploying OAI Object Failed\u001B[0m')
return success
def CheckAndAddRoute(self, svrName, ipAddr, userName, password): def CheckAndAddRoute(self, svrName, ipAddr, userName, password):
logging.debug('Checking IP routing on ' + svrName) logging.debug('Checking IP routing on ' + svrName)
......
...@@ -446,6 +446,8 @@ class HTMLManagement(): ...@@ -446,6 +446,8 @@ class HTMLManagement():
self.htmlFile.write(f' <td bgcolor = "lightgreen" >{status}</td>\n') self.htmlFile.write(f' <td bgcolor = "lightgreen" >{status}</td>\n')
elif (str(status) == 'KO'): elif (str(status) == 'KO'):
self.htmlFile.write(f' <td bgcolor = "lightcoral" >{status}</td>\n') self.htmlFile.write(f' <td bgcolor = "lightcoral" >{status}</td>\n')
elif str(status) == 'SKIP':
self.htmlFile.write(f' <td bgcolor = "lightgray" >{status}</td>\n')
else: else:
addOrangeBK = True addOrangeBK = True
self.htmlFile.write(f' <td bgcolor = "orange" >{status}</td>\n') self.htmlFile.write(f' <td bgcolor = "orange" >{status}</td>\n')
......
...@@ -900,7 +900,6 @@ class OaiCiTest(): ...@@ -900,7 +900,6 @@ class OaiCiTest():
CONTAINERS.UndeployObject(HTML,RAN) CONTAINERS.UndeployObject(HTML,RAN)
else: else:
CONTAINERS.UndeployGenObject(HTML,RAN, self) CONTAINERS.UndeployGenObject(HTML,RAN, self)
RAN.prematureExit=True
#this function is called only if eNB/gNB fails to start #this function is called only if eNB/gNB fails to start
#RH to be re-factored #RH to be re-factored
...@@ -930,7 +929,6 @@ class OaiCiTest(): ...@@ -930,7 +929,6 @@ class OaiCiTest():
CONTAINERS.UndeployObject(HTML,RAN) CONTAINERS.UndeployObject(HTML,RAN)
else: else:
CONTAINERS.UndeployGenObject(HTML,RAN,self) CONTAINERS.UndeployGenObject(HTML,RAN,self)
RAN.prematureExit=True
def LogCollectBuild(self,RAN): def LogCollectBuild(self,RAN):
# Some pipelines are using "none" IP / Credentials # Some pipelines are using "none" IP / Credentials
......
...@@ -52,7 +52,6 @@ class PhySim: ...@@ -52,7 +52,6 @@ class PhySim:
self.ranCommitID= "" self.ranCommitID= ""
self.ranAllowMerge= "" self.ranAllowMerge= ""
self.ranTargetBranch= "" self.ranTargetBranch= ""
self.exitStatus=0
self.forced_workspace_cleanup=False self.forced_workspace_cleanup=False
#private attributes #private attributes
self.__workSpacePath='' self.__workSpacePath=''
...@@ -111,7 +110,6 @@ class PhySim: ...@@ -111,7 +110,6 @@ class PhySim:
if res_enc is None and res_dec is None: if res_enc is None and res_dec is None:
logging.error(f'no statistics: res_enc {res_enc} res_dec {res_dec}') logging.error(f'no statistics: res_enc {res_enc} res_dec {res_dec}')
HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', ['no statistics']) HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', ['no statistics'])
self.exitStatus = 1
os.system(f'mv {self.__runLogFile} {self.__runLogPath}/.') os.system(f'mv {self.__runLogFile} {self.__runLogPath}/.')
return False return False
...@@ -124,7 +122,6 @@ class PhySim: ...@@ -124,7 +122,6 @@ class PhySim:
error_msg = f'Processing time exceeds a limit of {thrs_KO} us' error_msg = f'Processing time exceeds a limit of {thrs_KO} us'
logging.error(error_msg) logging.error(error_msg)
HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', [info + '\n' + error_msg]) HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', [info + '\n' + error_msg])
self.exitStatus = 1
return success return success
def __CheckResults_NRulsimTest(self, HTML, CONST, testcase_id): def __CheckResults_NRulsimTest(self, HTML, CONST, testcase_id):
...@@ -136,7 +133,6 @@ class PhySim: ...@@ -136,7 +133,6 @@ class PhySim:
error_msg = f'could not recover test result file {filename}' error_msg = f'could not recover test result file {filename}'
logging.error(error_msg) logging.error(error_msg)
HTML.CreateHtmlTestRowQueue("could not recover results", 'KO', [error_msg]) HTML.CreateHtmlTestRowQueue("could not recover results", 'KO', [error_msg])
self.exitStatus = 1
return False return False
PUSCH_OK = False PUSCH_OK = False
...@@ -153,7 +149,6 @@ class PhySim: ...@@ -153,7 +149,6 @@ class PhySim:
error_msg = 'error: no "PUSCH test OK"' error_msg = 'error: no "PUSCH test OK"'
logging.error(error_msg) logging.error(error_msg)
HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', 1, [error_msg]) HTML.CreateHtmlTestRowQueue(self.runargs, 'KO', 1, [error_msg])
self.exitStatus = 1
return PUSCH_OK return PUSCH_OK
def __CheckBuild_PhySim(self, HTML, CONST): def __CheckBuild_PhySim(self, HTML, CONST):
...@@ -169,13 +164,10 @@ class PhySim: ...@@ -169,13 +164,10 @@ class PhySim:
with open(self.__buildLogFile) as f: with open(self.__buildLogFile) as f:
if 'BUILD SHOULD BE SUCCESSFUL' in f.read(): if 'BUILD SHOULD BE SUCCESSFUL' in f.read():
HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'PhySim') HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'PhySim')
self.exitStatus=0
return True return True
logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m') logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m')
HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC') HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC')
HTML.CreateHtmlTabFooter(False) HTML.CreateHtmlTabFooter(False)
#exitStatus=1 will do a sys.exit in main
self.exitStatus = 1
return False return False
......
...@@ -65,7 +65,7 @@ class PhySim: ...@@ -65,7 +65,7 @@ class PhySim:
#PUBLIC Methods$ #PUBLIC Methods$
#-----------------$ #-----------------$
def Deploy_PhySim(self, HTML, RAN): def Deploy_PhySim(self, HTML):
if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
...@@ -123,7 +123,6 @@ class PhySim: ...@@ -123,7 +123,6 @@ class PhySim:
logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m') logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m')
mySSH.close() mySSH.close()
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
RAN.prematureExit = True
return False return False
else: else:
logging.debug('\u001B[1m Login to OC Cluster Successfully\u001B[0m') logging.debug('\u001B[1m Login to OC Cluster Successfully\u001B[0m')
...@@ -133,7 +132,6 @@ class PhySim: ...@@ -133,7 +132,6 @@ class PhySim:
mySSH.command('oc logout', '\$', 30) mySSH.command('oc logout', '\$', 30)
mySSH.close() mySSH.close()
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PROJECT_FAIL) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PROJECT_FAIL)
RAN.prematureExit = True
return False return False
else: else:
logging.debug(f'\u001B[1m Now using project {ocProjectName}\u001B[0m') logging.debug(f'\u001B[1m Now using project {ocProjectName}\u001B[0m')
...@@ -154,7 +152,6 @@ class PhySim: ...@@ -154,7 +152,6 @@ class PhySim:
mySSH.command('oc logout', '\$', 30) mySSH.command('oc logout', '\$', 30)
mySSH.close() mySSH.close()
self.AnalyzeLogFile_phySim() self.AnalyzeLogFile_phySim()
RAN.prematureExit = True
return False return False
else: else:
logging.debug('\u001B[1m Deployed PhySim Successfully using helm chart\u001B[0m') logging.debug('\u001B[1m Deployed PhySim Successfully using helm chart\u001B[0m')
...@@ -186,7 +183,6 @@ class PhySim: ...@@ -186,7 +183,6 @@ class PhySim:
mySSH.command('oc logout', '\$', 30) mySSH.command('oc logout', '\$', 30)
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PHYSIM_DEPLOY_FAIL) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PHYSIM_DEPLOY_FAIL)
HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult)
RAN.prematureExit = True
return False return False
# Waiting to complete the running test # Waiting to complete the running test
count = 0 count = 0
...@@ -248,7 +244,6 @@ class PhySim: ...@@ -248,7 +244,6 @@ class PhySim:
HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult)
logging.info('\u001B[1m Physical Simulator Pass\u001B[0m') logging.info('\u001B[1m Physical Simulator Pass\u001B[0m')
else: else:
RAN.prematureExit = True
if isFinished: if isFinished:
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK)
else: else:
......
This diff is collapsed.
...@@ -55,7 +55,6 @@ class RANManagement(): ...@@ -55,7 +55,6 @@ class RANManagement():
def __init__(self): def __init__(self):
self.prematureExit = False
self.ranRepository = '' self.ranRepository = ''
self.ranBranch = '' self.ranBranch = ''
self.ranAllowMerge = False self.ranAllowMerge = False
...@@ -1269,7 +1268,6 @@ class RANManagement(): ...@@ -1269,7 +1268,6 @@ class RANManagement():
rruMsg = 'Slave RRU DID NOT receive the RRU_frame_resynch command from RAU' rruMsg = 'Slave RRU DID NOT receive the RRU_frame_resynch command from RAU'
logging.debug('\u001B[1;37;41m ' + rruMsg + ' \u001B[0m') logging.debug('\u001B[1;37;41m ' + rruMsg + ' \u001B[0m')
htmleNBFailureMsg += rruMsg + '\n' htmleNBFailureMsg += rruMsg + '\n'
self.prematureExit = True
global_status = CONST.ENB_PROCESS_SLAVE_RRU_NOT_SYNCED global_status = CONST.ENB_PROCESS_SLAVE_RRU_NOT_SYNCED
if foundSegFault: if foundSegFault:
logging.debug('\u001B[1;37;41m ' + nodeB_prefix + 'NB ended with a Segmentation Fault! \u001B[0m') logging.debug('\u001B[1;37;41m ' + nodeB_prefix + 'NB ended with a Segmentation Fault! \u001B[0m')
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
<htmlTabIcon>wrench</htmlTabIcon> <htmlTabIcon>wrench</htmlTabIcon>
<TestCaseRequestedList> <TestCaseRequestedList>
000001 000001
000002
000003
000004
</TestCaseRequestedList> </TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList> <TestCaseExclusionList></TestCaseExclusionList>
...@@ -37,4 +40,29 @@ ...@@ -37,4 +40,29 @@
<command>true</command> <command>true</command>
<command_fail>yes</command_fail> <command_fail>yes</command_fail>
</testCase> </testCase>
<testCase id="000002">
<class>Custom_Command</class>
<desc>This should fail</desc>
<node>localhost</node>
<command>false</command>
<command_fail>yes</command_fail>
</testCase>
<testCase id="000003">
<class>Custom_Command</class>
<desc>This should be skipped</desc>
<node>localhost</node>
<command>true</command>
<command_fail>yes</command_fail>
</testCase>
<testCase id="000004">
<class>Custom_Command</class>
<desc>This should be executed because marked so</desc>
<always_exec>true</always_exec>
<node>localhost</node>
<command>true</command>
<command_fail>yes</command_fail>
</testCase>
</testCaseList> </testCaseList>
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