Use archiveArtifact() for module_UE
This commit is contained in:
@@ -32,6 +32,7 @@ import re
|
||||
import yaml
|
||||
|
||||
import cls_cmd
|
||||
from cls_ci_helper import archiveArtifact
|
||||
|
||||
class Module_UE:
|
||||
|
||||
@@ -103,11 +104,11 @@ class Module_UE:
|
||||
return ret.returncode == 0
|
||||
|
||||
|
||||
def terminate(self, log_dir=None):
|
||||
def terminate(self, ctx=None):
|
||||
self._command(self.cmd_dict["terminate"])
|
||||
if self.trace and log_dir is not None:
|
||||
if self.trace and ctx is not None:
|
||||
self._disableTrace()
|
||||
return self._collectTrace(log_dir)
|
||||
return self._collectTrace(ctx)
|
||||
return None
|
||||
|
||||
def attach(self, attach_tries = 4, attach_timeout = 60):
|
||||
@@ -202,8 +203,7 @@ class Module_UE:
|
||||
logging.info(f'UE {self}: stop UE tracing')
|
||||
self._command(self.cmd_dict["traceStop"])
|
||||
|
||||
def _collectTrace(self, log_dir):
|
||||
logging.info(f'collecting logs into (local) {log_dir}')
|
||||
def _collectTrace(self, ctx):
|
||||
remote_dir = "/tmp/ue-trace-logs"
|
||||
with cls_cmd.getConnection(self.host) as c:
|
||||
# create a directory for log collection
|
||||
@@ -222,8 +222,7 @@ class Module_UE:
|
||||
log_files = []
|
||||
# copy them to the executor one by one, and store in log_dir
|
||||
for f in ret.stdout.split("\n"):
|
||||
l = f.replace(remote_dir, log_dir)
|
||||
c.copyin(f, l)
|
||||
log_files.append(l)
|
||||
name = archiveArtifact(c, ctx, f)
|
||||
log_files.append(name)
|
||||
c.run(f'rm -rf {remote_dir}')
|
||||
return log_files
|
||||
|
||||
@@ -834,10 +834,10 @@ class OaiCiTest():
|
||||
global_status = CONST.OAI_UE_PROCESS_COULD_NOT_SYNC
|
||||
return global_status
|
||||
|
||||
def TerminateUE(self, HTML, logPath):
|
||||
def TerminateUE(self, ctx, HTML):
|
||||
ues = [cls_module.Module_UE(n.strip()) for n in self.ue_ids]
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=64) as executor:
|
||||
futures = [executor.submit(ue.terminate, logPath) for ue in ues]
|
||||
futures = [executor.submit(ue.terminate, ctx) for ue in ues]
|
||||
archives = [f.result() for f in futures]
|
||||
archive_info = [f'Log at: {a}' if a else 'No log available' for a in archives]
|
||||
messages = [f"UE {ue.getName()}: {log}" for (ue, log) in zip(ues, archive_info)]
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ def ExecuteActionWithParam(action, ctx):
|
||||
elif action == 'Detach_UE':
|
||||
success = CiTestObj.DetachUE(HTML)
|
||||
elif action == 'Terminate_UE':
|
||||
success = CiTestObj.TerminateUE(HTML, logPath)
|
||||
success = CiTestObj.TerminateUE(ctx, HTML)
|
||||
elif action == 'CheckStatusUE':
|
||||
success = CiTestObj.CheckStatusUE(HTML)
|
||||
elif action == 'DataEnable_UE':
|
||||
|
||||
@@ -12,9 +12,16 @@ import unittest
|
||||
|
||||
sys.path.append('./') # to find OAI imports below
|
||||
import cls_module
|
||||
from cls_ci_helper import TestCaseCtx
|
||||
import cls_cmd
|
||||
|
||||
class TestModule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.ctx = TestCaseCtx.Default(tempfile.mkdtemp())
|
||||
def tearDown(self):
|
||||
with cls_cmd.LocalCmd() as c:
|
||||
c.run(f'rm -rf {self.ctx.logPath}')
|
||||
|
||||
def test_simple_module(self):
|
||||
c = cls_module.Module_UE("test", filename="tests/config/test_module_infra.yaml")
|
||||
self.assertFalse(c.trace)
|
||||
@@ -49,10 +56,9 @@ class TestModule(unittest.TestCase):
|
||||
self.assertTrue(c.checkMTU())
|
||||
c.detach()
|
||||
tmp = tempfile.mkdtemp()
|
||||
log_file = c.terminate(log_dir=tmp)
|
||||
with cls_cmd.LocalCmd() as c:
|
||||
c.run(f'rm -rf {tmp}')
|
||||
self.assertEqual(log_file, [f"{tmp}/tttf"]) # matches test-trace UE collection file
|
||||
log_file = c.terminate(self.ctx)
|
||||
# undeploy uses archiveArtifact(), which writes to {prefix}-logs
|
||||
self.assertEqual(log_file, [f"{self.ctx.baseFilename()}-tttf"]) # matches test-trace UE collection file
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user