diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index bc98c9e8292ae3152e7138ca56c3cf3e113927f2..8364f9a7fab2936379f175a5790673a23b9d7ee8 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -220,6 +220,25 @@ def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetlos pal_msg += f' (too high! >{self.iperf_packetloss_threshold}%)' return (result, f'{req_msg}\n{bir_msg}\n{brl_msg}\n{jit_msg}\n{pal_msg}') +def Custom_Command(HTML, node, command, command_fail): + logging.info(f"Executing custom command on {node}") + cmd = cls_cmd.getConnection(node) + ret = cmd.run(command) + cmd.close() + logging.debug(f"Custom_Command: {command} on node: {node} - {'OK, command succeeded' if ret.returncode == 0 else f'Error, return code: {ret.returncode}'}") + status = 'OK' + message = [] + if ret.returncode != 0 and not command_fail: + message = [ret.stdout] + logging.warning(f'Custom_Command output: {message}') + status = 'Warning' + if ret.returncode != 0 and command_fail: + message = [ret.stdout] + logging.error(f'Custom_Command failed: output: {message}') + status = 'KO' + HTML.CreateHtmlTestRowQueue(command, status, message) + return status == 'OK' or status == 'Warning' + #----------------------------------------------------------- # OaiCiTest Class Definition #----------------------------------------------------------- diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 808c5cafbac84ea46b7e16d4281906326e8671b3..a36005cec6df2b1f872b6ec86b0630ab0a6c8f57 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -450,10 +450,10 @@ def ExecuteActionWithParam(action): RAN.prematureExit = True 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'] - RAN.CustomCommand(HTML) + node = test.findtext('node') + command = test.findtext('command') + command_fail = test.findtext('command_fail') in ['True', 'true', 'Yes', 'yes'] + cls_oaicitest.Custom_Command(HTML, node, command, command_fail) elif action == 'Pull_Cluster_Image': string_field = test.findtext('images_to_pull') diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index 56424c4f25178d3c5c7d4483c6918c0d428e497f..f64250d12d7feaf307db1b31d48f3f2721239e4e 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -224,27 +224,6 @@ class RANManagement(): mySSH.close() self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, self.testCase_id, HTML) - def CustomCommand(self, HTML): - logging.info(f"Executing custom command on {self.node}") - cmd = cls_cmd.getConnection(self.node) - ret = cmd.run(self.command) - cmd.close() - logging.debug(f"CustomCommand: {self.command} on node: {self.node} - {'OK, command succeeded' if ret.returncode == 0 else f'Error, return code: {ret.returncode}'}") - status = 'OK' - message = [] - if ret.returncode != 0 and not self.command_fail: - message = [ret.stdout] - logging.warning(f'CustomCommand output: {message}') - status = 'Warning' - if self.command_fail: # important command since it would make the pipeline fail, so show output in HTML - message = [ret.stdout] - 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