]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Handle ceph-qa-suite checkouts
authorZack Cerza <zack@cerza.org>
Wed, 25 Jun 2014 20:59:38 +0000 (14:59 -0600)
committerZack Cerza <zack@cerza.org>
Fri, 27 Jun 2014 16:14:06 +0000 (10:14 -0600)
Previously we had an internally-maintained shell script that did this.

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/suite.py
teuthology/suite.py

index 1842890c5b442ca77e3604242ed2a6660a8333fc..a30a6e183d6b65ebbe55191efbfaddfab7d7c420 100644 (file)
@@ -23,8 +23,6 @@ Miscellaneous arguments:
 
 Standard arguments:
   <config_yaml>               Optional extra job yaml to include
-  --base <base>               Base directory for the suite
-                              e.g. ~/src/ceph-qa-suite/suites
   -s <suite>, --suite <suite>
                               The suite to schedule
   -c <ceph>, --ceph <ceph>    The ceph branch to run against
index e5e2ed634697ef799aaadebfb3bfa8db530e3bb8..62a8e31601dde98905fd8e73fffbfe9789275964 100644 (file)
@@ -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['<config_yaml>']
-    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.