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__)
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']
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)
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,
)
+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):
"""
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))
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):
"""
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,
)
-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.