Custom_Command: add option to fail if returncode is non-zero
This commit is contained in:
@@ -429,6 +429,7 @@ def GetParametersFromXML(action):
|
|||||||
elif action == 'Custom_Command':
|
elif action == 'Custom_Command':
|
||||||
RAN.node = test.findtext('node')
|
RAN.node = test.findtext('node')
|
||||||
RAN.command = test.findtext('command')
|
RAN.command = test.findtext('command')
|
||||||
|
RAN.command_fail = test.findtext('command_fail') in ['True', 'true', 'Yes', 'yes']
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.warning(f"unknown action {action} from option-parsing point-of-view")
|
logging.warning(f"unknown action {action} from option-parsing point-of-view")
|
||||||
@@ -752,6 +753,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
|||||||
elif action == 'Custom_Command':
|
elif action == 'Custom_Command':
|
||||||
logging.info(f"Executing custom command")
|
logging.info(f"Executing custom command")
|
||||||
RAN.CustomCommand(HTML)
|
RAN.CustomCommand(HTML)
|
||||||
|
if RAN.prematureExit:
|
||||||
|
CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS)
|
||||||
elif action == 'Initialize_eNB':
|
elif action == 'Initialize_eNB':
|
||||||
RAN.InitializeeNB(HTML, EPC)
|
RAN.InitializeeNB(HTML, EPC)
|
||||||
if RAN.prematureExit:
|
if RAN.prematureExit:
|
||||||
|
|||||||
+13
-9
@@ -99,6 +99,7 @@ class RANManagement():
|
|||||||
self.cmd_prefix = '' # prefix before {lte,nr}-softmodem
|
self.cmd_prefix = '' # prefix before {lte,nr}-softmodem
|
||||||
self.node = ''
|
self.node = ''
|
||||||
self.command = ''
|
self.command = ''
|
||||||
|
self.command_fail = False
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
@@ -259,19 +260,22 @@ class RANManagement():
|
|||||||
self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, self.backgroundBuildTestId[int(self.eNB_instance)], HTML)
|
self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, self.backgroundBuildTestId[int(self.eNB_instance)], HTML)
|
||||||
|
|
||||||
def CustomCommand(self, HTML):
|
def CustomCommand(self, HTML):
|
||||||
if self.node == '' or self.node == "localhost":
|
cmd = cls_cmd.getConnection(self.node)
|
||||||
cmd = cls_cmd.LocalCmd()
|
|
||||||
else:
|
|
||||||
cmd = cls_cmd.RemoteCmd(self.node)
|
|
||||||
ret = cmd.run(self.command)
|
ret = cmd.run(self.command)
|
||||||
cmd.close()
|
cmd.close()
|
||||||
logging.debug(f'CustomCommand: {self.command} returnCode: {ret.returncode} output: {ret.stdout}')
|
logging.debug(f'CustomCommand: {self.command} returnCode: {ret.returncode}')
|
||||||
html_queue = SimpleQueue()
|
|
||||||
status = 'OK'
|
status = 'OK'
|
||||||
if ret.returncode != 0:
|
message = ''
|
||||||
html_queue.put(ret.stdout)
|
if ret.returncode != 0 and not self.command_fail:
|
||||||
|
message = ret.stdout
|
||||||
|
logging.warning(f'CustomCommand output: {message}')
|
||||||
status = 'Warning'
|
status = 'Warning'
|
||||||
HTML.CreateHtmlTestRow(self.command, status, 1, html_queue)
|
if ret.returncode != 0 and self.command_fail:
|
||||||
|
message = ret.stdout
|
||||||
|
logging.error(f'CustomCommand failed: output: {message}')
|
||||||
|
status = 'KO'
|
||||||
|
self.prematureExit = True
|
||||||
|
HTML.CreateHtmlTestRowQueue(self.command, status, [message])
|
||||||
|
|
||||||
def checkBuildeNB(self, lIpAddr, lUserName, lPassWord, lSourcePath, testcaseId, HTML):
|
def checkBuildeNB(self, lIpAddr, lUserName, lPassWord, lSourcePath, testcaseId, HTML):
|
||||||
HTML.testCase_id=testcaseId
|
HTML.testCase_id=testcaseId
|
||||||
|
|||||||
Reference in New Issue
Block a user