summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Gallo <guilherme.gallo@collabora.com>2022-03-22 22:39:31 -0300
committerMarge Bot <emma+marge@anholt.net>2022-04-28 06:33:46 +0000
commit09236d9607a999026081b2c93af497e3bdd599e3 (patch)
treeff3363cdd938068b142e5dc743a8924d0786d262
parent33a1c51e3e700b4483507e486e876ae7a09456df (diff)
ci/lava: Use lava-test-case to run custom scripts in LAVA
The exit code is automatically parsed to fail/pass the job, so this commit removes the `hwci.*pass|fail` regex and printings. Add mesa-job-name parameter to get the CI_JOB_NAME easily to serve as test name. Besides, there is the treatment for the mesa job naeme, as LAVA does not like whitespace character inside the test case/suite name, since it interprets it as a LAVA signal parameter and it can make the job fail when the script looks for the results from the LAVA RPC. And the slash character seems to break gitlab log sectioning, so removing every character after the first whitespace. Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15938>
-rwxr-xr-x.gitlab-ci/lava/lava-submit.sh4
-rwxr-xr-x.gitlab-ci/lava/lava_job_submitter.py27
2 files changed, 20 insertions, 11 deletions
diff --git a/.gitlab-ci/lava/lava-submit.sh b/.gitlab-ci/lava/lava-submit.sh
index a61665dee82..a4bd28a3993 100755
--- a/.gitlab-ci/lava/lava-submit.sh
+++ b/.gitlab-ci/lava/lava-submit.sh
@@ -45,4 +45,6 @@ artifacts/lava/lava_job_submitter.py \
--kernel-image-type "${KERNEL_IMAGE_TYPE}" \
--boot-method ${BOOT_METHOD} \
--visibility-group ${VISIBILITY_GROUP} \
- --lava-tags "${LAVA_TAGS}" >> results/lava.log
+ --lava-tags "${LAVA_TAGS}" \
+ --mesa-job-name "$CI_JOB_NAME" \
+ >> results/lava.log \ No newline at end of file
diff --git a/.gitlab-ci/lava/lava_job_submitter.py b/.gitlab-ci/lava/lava_job_submitter.py
index b73ea692626..05fca6b7079 100755
--- a/.gitlab-ci/lava/lava_job_submitter.py
+++ b/.gitlab-ci/lava/lava_job_submitter.py
@@ -26,6 +26,7 @@
import argparse
import pathlib
+import re
import sys
import time
import traceback
@@ -117,6 +118,7 @@ def generate_lava_yaml(args):
# skeleton test definition: only declaring each job as a single 'test'
# since LAVA's test parsing is not useful to us
+ run_steps = []
test = {
'timeout': { 'minutes': args.job_timeout },
'failure_retry': 1,
@@ -133,10 +135,8 @@ def generate_lava_yaml(args):
'scope': [ 'functional' ],
'format': 'Lava-Test Test Definition 1.0',
},
- 'parse': {
- 'pattern': r'hwci: (?P<test_case_id>\S*):\s+(?P<result>(pass|fail))'
- },
'run': {
+ "steps": run_steps
},
},
} ],
@@ -147,26 +147,25 @@ def generate_lava_yaml(args):
# - fetch and unpack per-pipeline build artifacts from build job
# - fetch and unpack per-job environment from lava-submit.sh
# - exec .gitlab-ci/common/init-stage2.sh
- init_lines = []
+ run_steps = []
with open(args.first_stage_init, 'r') as init_sh:
- init_lines += [ x.rstrip() for x in init_sh if not x.startswith('#') and x.rstrip() ]
+ run_steps += [ x.rstrip() for x in init_sh if not x.startswith('#') and x.rstrip() ]
with open(args.jwt_file) as jwt_file:
- init_lines += [
+ run_steps += [
"set +x",
f'echo -n "{jwt_file.read()}" > "{args.jwt_file}" # HIDEME',
"set -x",
]
- init_lines += [
+ run_steps += [
'mkdir -p {}'.format(args.ci_project_dir),
'wget -S --progress=dot:giga -O- {} | tar -xz -C {}'.format(args.build_url, args.ci_project_dir),
'wget -S --progress=dot:giga -O- {} | tar -xz -C /'.format(args.job_rootfs_overlay_url),
f'echo "export CI_JOB_JWT_FILE={args.jwt_file}" >> /set-job-env-vars.sh',
'exec /init-stage2.sh',
]
- test['definitions'][0]['repository']['run']['steps'] = init_lines
values['actions'] = [
{ 'deploy': deploy },
@@ -376,6 +375,11 @@ def retriable_follow_job(proxy, job_definition):
)
+def treat_mesa_job_name(args):
+ # Remove mesa job names with spaces, which breaks the lava-test-case command
+ args.mesa_job_name = args.mesa_job_name.split(" ")[0]
+
+
def main(args):
proxy = setup_lava_proxy()
@@ -393,8 +397,9 @@ def main(args):
if args.validate_only:
return
- ret = retriable_follow_job(proxy, job_definition)
- sys.exit(ret)
+ has_job_passed = retriable_follow_job(proxy, job_definition)
+ exit_code = 0 if has_job_passed else 1
+ sys.exit(exit_code)
def create_parser():
@@ -418,6 +423,7 @@ def create_parser():
parser.add_argument("--validate-only", action='store_true')
parser.add_argument("--dump-yaml", action='store_true')
parser.add_argument("--visibility-group")
+ parser.add_argument("--mesa-job-name")
return parser
@@ -432,4 +438,5 @@ if __name__ == "__main__":
parser.set_defaults(func=main)
args = parser.parse_args()
+ treat_mesa_job_name(args)
args.func(args)