from .misc import read_config
from .nuke import nuke
from .run_tasks import run_tasks
+from .repo_utils import fetch_qa_suite
from .results import email_results
yaml.safe_dump(info, f, default_flow_style=False)
+def fetch_tasks_if_needed(job_config):
+ """
+ Fetch the suite repo (and include it in sys.path) so that we can use its
+ tasks.
+ """
+ # Any scheduled job will already have the suite checked out and its
+ # $PYTHONPATH set. We can check for this by looking for 'suite_path'
+ # in its config.
+ suite_path = job_config.get('suite_path')
+ if suite_path:
+ return
+
+ ceph_branch = job_config.get('branch', 'master')
+ suite_branch = job_config.get('suite_branch', ceph_branch)
+ suite_path = fetch_qa_suite(suite_branch)
+ sys.path.insert(1, suite_path)
+ job_config['suite_path'] = suite_path
+
+
def main(ctx):
set_up_logging(ctx)
log = logging.getLogger(__name__)
ctx.config['tasks'][:0] = init_tasks
+ fetch_tasks_if_needed(ctx.config)
+
try:
run_tasks(tasks=ctx.config['tasks'], ctx=ctx)
finally:
# last-in-suite jobs don't have suite_branch or branch set.
ceph_branch = job_config.get('branch', 'master')
suite_branch = job_config.get('suite_branch', ceph_branch)
- suite_path = fetch_qa_suite(suite_branch)
+ job_config['suite_path'] = fetch_qa_suite(suite_branch)
except BranchNotFoundError:
log.exception(
"Branch not found; throwing job away")
log.info('Creating archive dir %s', archive_path_full)
safepath.makedirs(ctx.archive_dir, safe_archive)
log.info('Running job %d', job.jid)
- run_job(job_config, teuth_bin_path, suite_path)
+ run_job(job_config, teuth_bin_path)
job.delete()
report.try_push_job_info(job_info, dict(status='dead'))
-def run_job(job_config, teuth_bin_path, suite_path):
+def run_job(job_config, teuth_bin_path):
+ suite_path = job_config['suite_path']
arg = [
os.path.join(teuth_bin_path, 'teuthology'),
]