From deadd5414df68eca747eaeb822c6738657283409 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 22 Aug 2025 14:39:24 +0200 Subject: [PATCH] CI: Generalizce deploy_oc_physim() A future commit will enable to deploy physical simulators via docker. Hence: - Move the script to run out of deploy_oc_physim(), to make it more generic (later commits will introduce other scripts) - pass the working directory (the function will be moved into cls_oaicitest, as it fits neither cls_containerize nor cls_cluster when deploying the tests from source) - not using ci-scripts: don't hardcode a specific path, just use the working directory - avoid helm-specific pods summary, and put it into the general "physim logs" - remove helm-specific "release", and use a generic name for results - always log pod logs and status to debug, even if deployment was not successful or tests did not finish. --- ci-scripts/cls_cluster.py | 19 ++++++------------- ci-scripts/main.py | 6 +++++- ci-scripts/scripts/oc-deploy-physims.sh | 12 ++++++------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/ci-scripts/cls_cluster.py b/ci-scripts/cls_cluster.py index def8b1272f..0db451b63c 100644 --- a/ci-scripts/cls_cluster.py +++ b/ci-scripts/cls_cluster.py @@ -418,24 +418,17 @@ class Cluster: return status - def deploy_oc_physim(self, ctx, HTML, oc_release, node): - if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': - HELP.GenericHelp(CONST.Version) - raise ValueError(f'Insufficient Parameter: ranRepository {self.ranRepository} ranBranch {self.ranBranch} ranCommitID {self.ranCommitID}') - image_tag = cls_containerize.CreateTag(self.ranCommitID, self.ranBranch, self.ranAllowMerge) + def deploy_oc_physim(self, ctx, HTML, node, workdir, script, options): logging.debug(f'Running physims from server: {node}') - script = "scripts/oc-deploy-physims.sh" - options = f"oaicicd-core-for-ci-ran {oc_release} {image_tag} {self.eNBSourceCodePath}" with cls_cmd.getConnection(node) as c: ret = c.exec_script(script, 600, options) logging.debug(f'"{script}" finished with code {ret.returncode}, output:\n{ret.stdout}') with cls_cmd.getConnection(node) as ssh: - details_json = archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/{oc_release}-tests.json') - result_junit = archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/{oc_release}-run.xml') - archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/physim_log.txt') - archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/physim_pods_summary.txt') - archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/LastTestsFailed.log') - archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/LastTest.log') + details_json = archiveArtifact(ssh, ctx, f'{workdir}/desc-tests.json') + result_junit = archiveArtifact(ssh, ctx, f'{workdir}/results-run.xml') + archiveArtifact(ssh, ctx, f'{workdir}/physim_log.txt') + archiveArtifact(ssh, ctx, f'{workdir}/LastTestsFailed.log') + archiveArtifact(ssh, ctx, f'{workdir}/LastTest.log') test_status, test_summary, test_result = cls_analysis.Analysis.analyze_oc_physim(result_junit, details_json, ctx.logPath) if test_summary: if test_status: diff --git a/ci-scripts/main.py b/ci-scripts/main.py index cbc03a47d5..36608a4fec 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -245,7 +245,11 @@ def ExecuteActionWithParam(action, ctx): elif action == 'Deploy_Run_PhySim': oc_release = test.findtext('oc_release') node = test.findtext('node') or None - success = CLUSTER.deploy_oc_physim(ctx, HTML, oc_release, node) + script = "scripts/oc-deploy-physims.sh" + image_tag = cls_containerize.CreateTag(CLUSTER.ranCommitID, CLUSTER.ranBranch, CLUSTER.ranAllowMerge) + options = f"oaicicd-core-for-ci-ran {oc_release} {image_tag} {CLUSTER.eNBSourceCodePath}" + workdir = CLUSTER.eNBSourceCodePath + success = CLUSTER.deploy_oc_physim(ctx, HTML, node, workdir, script, options) elif action == 'DeployCoreNetwork' or action == 'UndeployCoreNetwork': cn_id = test.findtext('cn_id') diff --git a/ci-scripts/scripts/oc-deploy-physims.sh b/ci-scripts/scripts/oc-deploy-physims.sh index c46b900bdc..953e541770 100755 --- a/ci-scripts/scripts/oc-deploy-physims.sh +++ b/ci-scripts/scripts/oc-deploy-physims.sh @@ -20,15 +20,15 @@ echo "Monitoring logs for 'FINISHED' in pod '$POD_ID'" oc logs -f -n ${OC_NS} "$POD_ID" | while read -r line; do if [[ "$line" == *"FINISHED"* ]]; then echo "'FINISHED' detected in logs. Copying logs..." - oc logs -n ${OC_NS} "$POD_ID" >> ${OAI_DIR}/ci-scripts/physim_log.txt - oc describe pod $POD_ID >> ${OAI_DIR}/ci-scripts/physim_pods_summary.txt - oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTestsFailed.log ${OAI_DIR}/ci-scripts/LastTestsFailed.log - oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTest.log ${OAI_DIR}/ci-scripts/LastTest.log - oc cp "$POD_ID":/opt/oai-physim/${OC_RELEASE}-tests.json ${OAI_DIR}/ci-scripts/${OC_RELEASE}-tests.json - oc cp "$POD_ID":/opt/oai-physim/${OC_RELEASE}-run.xml ${OAI_DIR}/ci-scripts/${OC_RELEASE}-run.xml + oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTestsFailed.log ${OAI_DIR}/LastTestsFailed.log + oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTest.log ${OAI_DIR}/LastTest.log + oc cp "$POD_ID":/opt/oai-physim/${OC_RELEASE}-tests.json ${OAI_DIR}/desc-tests.json + oc cp "$POD_ID":/opt/oai-physim/${OC_RELEASE}-run.xml ${OAI_DIR}/results-run.xml break fi done +oc logs -n ${OC_NS} "$POD_ID" >> ${OAI_DIR}/physim_log.txt +oc describe pod $POD_ID >> ${OAI_DIR}/physim_log.txt helm uninstall ${OC_RELEASE} --wait oc delete istag oai-physim:${IMG_TAG} -n ${OC_NS} oc logout > /dev/null