diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 7be8c594fd..4674be4966 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -429,6 +429,7 @@ def GetParametersFromXML(action): elif action == 'Custom_Command': RAN.node = test.findtext('node') RAN.command = test.findtext('command') + RAN.command_fail = test.findtext('command_fail') in ['True', 'true', 'Yes', 'yes'] else: 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': logging.info(f"Executing custom command") RAN.CustomCommand(HTML) + if RAN.prematureExit: + CiTestObj.AutoTerminateeNB(HTML,RAN,EPC,CONTAINERS) elif action == 'Initialize_eNB': RAN.InitializeeNB(HTML, EPC) if RAN.prematureExit: diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index a8e66989c2..dc3a7d8d35 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -99,6 +99,7 @@ class RANManagement(): self.cmd_prefix = '' # prefix before {lte,nr}-softmodem self.node = '' 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) def CustomCommand(self, HTML): - if self.node == '' or self.node == "localhost": - cmd = cls_cmd.LocalCmd() - else: - cmd = cls_cmd.RemoteCmd(self.node) + cmd = cls_cmd.getConnection(self.node) ret = cmd.run(self.command) cmd.close() - logging.debug(f'CustomCommand: {self.command} returnCode: {ret.returncode} output: {ret.stdout}') - html_queue = SimpleQueue() + logging.debug(f'CustomCommand: {self.command} returnCode: {ret.returncode}') status = 'OK' - if ret.returncode != 0: - html_queue.put(ret.stdout) + message = '' + if ret.returncode != 0 and not self.command_fail: + message = ret.stdout + logging.warning(f'CustomCommand output: {message}') 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): HTML.testCase_id=testcaseId