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>
This commit is contained in:
parent
33a1c51e3e
commit
09236d9607
|
@ -45,4 +45,6 @@ artifacts/lava/lava_job_submitter.py \
|
||||||
--kernel-image-type "${KERNEL_IMAGE_TYPE}" \
|
--kernel-image-type "${KERNEL_IMAGE_TYPE}" \
|
||||||
--boot-method ${BOOT_METHOD} \
|
--boot-method ${BOOT_METHOD} \
|
||||||
--visibility-group ${VISIBILITY_GROUP} \
|
--visibility-group ${VISIBILITY_GROUP} \
|
||||||
--lava-tags "${LAVA_TAGS}" >> results/lava.log
|
--lava-tags "${LAVA_TAGS}" \
|
||||||
|
--mesa-job-name "$CI_JOB_NAME" \
|
||||||
|
>> results/lava.log
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -117,6 +118,7 @@ def generate_lava_yaml(args):
|
||||||
|
|
||||||
# skeleton test definition: only declaring each job as a single 'test'
|
# skeleton test definition: only declaring each job as a single 'test'
|
||||||
# since LAVA's test parsing is not useful to us
|
# since LAVA's test parsing is not useful to us
|
||||||
|
run_steps = []
|
||||||
test = {
|
test = {
|
||||||
'timeout': { 'minutes': args.job_timeout },
|
'timeout': { 'minutes': args.job_timeout },
|
||||||
'failure_retry': 1,
|
'failure_retry': 1,
|
||||||
|
@ -133,10 +135,8 @@ def generate_lava_yaml(args):
|
||||||
'scope': [ 'functional' ],
|
'scope': [ 'functional' ],
|
||||||
'format': 'Lava-Test Test Definition 1.0',
|
'format': 'Lava-Test Test Definition 1.0',
|
||||||
},
|
},
|
||||||
'parse': {
|
|
||||||
'pattern': r'hwci: (?P<test_case_id>\S*):\s+(?P<result>(pass|fail))'
|
|
||||||
},
|
|
||||||
'run': {
|
'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-pipeline build artifacts from build job
|
||||||
# - fetch and unpack per-job environment from lava-submit.sh
|
# - fetch and unpack per-job environment from lava-submit.sh
|
||||||
# - exec .gitlab-ci/common/init-stage2.sh
|
# - exec .gitlab-ci/common/init-stage2.sh
|
||||||
init_lines = []
|
run_steps = []
|
||||||
|
|
||||||
with open(args.first_stage_init, 'r') as init_sh:
|
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:
|
with open(args.jwt_file) as jwt_file:
|
||||||
init_lines += [
|
run_steps += [
|
||||||
"set +x",
|
"set +x",
|
||||||
f'echo -n "{jwt_file.read()}" > "{args.jwt_file}" # HIDEME',
|
f'echo -n "{jwt_file.read()}" > "{args.jwt_file}" # HIDEME',
|
||||||
"set -x",
|
"set -x",
|
||||||
]
|
]
|
||||||
|
|
||||||
init_lines += [
|
run_steps += [
|
||||||
'mkdir -p {}'.format(args.ci_project_dir),
|
'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.build_url, args.ci_project_dir),
|
||||||
'wget -S --progress=dot:giga -O- {} | tar -xz -C /'.format(args.job_rootfs_overlay_url),
|
'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',
|
f'echo "export CI_JOB_JWT_FILE={args.jwt_file}" >> /set-job-env-vars.sh',
|
||||||
'exec /init-stage2.sh',
|
'exec /init-stage2.sh',
|
||||||
]
|
]
|
||||||
test['definitions'][0]['repository']['run']['steps'] = init_lines
|
|
||||||
|
|
||||||
values['actions'] = [
|
values['actions'] = [
|
||||||
{ 'deploy': deploy },
|
{ '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):
|
def main(args):
|
||||||
proxy = setup_lava_proxy()
|
proxy = setup_lava_proxy()
|
||||||
|
|
||||||
|
@ -393,8 +397,9 @@ def main(args):
|
||||||
if args.validate_only:
|
if args.validate_only:
|
||||||
return
|
return
|
||||||
|
|
||||||
ret = retriable_follow_job(proxy, job_definition)
|
has_job_passed = retriable_follow_job(proxy, job_definition)
|
||||||
sys.exit(ret)
|
exit_code = 0 if has_job_passed else 1
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
||||||
|
|
||||||
def create_parser():
|
def create_parser():
|
||||||
|
@ -418,6 +423,7 @@ def create_parser():
|
||||||
parser.add_argument("--validate-only", action='store_true')
|
parser.add_argument("--validate-only", action='store_true')
|
||||||
parser.add_argument("--dump-yaml", action='store_true')
|
parser.add_argument("--dump-yaml", action='store_true')
|
||||||
parser.add_argument("--visibility-group")
|
parser.add_argument("--visibility-group")
|
||||||
|
parser.add_argument("--mesa-job-name")
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -432,4 +438,5 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
parser.set_defaults(func=main)
|
parser.set_defaults(func=main)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
treat_mesa_job_name(args)
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
Loading…
Reference in New Issue