From 88d26e4ae4406853a73e50eb29999c2a8e59c306 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 25 Jun 2014 14:59:38 -0600 Subject: [PATCH] Handle ceph-qa-suite checkouts Previously we had an internally-maintained shell script that did this. Signed-off-by: Zack Cerza --- scripts/suite.py | 2 -- teuthology/suite.py | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/scripts/suite.py b/scripts/suite.py index 1842890c..a30a6e18 100644 --- a/scripts/suite.py +++ b/scripts/suite.py @@ -23,8 +23,6 @@ Miscellaneous arguments: Standard arguments: Optional extra job yaml to include - --base Base directory for the suite - e.g. ~/src/ceph-qa-suite/suites -s , --suite The suite to schedule -c , --ceph The ceph branch to run against diff --git a/teuthology/suite.py b/teuthology/suite.py index e5e2ed63..62a8e316 100644 --- a/teuthology/suite.py +++ b/teuthology/suite.py @@ -17,8 +17,9 @@ from email.mime.text import MIMEText from tempfile import NamedTemporaryFile import teuthology -from teuthology import lock as lock -from teuthology.config import config +from . import lock +from .config import config +from .repo_utils import checkout_repo, BranchNotFoundError log = logging.getLogger(__name__) @@ -30,9 +31,6 @@ def main(args): dry_run = args['--dry-run'] base_yaml_paths = args[''] - base = os.path.expanduser(args['--base']) - if not os.path.exists(base): - schedule_fail("Base directory not found: {dir}".format(dir=base)) suite = args['--suite'] nice_suite = suite.replace('/', ':') ceph_branch = args['--ceph'] @@ -54,6 +52,9 @@ def main(args): name = make_run_name(nice_suite, ceph_branch, kernel_branch, kernel_flavor, machine_type) + + suite_repo_path = fetch_suite_repo(ceph_branch, test_name=name) + config_string = create_initial_config(nice_suite, ceph_branch, teuthology_branch, kernel_branch, kernel_flavor, distro, machine_type) @@ -67,7 +68,7 @@ def main(args): name=name, suite=suite, machine_type=machine_type, - base=base, + suite_repo_path=suite_repo_path, base_yaml_paths=base_yaml_paths, email=email, priority=priority, @@ -99,6 +100,27 @@ def make_run_name(suite, ceph_branch, kernel_branch, kernel_flavor, ) +def fetch_suite_repo(branch, test_name): + """ + Fetch the suite repo so we can use it to build jobs + + :returns: The path to the repo on disk + """ + src_base_path = os.path.expanduser('~/src') + if not os.path.exists(src_base_path): + os.mkdir(src_base_path) + suite_repo_path = os.path.join(src_base_path, + 'ceph-qa-suite_' + branch) + try: + checkout_repo( + repo_url=os.path.join(config.ceph_git_base_url, 'ceph-qa-suite'), + dest_path=suite_repo_path, + branch=branch) + except BranchNotFoundError as exc: + schedule_fail(message=str(exc), name=test_name) + return suite_repo_path + + def create_initial_config(nice_suite, ceph_branch, teuthology_branch, kernel_branch, kernel_flavor, distro, machine_type): """ @@ -119,7 +141,7 @@ def create_initial_config(nice_suite, ceph_branch, teuthology_branch, kernel_hash = get_hash('kernel', kernel_branch, kernel_flavor, machine_type) if not kernel_hash: - schedule_fail(message="Kernel branch '{branch} not found".format( + schedule_fail(message="Kernel branch '{branch}' not found".format( branch=kernel_branch)) if kernel_hash: log.info("kernel sha1: {hash}".format(hash=kernel_hash)) @@ -176,7 +198,7 @@ def create_initial_config(nice_suite, ceph_branch, teuthology_branch, return config_template.format(**config_input) -def prepare_and_schedule(owner, name, suite, machine_type, base, +def prepare_and_schedule(owner, name, suite, machine_type, suite_repo_path, base_yaml_paths, email, priority, limit, num, timeout, dry_run, verbose): """ @@ -200,7 +222,7 @@ def prepare_and_schedule(owner, name, suite, machine_type, base, if owner: base_args.extend(['--owner', owner]) - suite_path = os.path.join(base, suite) + suite_path = os.path.join(suite_repo_path, 'suites', suite) num_jobs = schedule_suite( name=suite, @@ -228,7 +250,7 @@ def prepare_and_schedule(owner, name, suite, machine_type, base, ) -def schedule_fail(message, name=None): +def schedule_fail(message, name=''): """ If an email address has been specified anywhere, send an alert there. Then raise a ScheduleFailError. -- 2.47.3