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.
This commit is contained in:
@@ -418,24 +418,17 @@ class Cluster:
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def deploy_oc_physim(self, ctx, HTML, oc_release, node):
|
def deploy_oc_physim(self, ctx, HTML, node, workdir, script, options):
|
||||||
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)
|
|
||||||
logging.debug(f'Running physims from server: {node}')
|
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:
|
with cls_cmd.getConnection(node) as c:
|
||||||
ret = c.exec_script(script, 600, options)
|
ret = c.exec_script(script, 600, options)
|
||||||
logging.debug(f'"{script}" finished with code {ret.returncode}, output:\n{ret.stdout}')
|
logging.debug(f'"{script}" finished with code {ret.returncode}, output:\n{ret.stdout}')
|
||||||
with cls_cmd.getConnection(node) as ssh:
|
with cls_cmd.getConnection(node) as ssh:
|
||||||
details_json = archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/{oc_release}-tests.json')
|
details_json = archiveArtifact(ssh, ctx, f'{workdir}/desc-tests.json')
|
||||||
result_junit = archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/{oc_release}-run.xml')
|
result_junit = archiveArtifact(ssh, ctx, f'{workdir}/results-run.xml')
|
||||||
archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/physim_log.txt')
|
archiveArtifact(ssh, ctx, f'{workdir}/physim_log.txt')
|
||||||
archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/physim_pods_summary.txt')
|
archiveArtifact(ssh, ctx, f'{workdir}/LastTestsFailed.log')
|
||||||
archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/LastTestsFailed.log')
|
archiveArtifact(ssh, ctx, f'{workdir}/LastTest.log')
|
||||||
archiveArtifact(ssh, ctx, f'{self.eNBSourceCodePath}/ci-scripts/LastTest.log')
|
|
||||||
test_status, test_summary, test_result = cls_analysis.Analysis.analyze_oc_physim(result_junit, details_json, ctx.logPath)
|
test_status, test_summary, test_result = cls_analysis.Analysis.analyze_oc_physim(result_junit, details_json, ctx.logPath)
|
||||||
if test_summary:
|
if test_summary:
|
||||||
if test_status:
|
if test_status:
|
||||||
|
|||||||
+5
-1
@@ -245,7 +245,11 @@ def ExecuteActionWithParam(action, ctx):
|
|||||||
elif action == 'Deploy_Run_PhySim':
|
elif action == 'Deploy_Run_PhySim':
|
||||||
oc_release = test.findtext('oc_release')
|
oc_release = test.findtext('oc_release')
|
||||||
node = test.findtext('node') or None
|
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':
|
elif action == 'DeployCoreNetwork' or action == 'UndeployCoreNetwork':
|
||||||
cn_id = test.findtext('cn_id')
|
cn_id = test.findtext('cn_id')
|
||||||
|
|||||||
@@ -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
|
oc logs -f -n ${OC_NS} "$POD_ID" | while read -r line; do
|
||||||
if [[ "$line" == *"FINISHED"* ]]; then
|
if [[ "$line" == *"FINISHED"* ]]; then
|
||||||
echo "'FINISHED' detected in logs. Copying logs..."
|
echo "'FINISHED' detected in logs. Copying logs..."
|
||||||
oc logs -n ${OC_NS} "$POD_ID" >> ${OAI_DIR}/ci-scripts/physim_log.txt
|
oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTestsFailed.log ${OAI_DIR}/LastTestsFailed.log
|
||||||
oc describe pod $POD_ID >> ${OAI_DIR}/ci-scripts/physim_pods_summary.txt
|
oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTest.log ${OAI_DIR}/LastTest.log
|
||||||
oc cp "$POD_ID":/opt/oai-physim/Testing/Temporary/LastTestsFailed.log ${OAI_DIR}/ci-scripts/LastTestsFailed.log
|
oc cp "$POD_ID":/opt/oai-physim/${OC_RELEASE}-tests.json ${OAI_DIR}/desc-tests.json
|
||||||
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}-run.xml ${OAI_DIR}/results-run.xml
|
||||||
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
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
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
|
helm uninstall ${OC_RELEASE} --wait
|
||||||
oc delete istag oai-physim:${IMG_TAG} -n ${OC_NS}
|
oc delete istag oai-physim:${IMG_TAG} -n ${OC_NS}
|
||||||
oc logout > /dev/null
|
oc logout > /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user