Add custom_commad to execute arbitrary command in CI
This commit is contained in:
committed by
Robert Schmidt
parent
2de56bf324
commit
5723e7135f
@@ -498,6 +498,9 @@ def GetParametersFromXML(action):
|
||||
string_field = test.findtext('test_svr_id')
|
||||
if (string_field is not None):
|
||||
CONTAINERS.testSvrId = string_field
|
||||
elif action == 'Custom_Command':
|
||||
RAN.node = test.findtext('node')
|
||||
RAN.command = test.findtext('command')
|
||||
|
||||
else:
|
||||
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
|
||||
RAN.BuildeNB(HTML)
|
||||
elif action == 'WaitEndBuild_eNB':
|
||||
RAN.WaitBuildeNBisFinished(HTML)
|
||||
elif action == 'Custom_Command':
|
||||
logging.info(f"Executing custom command")
|
||||
RAN.CustomCommand(HTML)
|
||||
elif action == 'Initialize_eNB':
|
||||
check_eNB = False
|
||||
check_OAI_UE = False
|
||||
|
||||
@@ -38,6 +38,7 @@ import os
|
||||
import time
|
||||
from multiprocessing import Process, Lock, SimpleQueue
|
||||
import yaml
|
||||
import cls_cmd
|
||||
|
||||
|
||||
#-----------------------------------------------------------
|
||||
@@ -96,6 +97,8 @@ class RANManagement():
|
||||
#checkers from xml
|
||||
self.ran_checkers={}
|
||||
self.cmd_prefix = '' # prefix before {lte,nr}-softmodem
|
||||
self.node = ''
|
||||
self.command = ''
|
||||
|
||||
|
||||
#-----------------------------------------------------------
|
||||
@@ -259,6 +262,21 @@ class RANManagement():
|
||||
mySSH.close()
|
||||
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):
|
||||
HTML.testCase_id=testcaseId
|
||||
|
||||
|
||||
@@ -51,3 +51,4 @@
|
||||
- Push_Local_Registry
|
||||
- Pull_Local_Registry
|
||||
- Clean_Test_Server_Images
|
||||
- Custom_Command
|
||||
|
||||
Reference in New Issue
Block a user