Generic changes related to UEs used in CI

parent 98f4d038
...@@ -81,7 +81,7 @@ class Module_UE: ...@@ -81,7 +81,7 @@ class Module_UE:
c = cls_cmd.RemoteCmd(self.host) c = cls_cmd.RemoteCmd(self.host)
response = c.run(cmd, silent=silent) response = c.run(cmd, silent=silent)
c.close() c.close()
return response.stdout return response
#-----------------$ #-----------------$
#PUBLIC Methods$ #PUBLIC Methods$
...@@ -95,7 +95,11 @@ class Module_UE: ...@@ -95,7 +95,11 @@ class Module_UE:
if self.cmd_dict["detach"]: if self.cmd_dict["detach"]:
self._command(self.cmd_dict["detach"], silent=True) self._command(self.cmd_dict["detach"], silent=True)
self._command(self.cmd_dict["terminate"], silent=True) self._command(self.cmd_dict["terminate"], silent=True)
self._command(self.cmd_dict["initialize"]) ret = self._command(self.cmd_dict["initialize"])
logging.info(f'For command: {ret.args} | return output: {ret.stdout} | Code: {ret.returncode}')
# Here each UE returns differently for the successful initialization, requires check based on UE
return ret.returncode == 0
def terminate(self): def terminate(self):
self._command(self.cmd_dict["terminate"]) self._command(self.cmd_dict["terminate"])
...@@ -122,9 +126,9 @@ class Module_UE: ...@@ -122,9 +126,9 @@ class Module_UE:
self._command(self.cmd_dict["detach"]) self._command(self.cmd_dict["detach"])
time.sleep(5) time.sleep(5)
if ip: if ip:
logging.debug(f'\u001B[1mUE IP Address is {ip}\u001B[0m') logging.debug(f'\u001B[1mUE IP Address for UE {self.module_name} is {ip}\u001B[0m')
else: else:
logging.debug('\u001B[1;37;41mUE IP Address Not Found!\u001B[0m') logging.debug(f'\u001B[1;37;41mUE IP Address for UE {self.module_name} Not Found!\u001B[0m')
return ip return ip
def detach(self): def detach(self):
...@@ -133,7 +137,7 @@ class Module_UE: ...@@ -133,7 +137,7 @@ class Module_UE:
def check(self): def check(self):
cmd = self.cmd_dict["check"] cmd = self.cmd_dict["check"]
if cmd: if cmd:
return self._command(cmd) return self._command(cmd).stdout
else: else:
logging.warning(f"requested status check of UE {self.getName()}, but operation is not supported") logging.warning(f"requested status check of UE {self.getName()}, but operation is not supported")
return f"UE {self.getName()} does not support status checking" return f"UE {self.getName()} does not support status checking"
...@@ -160,7 +164,7 @@ class Module_UE: ...@@ -160,7 +164,7 @@ class Module_UE:
def getIP(self): def getIP(self):
output = self._command(self.cmd_dict["getNetwork"], silent=True) output = self._command(self.cmd_dict["getNetwork"], silent=True)
result = re.search('inet (?P<ip>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', output) result = re.search('inet (?P<ip>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', output.stdout)
if result and result.group('ip'): if result and result.group('ip'):
ip = result.group('ip') ip = result.group('ip')
return ip return ip
...@@ -168,12 +172,12 @@ class Module_UE: ...@@ -168,12 +172,12 @@ class Module_UE:
def checkMTU(self): def checkMTU(self):
output = self._command(self.cmd_dict["getNetwork"], silent=True) output = self._command(self.cmd_dict["getNetwork"], silent=True)
result = re.search('mtu (?P<mtu>[0-9]+)', output) result = re.search('mtu (?P<mtu>[0-9]+)', output.stdout)
if result and result.group('mtu') and int(result.group('mtu')) == self.MTU: if result and result.group('mtu') and int(result.group('mtu')) == self.MTU:
logging.debug('\u001B[1mUE Module NIC MTU is ' + str(self.MTU) + ' as expected\u001B[0m') logging.debug(f'\u001B[1mUE Module {self.module_name} NIC MTU is {self.MTU} as expected\u001B[0m')
return True return True
else: else:
logging.debug('\u001B[1;37;41m Incorrect Module NIC MTU or MTU not found! Expected: ' + str(self.MTU) + '\u001B[0m') logging.debug(f'\u001B[1;37;41m UE module {self.module_name} has incorrect Module NIC MTU or MTU not found! Expected: {self.MTU} \u001B[0m')
return False return False
def getName(self): def getName(self):
......
...@@ -295,10 +295,13 @@ class OaiCiTest(): ...@@ -295,10 +295,13 @@ class OaiCiTest():
def InitializeUE(self, HTML): def InitializeUE(self, HTML):
ues = [cls_module_ue.Module_UE(n.strip()) for n in self.ue_ids] ues = [cls_module_ue.Module_UE(n.strip()) for n in self.ue_ids]
messages = []
with concurrent.futures.ThreadPoolExecutor() as executor: with concurrent.futures.ThreadPoolExecutor() as executor:
futures = [executor.submit(ue.initialize) for ue in ues] futures = [executor.submit(ue.initialize) for ue in ues]
for f, ue in zip(futures, ues):
uename = f'UE {ue.getName()}'
messages.append(f'{uename}: initialized' if f.result() else f'{uename}: ERROR during Initialization')
[f.result() for f in futures] [f.result() for f in futures]
messages = [f'UE {ue.getName()}: initialized' for ue in ues]
HTML.CreateHtmlTestRowQueue('N/A', 'OK', messages) HTML.CreateHtmlTestRowQueue('N/A', 'OK', messages)
......
...@@ -263,7 +263,7 @@ class RANManagement(): ...@@ -263,7 +263,7 @@ class RANManagement():
cmd = cls_cmd.getConnection(self.node) cmd = cls_cmd.getConnection(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}') logging.debug(f"Custum command : {self.command} on node : {self.node} returnCode : {ret.returncode}")
status = 'OK' status = 'OK'
message = [] message = []
if ret.returncode != 0 and not self.command_fail: if ret.returncode != 0 and not self.command_fail:
......
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