From 190dc55d9fff3abc2dbe2c5ee48d89451425a2d1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 11 Aug 2025 12:35:56 +0200 Subject: [PATCH] Pass node to various Build*() functions Pass node directly from XML to these functions - BuildClusterImage() - BuildImage() - BuildProxy() - BuildRunTests() instead of reading the "server ID" and looking up from eNB_IPAddress/eNB1_IPAddress/eNB2_IPAddress. Improve the proxy build unit test by properly passing ctx information. --- ci-scripts/args_parse.py | 3 -- ci-scripts/cls_cluster.py | 10 +++---- ci-scripts/cls_containerize.py | 29 +++++++++---------- ci-scripts/cls_native.py | 6 ++-- ci-scripts/main.py | 25 ++++------------ ci-scripts/tests/build.py | 10 +++---- ci-scripts/xml_files/cluster_image_build.xml | 1 + .../xml_files/container_build_run_tests.xml | 3 +- .../xml_files/container_image_build.xml | 3 +- .../xml_files/container_image_build_arm.xml | 3 +- .../xml_files/container_image_build_cross.xml | 3 +- .../xml_files/container_l2sim_proxy.xml | 3 +- ci-scripts/xml_files/gnb_usrp_build.xml | 1 + 13 files changed, 38 insertions(+), 62 deletions(-) diff --git a/ci-scripts/args_parse.py b/ci-scripts/args_parse.py index 7b57409fb0..11b27135a2 100644 --- a/ci-scripts/args_parse.py +++ b/ci-scripts/args_parse.py @@ -125,7 +125,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER): matchReg = re.match(r'^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNBIPAddress=matchReg.group(1) CONTAINERS.eNBIPAddress=matchReg.group(1) - CLUSTER.eNBIPAddress=matchReg.group(1) elif re.match(r'^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match(r'^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1IPAddress=matchReg.group(1) @@ -139,7 +138,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER): matchReg = re.match(r'^\-\-eNBUserName=(.+)$', myArgv, re.IGNORECASE) RAN.eNBUserName=matchReg.group(1) CONTAINERS.eNBUserName=matchReg.group(1) - CLUSTER.eNBUserName=matchReg.group(1) elif re.match(r'^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match(r'^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1UserName=matchReg.group(1) @@ -153,7 +151,6 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,CONTAINERS,HELP,SCA,CLUSTER): matchReg = re.match(r'^\-\-eNBPassword=(.+)$', myArgv, re.IGNORECASE) RAN.eNBPassword=matchReg.group(1) CONTAINERS.eNBPassword=matchReg.group(1) - CLUSTER.eNBPassword=matchReg.group(1) elif re.match(r'^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match(r'^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1Password=matchReg.group(1) diff --git a/ci-scripts/cls_cluster.py b/ci-scripts/cls_cluster.py index dd3c66d989..929dd29021 100644 --- a/ci-scripts/cls_cluster.py +++ b/ci-scripts/cls_cluster.py @@ -69,7 +69,6 @@ def OC_logout(cmd): class Cluster: def __init__(self): - self.eNBIPAddress = "" self.eNBSourceCodePath = "" self.forcedWorkspaceCleanup = False self.OCUserName = "" @@ -195,13 +194,12 @@ class Cluster: self.cmd.run(f'oc logs {job} &> {fn}') return (image, archiveArtifact(self.cmd, ctx, fn)) - def BuildClusterImage(self, ctx, HTML): + def BuildClusterImage(self, ctx, node, HTML): if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': HELP.GenericHelp(CONST.Version) raise ValueError(f'Insufficient Parameter: ranRepository {self.ranRepository} ranBranch {ranBranch} ranCommitID {self.ranCommitID}') - lIpAddr = self.eNBIPAddress lSourcePath = self.eNBSourceCodePath - if lIpAddr == '' or lSourcePath == '': + if node == '' or lSourcePath == '': raise ValueError('Insufficient Parameter: eNBSourceCodePath missing') ocUserName = self.OCUserName ocPassword = self.OCPassword @@ -212,8 +210,8 @@ class Cluster: if self.OCRegistry.startswith("http") or self.OCRegistry.endswith("/"): raise ValueError(f'ocRegistry {self.OCRegistry} should not start with http:// or https:// and not end on a slash /') - logging.debug(f'Building on cluster triggered from server: {lIpAddr}') - self.cmd = cls_cmd.RemoteCmd(lIpAddr) + logging.debug(f'Building on cluster triggered from server: {node}') + self.cmd = cls_cmd.RemoteCmd(node) self.testCase_id = HTML.testCase_id diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 7629a2ee17..282fe0f4a0 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -280,11 +280,10 @@ class Containerize(): raise ValueError(f'Insufficient Parameter: IP/node {ip}, path {path}') return (ip, path) - def BuildImage(self, ctx, HTML): - svr = self.eNB_serverId[self.eNB_instance] - lIpAddr, lSourcePath = self.GetCredentials(svr) - logging.debug('Building on server: ' + lIpAddr) - cmd = cls_cmd.getConnection(lIpAddr) + def BuildImage(self, ctx, node, HTML): + lSourcePath = self.eNBSourceCodePath + logging.debug('Building on server: ' + node) + cmd = cls_cmd.getConnection(node) log_files = [] # Checking the hostname to get adapted on cli and dockerfileprefixes @@ -475,11 +474,10 @@ class Containerize(): logging.error('\u001B[1m Building OAI Images Failed\u001B[0m') return status - def BuildProxy(self, ctx, HTML): - svr = self.eNB_serverId[self.eNB_instance] - lIpAddr, lSourcePath = self.GetCredentials(svr) - logging.debug('Building on server: ' + lIpAddr) - ssh = cls_cmd.getConnection(lIpAddr) + def BuildProxy(self, ctx, node, HTML): + lSourcePath = self.eNBSourceCodePath + logging.debug('Building on server: ' + node) + ssh = cls_cmd.getConnection(node) oldRanCommidID = self.ranCommitID oldRanRepository = self.ranRepository @@ -502,7 +500,7 @@ class Containerize(): buildProxy = ret.returncode != 0 # if no image, build new proxy if buildProxy: ssh.run(f'rm -Rf {lSourcePath}') - success = CreateWorkspace(lIpAddr, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) + success = CreateWorkspace(node, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge) if not success: raise Exception("could not clone proxy repository") @@ -559,11 +557,10 @@ class Containerize(): HTML.CreateHtmlTestRow('commit ' + tag, 'KO', CONST.ALL_PROCESSES_OK) return False - def BuildRunTests(self, ctx, HTML): - svr = self.eNB_serverId[self.eNB_instance] - lIpAddr, lSourcePath = self.GetCredentials(svr) - logging.debug('Building on server: ' + lIpAddr) - cmd = cls_cmd.RemoteCmd(lIpAddr) + def BuildRunTests(self, ctx, node, HTML): + lSourcePath = self.eNBSourceCodePath + logging.debug('Building on server: ' + node) + cmd = cls_cmd.RemoteCmd(node) cmd.cd(lSourcePath) ret = cmd.run('hostnamectl') diff --git a/ci-scripts/cls_native.py b/ci-scripts/cls_native.py index 83c1b14b37..9546f93d28 100644 --- a/ci-scripts/cls_native.py +++ b/ci-scripts/cls_native.py @@ -34,11 +34,11 @@ DPDK_PATH = '/opt/dpdk-t2-22.11.0' class Native(): - def Build(ctx, test_case, HTML, host, directory, options): - logging.debug(f'Building on server: {host}') + def Build(ctx, node, test_case, HTML, directory, options): + logging.debug(f'Building on server: {node}') HTML.testCase_id = test_case - with cls_cmd.getConnection(host) as ssh: + with cls_cmd.getConnection(node) as ssh: base = f"{directory}/cmake_targets" ret = ssh.run(f"C_INCLUDE_PATH={DPDK_PATH}/include/ PKG_CONFIG_PATH={DPDK_PATH}/lib64/pkgconfig/ {base}/build_oai {options} > {base}/build_oai.log", timeout=900) success = ret.returncode == 0 diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 03e8e126a0..d30b209be7 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -110,33 +110,20 @@ def ExecuteActionWithParam(action, ctx): RAN.Build_eNB_forced_workspace_cleanup = True CONTAINERS.forcedWorkspaceCleanup = True CLUSTER.forcedWorkspaceCleanup = True - eNB_instance=test.findtext('eNB_instance') - if (eNB_instance is None): - RAN.eNB_instance=0 - CONTAINERS.eNB_instance=0 - else: - RAN.eNB_instance=int(eNB_instance) - CONTAINERS.eNB_instance=int(eNB_instance) - eNB_serverId=test.findtext('eNB_serverId') - if (eNB_serverId is None): - RAN.eNB_serverId[RAN.eNB_instance]='0' - CONTAINERS.eNB_serverId[RAN.eNB_instance]='0' - else: - RAN.eNB_serverId[RAN.eNB_instance]=eNB_serverId - CONTAINERS.eNB_serverId[CONTAINERS.eNB_instance]=eNB_serverId + node = test.findtext('node') proxy_commit = test.findtext('proxy_commit') if proxy_commit is not None: CONTAINERS.proxyCommit = proxy_commit if action == 'Build_eNB': - success = cls_native.Native.Build(ctx, HTML.testCase_id, HTML, RAN.eNBIPAddress, RAN.eNBSourceCodePath, RAN.Build_eNB_args) + success = cls_native.Native.Build(ctx, node, HTML.testCase_id, HTML, RAN.eNBSourceCodePath, RAN.Build_eNB_args) elif action == 'Build_Image': - success = CONTAINERS.BuildImage(ctx, HTML) + success = CONTAINERS.BuildImage(ctx, node, HTML) elif action == 'Build_Proxy': - success = CONTAINERS.BuildProxy(ctx, HTML) + success = CONTAINERS.BuildProxy(ctx, node, HTML) elif action == 'Build_Cluster_Image': - success = CLUSTER.BuildClusterImage(ctx, HTML) + success = CLUSTER.BuildClusterImage(ctx, node, HTML) elif action == 'Build_Run_Tests': - success = CONTAINERS.BuildRunTests(ctx, HTML) + success = CONTAINERS.BuildRunTests(ctx, node, HTML) elif action == 'Initialize_eNB': datalog_rt_stats_file=test.findtext('rt_stats_cfg') diff --git a/ci-scripts/tests/build.py b/ci-scripts/tests/build.py index 669e6711b4..013486a560 100644 --- a/ci-scripts/tests/build.py +++ b/ci-scripts/tests/build.py @@ -11,6 +11,7 @@ import tempfile sys.path.append('./') # to find OAI imports below import cls_oai_html import cls_containerize +from cls_ci_helper import TestCaseCtx import cls_cmd class TestBuild(unittest.TestCase): @@ -18,22 +19,21 @@ class TestBuild(unittest.TestCase): self.html = cls_oai_html.HTMLManagement() self.html.testCase_id = "000000" self.cont = cls_containerize.Containerize() - self.cont.eNB_serverId[0] = '0' - self.cont.eNBIPAddress = 'localhost' - self.cont.eNBUserName = None - self.cont.eNBPassword = None self._d = tempfile.mkdtemp() logging.warning(f"temporary directory: {self._d}") + self.node = 'localhost' self.cont.eNBSourceCodePath = self._d + self.ctx = TestCaseCtx.Default(tempfile.mkdtemp()) def tearDown(self): logging.warning(f"removing directory contents") with cls_cmd.getConnection(None) as cmd: cmd.run(f"rm -rf {self._d}") + cmd.run(f'rm -rf {self.ctx.logPath}') def test_build_proxy(self): self.cont.proxyCommit = "b64d9bce986b38ca59e8582864ade3fcdd05c0dc" - success = self.cont.BuildProxy(self.html) + success = self.cont.BuildProxy(self.ctx, self.node, self.html) self.assertTrue(success) if __name__ == '__main__': diff --git a/ci-scripts/xml_files/cluster_image_build.xml b/ci-scripts/xml_files/cluster_image_build.xml index b8462a4ebd..a80d1cd7d4 100644 --- a/ci-scripts/xml_files/cluster_image_build.xml +++ b/ci-scripts/xml_files/cluster_image_build.xml @@ -37,6 +37,7 @@ Build_Cluster_Image Build Images on OpenShift Cluster + poseidon diff --git a/ci-scripts/xml_files/container_build_run_tests.xml b/ci-scripts/xml_files/container_build_run_tests.xml index 479bb20a5d..087c5af598 100644 --- a/ci-scripts/xml_files/container_build_run_tests.xml +++ b/ci-scripts/xml_files/container_build_run_tests.xml @@ -32,9 +32,8 @@ Build_Run_Tests Build and Run UnitTests + obelix all - 0 - 0 diff --git a/ci-scripts/xml_files/container_image_build.xml b/ci-scripts/xml_files/container_image_build.xml index b2c0705d8a..33f29cf087 100644 --- a/ci-scripts/xml_files/container_image_build.xml +++ b/ci-scripts/xml_files/container_image_build.xml @@ -39,9 +39,8 @@ Build_Image Build all Images + obelix all - 0 - 0 True diff --git a/ci-scripts/xml_files/container_image_build_arm.xml b/ci-scripts/xml_files/container_image_build_arm.xml index e82e357d26..7c731fd3a1 100644 --- a/ci-scripts/xml_files/container_image_build_arm.xml +++ b/ci-scripts/xml_files/container_image_build_arm.xml @@ -39,9 +39,8 @@ Build_Image Build all Images + gracehopper3-oai native_arm - 0 - 0 diff --git a/ci-scripts/xml_files/container_image_build_cross.xml b/ci-scripts/xml_files/container_image_build_cross.xml index c47253662b..ddaeac3602 100644 --- a/ci-scripts/xml_files/container_image_build_cross.xml +++ b/ci-scripts/xml_files/container_image_build_cross.xml @@ -38,8 +38,7 @@ Build_Image Cross-Compile for ARM64 build_cross_arm64 - 0 - 0 + alambix True diff --git a/ci-scripts/xml_files/container_l2sim_proxy.xml b/ci-scripts/xml_files/container_l2sim_proxy.xml index 197baf429b..88026f077d 100644 --- a/ci-scripts/xml_files/container_l2sim_proxy.xml +++ b/ci-scripts/xml_files/container_l2sim_proxy.xml @@ -32,8 +32,7 @@ Build_Proxy Build L2sim Proxy Image - 1 - 1 + localhost True b64d9bce986b38ca59e8582864ade3fcdd05c0dc diff --git a/ci-scripts/xml_files/gnb_usrp_build.xml b/ci-scripts/xml_files/gnb_usrp_build.xml index 8ee89ee108..4e763678a7 100644 --- a/ci-scripts/xml_files/gnb_usrp_build.xml +++ b/ci-scripts/xml_files/gnb_usrp_build.xml @@ -41,6 +41,7 @@ TesteNB Build_eNB Build gNB (USRP) + caracal --gNB -w USRP --ninja -c -P --build-lib ldpc_cuda --build-lib ldpc_aal --cmake-opt -DASN1C_EXEC=/opt/asn1c/bin/asn1c True