Commit 5723e713 authored by Dhanuja Elizabeth Thomas's avatar Dhanuja Elizabeth Thomas Committed by Robert Schmidt

Add custom_commad to execute arbitrary command in CI

parent 2de56bf3
...@@ -498,6 +498,9 @@ def GetParametersFromXML(action): ...@@ -498,6 +498,9 @@ def GetParametersFromXML(action):
string_field = test.findtext('test_svr_id') string_field = test.findtext('test_svr_id')
if (string_field is not None): if (string_field is not None):
CONTAINERS.testSvrId = string_field CONTAINERS.testSvrId = string_field
elif action == 'Custom_Command':
RAN.node = test.findtext('node')
RAN.command = test.findtext('command')
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")
...@@ -879,6 +882,9 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -879,6 +882,9 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
RAN.BuildeNB(HTML) RAN.BuildeNB(HTML)
elif action == 'WaitEndBuild_eNB': elif action == 'WaitEndBuild_eNB':
RAN.WaitBuildeNBisFinished(HTML) RAN.WaitBuildeNBisFinished(HTML)
elif action == 'Custom_Command':
logging.info(f"Executing custom command")
RAN.CustomCommand(HTML)
elif action == 'Initialize_eNB': elif action == 'Initialize_eNB':
check_eNB = False check_eNB = False
check_OAI_UE = False check_OAI_UE = False
......
...@@ -38,6 +38,7 @@ import os ...@@ -38,6 +38,7 @@ import os
import time import time
from multiprocessing import Process, Lock, SimpleQueue from multiprocessing import Process, Lock, SimpleQueue
import yaml import yaml
import cls_cmd
#----------------------------------------------------------- #-----------------------------------------------------------
...@@ -96,6 +97,8 @@ class RANManagement(): ...@@ -96,6 +97,8 @@ class RANManagement():
#checkers from xml #checkers from xml
self.ran_checkers={} self.ran_checkers={}
self.cmd_prefix = '' # prefix before {lte,nr}-softmodem self.cmd_prefix = '' # prefix before {lte,nr}-softmodem
self.node = ''
self.command = ''
#----------------------------------------------------------- #-----------------------------------------------------------
...@@ -259,6 +262,21 @@ class RANManagement(): ...@@ -259,6 +262,21 @@ class RANManagement():
mySSH.close() mySSH.close()
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):
if self.node == '' or self.node == "localhost":
cmd = cls_cmd.LocalCmd()
else:
cmd = cls_cmd.RemoteCmd(self.node)
ret = cmd.run(self.command)
cmd.close()
logging.debug(f'CustomCommand: {self.command} returnCode: {ret.returncode} output: {ret.stdout}')
html_queue = SimpleQueue()
status = 'OK'
if ret.returncode != 0:
html_queue.put(ret.stdout)
status = 'Warning'
HTML.CreateHtmlTestRow(self.command, status, 1, html_queue)
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
......
...@@ -51,3 +51,4 @@ ...@@ -51,3 +51,4 @@
- Push_Local_Registry - Push_Local_Registry
- Pull_Local_Registry - Pull_Local_Registry
- Clean_Test_Server_Images - Clean_Test_Server_Images
- Custom_Command
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