Use archiveArtifact() for BuildRunTests()

Collect also unit test logs, so that developers could see the reason for
failed logs.
This commit is contained in:
Robert Schmidt
2025-08-06 12:24:30 +02:00
parent 83d037057b
commit 1ffbba525d
2 changed files with 14 additions and 10 deletions
+13 -9
View File
@@ -636,7 +636,7 @@ class Containerize():
HTML.CreateHtmlTabFooter(False) HTML.CreateHtmlTabFooter(False)
return False return False
def BuildRunTests(self, HTML): def BuildRunTests(self, ctx, HTML):
svr = self.eNB_serverId[self.eNB_instance] svr = self.eNB_serverId[self.eNB_instance]
lIpAddr, lSourcePath = self.GetCredentials(svr) lIpAddr, lSourcePath = self.GetCredentials(svr)
logging.debug('Building on server: ' + lIpAddr) logging.debug('Building on server: ' + lIpAddr)
@@ -653,7 +653,6 @@ class Containerize():
if self.forcedWorkspaceCleanup: if self.forcedWorkspaceCleanup:
cmd.run(f'sudo -S rm -Rf {lSourcePath}') cmd.run(f'sudo -S rm -Rf {lSourcePath}')
self.testCase_id = HTML.testCase_id
# check that ran-base image exists as we expect it # check that ran-base image exists as we expect it
baseImage = 'ran-base' baseImage = 'ran-base'
@@ -673,10 +672,10 @@ class Containerize():
# build ran-unittests image # build ran-unittests image
dockerfile = "ci-scripts/docker/Dockerfile.unittest.ubuntu22" dockerfile = "ci-scripts/docker/Dockerfile.unittest.ubuntu22"
ret = cmd.run(f'docker build --progress=plain --tag ran-unittests:{baseTag} --file {dockerfile} . &> {lSourcePath}/cmake_targets/log/unittest-build.log') logfile = f'{lSourcePath}/cmake_targets/log/unittest-build.log'
ret = cmd.run(f'docker build --progress=plain --tag ran-unittests:{baseTag} --file {dockerfile} . &> {logfile}')
archiveArtifact(cmd, ctx, logfile)
if ret.returncode != 0: if ret.returncode != 0:
build_log_name = f'build_log_{self.testCase_id}'
CopyLogsToExecutor(cmd, lSourcePath, build_log_name)
logging.error(f'Cannot build unit tests') logging.error(f'Cannot build unit tests')
HTML.CreateHtmlTestRow("Unit test build failed", 'KO', [dockerfile]) HTML.CreateHtmlTestRow("Unit test build failed", 'KO', [dockerfile])
HTML.CreateHtmlTabFooter(False) HTML.CreateHtmlTabFooter(False)
@@ -685,10 +684,15 @@ class Containerize():
HTML.CreateHtmlTestRowQueue("Build unit tests", 'OK', [dockerfile]) HTML.CreateHtmlTestRowQueue("Build unit tests", 'OK', [dockerfile])
# it worked, build and execute tests, and close connection # it worked, build and execute tests, and close connection
ret = cmd.run(f'docker run -a STDOUT --workdir /oai-ran/build/ --env LD_LIBRARY_PATH=/oai-ran/build/ --rm ran-unittests:{baseTag} ctest --no-label-summary -j$(nproc)') # I would like to run it with --rm and mount the ctest result directory to avoid 'docker cp'
cmd.run(f'docker rmi ran-unittests:{baseTag}') # below, but then permissions are messed up and we can't remove the directory without sudo
build_log_name = f'build_log_{self.testCase_id}' # making the next pipeline fail
CopyLogsToExecutor(cmd, lSourcePath, build_log_name) ret = cmd.run(f'docker run -a STDOUT --workdir /oai-ran/build/ --env LD_LIBRARY_PATH=/oai-ran/build/ --name ran-unittests ran-unittests:{baseTag} ctest --no-label-summary -j$(nproc)')
cmd.run('docker cp ran-unittests:/oai-ran/build/Testing/Temporary/LastTest.log .')
archiveArtifact(cmd, ctx, f'{lSourcePath}/LastTest.log')
cmd.run('docker cp ran-unittests:/oai-ran/build/Testing/Temporary/LastTestsFailed.log .')
archiveArtifact(cmd, ctx, f'{lSourcePath}/LastTestsFailed.log')
cmd.run('docker rm ran-unittests')
cmd.close() cmd.close()
if ret.returncode == 0: if ret.returncode == 0:
+1 -1
View File
@@ -144,7 +144,7 @@ def ExecuteActionWithParam(action, ctx):
elif action == 'Build_Cluster_Image': elif action == 'Build_Cluster_Image':
success = CLUSTER.BuildClusterImage(HTML) success = CLUSTER.BuildClusterImage(HTML)
elif action == 'Build_Run_Tests': elif action == 'Build_Run_Tests':
success = CONTAINERS.BuildRunTests(HTML) success = CONTAINERS.BuildRunTests(ctx, HTML)
elif action == 'Initialize_eNB': elif action == 'Initialize_eNB':
datalog_rt_stats_file=test.findtext('rt_stats_cfg') datalog_rt_stats_file=test.findtext('rt_stats_cfg')