2021-05-29 01:38:54 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# Copyright (C) 2020, 2021 Collabora Limited
|
|
|
|
# Author: Gustavo Padovan <gustavo.padovan@collabora.com>
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
# copy of this software and associated documentation files (the "Software"),
|
|
|
|
# to deal in the Software without restriction, including without limitation
|
|
|
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
# and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
# Software is furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice (including the next
|
|
|
|
# paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
# Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
|
|
|
|
"""Send a job to LAVA, track it and collect log back"""
|
|
|
|
|
|
|
|
import argparse
|
2021-12-02 13:13:10 +00:00
|
|
|
import pathlib
|
2021-05-29 01:38:54 +01:00
|
|
|
import sys
|
|
|
|
import time
|
2021-06-10 09:45:54 +01:00
|
|
|
import traceback
|
2021-05-29 01:38:54 +01:00
|
|
|
import urllib.parse
|
|
|
|
import xmlrpc
|
2021-09-10 16:58:27 +01:00
|
|
|
from datetime import datetime, timedelta
|
2022-02-16 04:07:57 +00:00
|
|
|
from os import getenv
|
2022-03-23 22:26:47 +00:00
|
|
|
from typing import Optional
|
2021-12-02 13:13:10 +00:00
|
|
|
|
|
|
|
import lavacli
|
|
|
|
import yaml
|
2021-05-29 01:38:54 +01:00
|
|
|
from lavacli.utils import loader
|
|
|
|
|
2022-02-16 04:07:57 +00:00
|
|
|
# Timeout in seconds to decide if the device from the dispatched LAVA job has
|
2021-09-15 15:03:16 +01:00
|
|
|
# hung or not due to the lack of new log output.
|
2022-02-16 04:07:57 +00:00
|
|
|
DEVICE_HANGING_TIMEOUT_SEC = int(getenv("LAVA_DEVICE_HANGING_TIMEOUT_SEC", 5*60))
|
2021-09-15 15:03:16 +01:00
|
|
|
|
|
|
|
# How many seconds the script should wait before try a new polling iteration to
|
|
|
|
# check if the dispatched LAVA job is running or waiting in the job queue.
|
2022-02-16 04:07:57 +00:00
|
|
|
WAIT_FOR_DEVICE_POLLING_TIME_SEC = int(getenv("LAVA_WAIT_FOR_DEVICE_POLLING_TIME_SEC", 10))
|
2021-09-15 15:03:16 +01:00
|
|
|
|
|
|
|
# How many seconds to wait between log output LAVA RPC calls.
|
2022-02-16 04:07:57 +00:00
|
|
|
LOG_POLLING_TIME_SEC = int(getenv("LAVA_LOG_POLLING_TIME_SEC", 5))
|
2021-09-15 15:03:16 +01:00
|
|
|
|
|
|
|
# How many retries should be made when a timeout happen.
|
2022-02-16 04:07:57 +00:00
|
|
|
NUMBER_OF_RETRIES_TIMEOUT_DETECTION = int(getenv("LAVA_NUMBER_OF_RETRIES_TIMEOUT_DETECTION", 2))
|
2021-09-15 15:03:16 +01:00
|
|
|
|
2021-05-29 01:38:54 +01:00
|
|
|
|
|
|
|
def print_log(msg):
|
2021-06-10 23:45:07 +01:00
|
|
|
print("{}: {}".format(datetime.now(), msg))
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2021-06-10 23:45:07 +01:00
|
|
|
def fatal_err(msg):
|
|
|
|
print_log(msg)
|
|
|
|
sys.exit(1)
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2021-12-02 13:13:10 +00:00
|
|
|
|
|
|
|
def hide_sensitive_data(yaml_data, hide_tag="HIDEME"):
|
2022-02-16 04:07:57 +00:00
|
|
|
return "".join(line for line in yaml_data.splitlines(True) if hide_tag not in line)
|
2021-12-02 13:13:10 +00:00
|
|
|
|
|
|
|
|
2021-05-29 01:38:54 +01:00
|
|
|
def generate_lava_yaml(args):
|
2021-06-11 20:04:38 +01:00
|
|
|
# General metadata and permissions, plus also inexplicably kernel arguments
|
|
|
|
values = {
|
|
|
|
'job_name': 'mesa: {}'.format(args.pipeline_info),
|
|
|
|
'device_type': args.device_type,
|
2021-07-07 21:54:43 +01:00
|
|
|
'visibility': { 'group': [ args.visibility_group ] },
|
2021-06-11 20:04:38 +01:00
|
|
|
'priority': 75,
|
|
|
|
'context': {
|
2022-04-05 11:20:11 +01:00
|
|
|
'extra_nfsroot_args': ' init=/init rootwait usbcore.quirks=0bda:8153:k'
|
2021-06-11 20:04:38 +01:00
|
|
|
},
|
|
|
|
'timeouts': {
|
|
|
|
'job': {
|
2021-10-22 15:23:21 +01:00
|
|
|
'minutes': args.job_timeout
|
2021-06-11 20:04:38 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
if args.lava_tags:
|
|
|
|
values['tags'] = args.lava_tags.split(',')
|
|
|
|
|
|
|
|
# URLs to our kernel rootfs to boot from, both generated by the base
|
|
|
|
# container build
|
|
|
|
deploy = {
|
|
|
|
'timeout': { 'minutes': 10 },
|
|
|
|
'to': 'tftp',
|
|
|
|
'os': 'oe',
|
|
|
|
'kernel': {
|
2022-03-17 15:35:30 +00:00
|
|
|
'url': '{}/{}'.format(args.kernel_url_prefix, args.kernel_image_name),
|
2021-06-11 20:04:38 +01:00
|
|
|
},
|
|
|
|
'nfsrootfs': {
|
2022-03-17 15:35:30 +00:00
|
|
|
'url': '{}/lava-rootfs.tgz'.format(args.rootfs_url_prefix),
|
2021-06-11 20:04:38 +01:00
|
|
|
'compression': 'gz',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if args.kernel_image_type:
|
|
|
|
deploy['kernel']['type'] = args.kernel_image_type
|
|
|
|
if args.dtb:
|
|
|
|
deploy['dtb'] = {
|
2022-03-17 15:35:30 +00:00
|
|
|
'url': '{}/{}.dtb'.format(args.kernel_url_prefix, args.dtb)
|
2021-06-11 20:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# always boot over NFS
|
|
|
|
boot = {
|
|
|
|
'timeout': { 'minutes': 25 },
|
|
|
|
'method': args.boot_method,
|
|
|
|
'commands': 'nfs',
|
|
|
|
'prompts': ['lava-shell:'],
|
|
|
|
}
|
|
|
|
|
|
|
|
# skeleton test definition: only declaring each job as a single 'test'
|
|
|
|
# since LAVA's test parsing is not useful to us
|
|
|
|
test = {
|
2021-10-22 15:23:21 +01:00
|
|
|
'timeout': { 'minutes': args.job_timeout },
|
2021-06-11 20:04:38 +01:00
|
|
|
'failure_retry': 1,
|
|
|
|
'definitions': [ {
|
|
|
|
'name': 'mesa',
|
|
|
|
'from': 'inline',
|
2022-04-13 23:23:23 +01:00
|
|
|
'lava-signal': 'kmsg',
|
2021-06-11 20:04:38 +01:00
|
|
|
'path': 'inline/mesa.yaml',
|
|
|
|
'repository': {
|
|
|
|
'metadata': {
|
|
|
|
'name': 'mesa',
|
|
|
|
'description': 'Mesa test plan',
|
|
|
|
'os': [ 'oe' ],
|
|
|
|
'scope': [ 'functional' ],
|
|
|
|
'format': 'Lava-Test Test Definition 1.0',
|
|
|
|
},
|
|
|
|
'parse': {
|
2021-09-15 15:03:16 +01:00
|
|
|
'pattern': r'hwci: (?P<test_case_id>\S*):\s+(?P<result>(pass|fail))'
|
2021-06-11 20:04:38 +01:00
|
|
|
},
|
|
|
|
'run': {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} ],
|
|
|
|
}
|
|
|
|
|
|
|
|
# job execution script:
|
|
|
|
# - inline .gitlab-ci/common/init-stage1.sh
|
|
|
|
# - 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 = []
|
2021-12-02 13:13:10 +00:00
|
|
|
|
2021-06-11 20:04:38 +01:00
|
|
|
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() ]
|
2021-12-02 13:13:10 +00:00
|
|
|
|
|
|
|
with open(args.jwt_file) as jwt_file:
|
|
|
|
init_lines += [
|
|
|
|
"set +x",
|
|
|
|
f'echo -n "{jwt_file.read()}" > "{args.jwt_file}" # HIDEME',
|
|
|
|
"set -x",
|
|
|
|
]
|
|
|
|
|
2021-06-11 20:04:38 +01:00
|
|
|
init_lines += [
|
|
|
|
'mkdir -p {}'.format(args.ci_project_dir),
|
2022-03-17 15:35:30 +00:00
|
|
|
'wget -S --progress=dot:giga -O- {} | tar -xz -C {}'.format(args.build_url, args.ci_project_dir),
|
2021-06-11 20:04:38 +01:00
|
|
|
'wget -S --progress=dot:giga -O- {} | tar -xz -C /'.format(args.job_rootfs_overlay_url),
|
2021-12-02 13:13:10 +00:00
|
|
|
f'echo "export CI_JOB_JWT_FILE={args.jwt_file}" >> /set-job-env-vars.sh',
|
2021-06-11 20:04:38 +01:00
|
|
|
'exec /init-stage2.sh',
|
|
|
|
]
|
|
|
|
test['definitions'][0]['repository']['run']['steps'] = init_lines
|
|
|
|
|
|
|
|
values['actions'] = [
|
|
|
|
{ 'deploy': deploy },
|
|
|
|
{ 'boot': boot },
|
|
|
|
{ 'test': test },
|
|
|
|
]
|
|
|
|
|
|
|
|
return yaml.dump(values, width=10000000)
|
2021-05-29 01:38:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
def setup_lava_proxy():
|
|
|
|
config = lavacli.load_config("default")
|
|
|
|
uri, usr, tok = (config.get(key) for key in ("uri", "username", "token"))
|
|
|
|
uri_obj = urllib.parse.urlparse(uri)
|
|
|
|
uri_str = "{}://{}:{}@{}{}".format(uri_obj.scheme, usr, tok, uri_obj.netloc, uri_obj.path)
|
|
|
|
transport = lavacli.RequestsTransport(
|
|
|
|
uri_obj.scheme,
|
|
|
|
config.get("proxy"),
|
|
|
|
config.get("timeout", 120.0),
|
|
|
|
config.get("verify_ssl_cert", True),
|
|
|
|
)
|
|
|
|
proxy = xmlrpc.client.ServerProxy(
|
|
|
|
uri_str, allow_none=True, transport=transport)
|
|
|
|
|
|
|
|
print_log("Proxy for {} created.".format(config['uri']))
|
|
|
|
|
|
|
|
return proxy
|
|
|
|
|
|
|
|
|
|
|
|
def _call_proxy(fn, *args):
|
|
|
|
retries = 60
|
|
|
|
for n in range(1, retries + 1):
|
|
|
|
try:
|
|
|
|
return fn(*args)
|
|
|
|
except xmlrpc.client.ProtocolError as err:
|
|
|
|
if n == retries:
|
2021-06-10 09:45:54 +01:00
|
|
|
traceback.print_exc()
|
2021-06-10 23:45:07 +01:00
|
|
|
fatal_err("A protocol error occurred (Err {} {})".format(err.errcode, err.errmsg))
|
2021-05-29 01:38:54 +01:00
|
|
|
else:
|
|
|
|
time.sleep(15)
|
|
|
|
except xmlrpc.client.Fault as err:
|
2021-06-10 09:45:54 +01:00
|
|
|
traceback.print_exc()
|
2021-06-10 23:45:07 +01:00
|
|
|
fatal_err("FATAL: Fault: {} (code: {})".format(err.faultString, err.faultCode))
|
2021-05-29 01:38:54 +01:00
|
|
|
|
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
class MesaCIException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class LAVAJob():
|
|
|
|
def __init__(self, proxy, definition):
|
|
|
|
self.job_id = None
|
|
|
|
self.proxy = proxy
|
|
|
|
self.definition = definition
|
|
|
|
self.last_log_line = 0
|
|
|
|
self.last_log_time = None
|
|
|
|
self.is_finished = False
|
|
|
|
|
|
|
|
def heartbeat(self):
|
|
|
|
self.last_log_time = datetime.now()
|
|
|
|
|
2022-03-23 22:26:47 +00:00
|
|
|
def validate(self) -> Optional[dict]:
|
2022-02-16 18:06:20 +00:00
|
|
|
try:
|
|
|
|
return _call_proxy(
|
|
|
|
self.proxy.scheduler.jobs.validate, self.definition, True
|
|
|
|
)
|
|
|
|
except MesaCIException:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def submit(self):
|
|
|
|
try:
|
|
|
|
self.job_id = _call_proxy(self.proxy.scheduler.jobs.submit, self.definition)
|
|
|
|
except MesaCIException:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def cancel(self):
|
|
|
|
if self.job_id:
|
|
|
|
self.proxy.scheduler.jobs.cancel(self.job_id)
|
|
|
|
|
|
|
|
def is_started(self):
|
|
|
|
waiting_states = ["Submitted", "Scheduling", "Scheduled"]
|
|
|
|
job_state = _call_proxy(self.proxy.scheduler.job_state, self.job_id)
|
|
|
|
return job_state["job_state"] not in waiting_states
|
|
|
|
|
|
|
|
def get_logs(self):
|
|
|
|
try:
|
|
|
|
(finished, data) = _call_proxy(
|
|
|
|
self.proxy.scheduler.jobs.logs, self.job_id, self.last_log_line
|
|
|
|
)
|
|
|
|
lines = yaml.load(str(data), Loader=loader(False))
|
|
|
|
self.is_finished = finished
|
|
|
|
if not lines:
|
|
|
|
return []
|
|
|
|
self.heartbeat()
|
|
|
|
self.last_log_line += len(lines)
|
|
|
|
return lines
|
|
|
|
except MesaCIException as mesa_exception:
|
|
|
|
fatal_err(f"Could not get LAVA job logs. Reason: {mesa_exception}")
|
|
|
|
|
|
|
|
|
2021-05-29 01:38:54 +01:00
|
|
|
def get_job_results(proxy, job_id, test_suite, test_case):
|
2021-06-09 14:53:23 +01:00
|
|
|
# Look for infrastructure errors and retry if we see them.
|
2021-05-29 01:38:54 +01:00
|
|
|
results_yaml = _call_proxy(proxy.results.get_testjob_results_yaml, job_id)
|
|
|
|
results = yaml.load(results_yaml, Loader=loader(False))
|
2021-06-09 14:53:23 +01:00
|
|
|
for res in results:
|
2022-02-16 04:07:57 +00:00
|
|
|
metadata = res["metadata"]
|
|
|
|
if "result" not in metadata or metadata["result"] != "fail":
|
2021-06-09 14:53:23 +01:00
|
|
|
continue
|
|
|
|
if 'error_type' in metadata and metadata['error_type'] == "Infrastructure":
|
2022-02-16 18:06:20 +00:00
|
|
|
raise MesaCIException("LAVA job {} failed with Infrastructure Error. Retry.".format(job_id))
|
2021-06-09 15:00:50 +01:00
|
|
|
if 'case' in metadata and metadata['case'] == "validate":
|
2022-02-16 18:06:20 +00:00
|
|
|
raise MesaCIException("LAVA job {} failed validation (possible download error). Retry.".format(job_id))
|
2021-05-29 01:38:54 +01:00
|
|
|
|
|
|
|
results_yaml = _call_proxy(proxy.results.get_testcase_results_yaml, job_id, test_suite, test_case)
|
|
|
|
results = yaml.load(results_yaml, Loader=loader(False))
|
2021-06-07 12:03:24 +01:00
|
|
|
if not results:
|
2022-02-16 18:06:20 +00:00
|
|
|
raise MesaCIException("LAVA: no result for test_suite '{}', test_case '{}'".format(test_suite, test_case))
|
2021-06-07 12:03:24 +01:00
|
|
|
|
|
|
|
print_log("LAVA: result for test_suite '{}', test_case '{}': {}".format(test_suite, test_case, results[0]['result']))
|
|
|
|
if results[0]['result'] != 'pass':
|
2022-02-16 18:06:20 +00:00
|
|
|
return False
|
2021-05-29 01:38:54 +01:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
def show_job_data(job):
|
|
|
|
show = _call_proxy(job.proxy.scheduler.jobs.show, job.job_id)
|
2021-05-29 01:38:54 +01:00
|
|
|
for field, value in show.items():
|
|
|
|
print("{}\t: {}".format(field, value))
|
|
|
|
|
|
|
|
|
2022-04-14 18:58:55 +01:00
|
|
|
def parse_lava_lines(new_lines) -> list[str]:
|
|
|
|
parsed_lines: list[str] = []
|
|
|
|
for line in new_lines:
|
|
|
|
if line["lvl"] in ["results", "feedback"]:
|
|
|
|
continue
|
|
|
|
elif line["lvl"] in ["warning", "error"]:
|
|
|
|
prefix = "\x1b[1;38;5;197m"
|
|
|
|
suffix = "\x1b[0m"
|
|
|
|
elif line["lvl"] == "input":
|
|
|
|
prefix = "$ "
|
|
|
|
suffix = ""
|
|
|
|
else:
|
|
|
|
prefix = ""
|
|
|
|
suffix = ""
|
|
|
|
line = f'{prefix}{line["msg"]}{suffix}'
|
|
|
|
parsed_lines.append(line)
|
|
|
|
|
|
|
|
return parsed_lines
|
|
|
|
|
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
def follow_job_execution(job):
|
2021-06-10 09:42:40 +01:00
|
|
|
try:
|
2022-02-16 18:06:20 +00:00
|
|
|
job.submit()
|
|
|
|
except MesaCIException as mesa_exception:
|
|
|
|
fatal_err(f"Could not submit LAVA job. Reason: {mesa_exception}")
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
print_log(f"Waiting for job {job.job_id} to start.")
|
|
|
|
while not job.is_started():
|
|
|
|
time.sleep(WAIT_FOR_DEVICE_POLLING_TIME_SEC)
|
|
|
|
print_log(f"Job {job.job_id} started.")
|
|
|
|
|
|
|
|
max_idle_time = timedelta(seconds=DEVICE_HANGING_TIMEOUT_SEC)
|
|
|
|
# Start to check job's health
|
|
|
|
job.heartbeat()
|
|
|
|
while not job.is_finished:
|
|
|
|
# Poll to check for new logs, assuming that a prolonged period of
|
|
|
|
# silence means that the device has died and we should try it again
|
|
|
|
if datetime.now() - job.last_log_time > max_idle_time:
|
|
|
|
print_log(
|
|
|
|
f"No log output for {max_idle_time} seconds; assuming device has died, retrying"
|
|
|
|
)
|
|
|
|
|
|
|
|
raise MesaCIException(
|
|
|
|
f"LAVA job {job.job_id} does not respond for {max_idle_time}. Retry."
|
|
|
|
)
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
time.sleep(LOG_POLLING_TIME_SEC)
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
new_lines = job.get_logs()
|
2022-04-14 18:58:55 +01:00
|
|
|
parsed_lines = parse_lava_lines(new_lines)
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2022-04-14 18:58:55 +01:00
|
|
|
for line in parsed_lines:
|
2022-02-16 18:06:20 +00:00
|
|
|
print(line)
|
2021-09-10 16:58:27 +01:00
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
show_job_data(job)
|
|
|
|
return get_job_results(job.proxy, job.job_id, "0_mesa", "mesa")
|
2021-09-10 16:58:27 +01:00
|
|
|
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
def retriable_follow_job(proxy, job_definition):
|
|
|
|
retry_count = NUMBER_OF_RETRIES_TIMEOUT_DETECTION
|
2022-02-16 04:07:57 +00:00
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
for attempt_no in range(1, retry_count + 2):
|
|
|
|
job = LAVAJob(proxy, job_definition)
|
|
|
|
try:
|
|
|
|
return follow_job_execution(job)
|
|
|
|
except MesaCIException as mesa_exception:
|
|
|
|
print_log(mesa_exception)
|
|
|
|
job.cancel()
|
|
|
|
finally:
|
|
|
|
print_log(f"Finished executing LAVA job in the attempt #{attempt_no}")
|
|
|
|
|
|
|
|
fatal_err(
|
|
|
|
"Job failed after it exceeded the number of "
|
|
|
|
f"{NUMBER_OF_RETRIES_TIMEOUT_DETECTION} retries."
|
|
|
|
)
|
2022-02-16 04:07:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main(args):
|
|
|
|
proxy = setup_lava_proxy()
|
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
job_definition = generate_lava_yaml(args)
|
2022-02-16 04:07:57 +00:00
|
|
|
|
|
|
|
if args.dump_yaml:
|
2022-02-16 18:06:20 +00:00
|
|
|
print("LAVA job definition (YAML):")
|
|
|
|
print(hide_sensitive_data(job_definition))
|
2022-03-23 01:02:59 +00:00
|
|
|
job = LAVAJob(proxy, job_definition)
|
|
|
|
|
|
|
|
if errors := job.validate():
|
|
|
|
fatal_err(f"Error in LAVA job definition: {errors}")
|
|
|
|
print_log("LAVA job definition validated successfully")
|
2022-02-16 04:07:57 +00:00
|
|
|
|
|
|
|
if args.validate_only:
|
|
|
|
return
|
|
|
|
|
2022-02-16 18:06:20 +00:00
|
|
|
ret = retriable_follow_job(proxy, job_definition)
|
|
|
|
sys.exit(ret)
|
2022-02-16 04:07:57 +00:00
|
|
|
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2021-12-02 13:13:10 +00:00
|
|
|
def create_parser():
|
2021-05-29 01:38:54 +01:00
|
|
|
parser = argparse.ArgumentParser("LAVA job submitter")
|
|
|
|
|
|
|
|
parser.add_argument("--pipeline-info")
|
2022-03-17 15:35:30 +00:00
|
|
|
parser.add_argument("--rootfs-url-prefix")
|
|
|
|
parser.add_argument("--kernel-url-prefix")
|
|
|
|
parser.add_argument("--build-url")
|
2021-06-10 17:00:32 +01:00
|
|
|
parser.add_argument("--job-rootfs-overlay-url")
|
2021-10-22 15:23:21 +01:00
|
|
|
parser.add_argument("--job-timeout", type=int)
|
2021-06-11 20:04:38 +01:00
|
|
|
parser.add_argument("--first-stage-init")
|
|
|
|
parser.add_argument("--ci-project-dir")
|
2021-05-29 01:38:54 +01:00
|
|
|
parser.add_argument("--device-type")
|
|
|
|
parser.add_argument("--dtb", nargs='?', default="")
|
|
|
|
parser.add_argument("--kernel-image-name")
|
|
|
|
parser.add_argument("--kernel-image-type", nargs='?', default="")
|
|
|
|
parser.add_argument("--boot-method")
|
|
|
|
parser.add_argument("--lava-tags", nargs='?', default="")
|
2021-12-02 13:13:10 +00:00
|
|
|
parser.add_argument("--jwt-file", type=pathlib.Path)
|
2021-06-10 09:42:40 +01:00
|
|
|
parser.add_argument("--validate-only", action='store_true')
|
2021-06-10 10:35:21 +01:00
|
|
|
parser.add_argument("--dump-yaml", action='store_true')
|
2021-07-07 21:54:43 +01:00
|
|
|
parser.add_argument("--visibility-group")
|
2021-05-29 01:38:54 +01:00
|
|
|
|
2021-12-02 13:13:10 +00:00
|
|
|
return parser
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# given that we proxy from DUT -> LAVA dispatcher -> LAVA primary -> us ->
|
|
|
|
# GitLab runner -> GitLab primary -> user, safe to say we don't need any
|
|
|
|
# more buffering
|
|
|
|
sys.stdout.reconfigure(line_buffering=True)
|
|
|
|
sys.stderr.reconfigure(line_buffering=True)
|
|
|
|
|
|
|
|
parser = create_parser()
|
|
|
|
|
2021-05-29 01:38:54 +01:00
|
|
|
parser.set_defaults(func=main)
|
|
|
|
args = parser.parse_args()
|
|
|
|
args.func(args)
|