From 1f957a6a9ea3a78eeabf2d5f88004bfb679bab91 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 6 Aug 2014 16:50:13 -0600 Subject: [PATCH] For non-scheduled jobs, check out the suite repo. Signed-off-by: Zack Cerza --- teuthology/run.py | 22 ++++++++++++++++++++++ teuthology/worker.py | 7 ++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/teuthology/run.py b/teuthology/run.py index 672cdf5ec4..373bffe267 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -12,6 +12,7 @@ from .misc import get_user 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 @@ -65,6 +66,25 @@ def write_initial_metadata(ctx): 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__) @@ -148,6 +168,8 @@ def main(ctx): ctx.config['tasks'][:0] = init_tasks + fetch_tasks_if_needed(ctx.config) + try: run_tasks(tasks=ctx.config['tasks'], ctx=ctx) finally: diff --git a/teuthology/worker.py b/teuthology/worker.py index 31faacdd81..95945a77b8 100644 --- a/teuthology/worker.py +++ b/teuthology/worker.py @@ -119,7 +119,7 @@ def main(ctx): # 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") @@ -159,7 +159,7 @@ def main(ctx): 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() @@ -218,7 +218,8 @@ def run_with_watchdog(process, job_config): 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'), ] -- 2.39.5