]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite: add --suite-repo option
authorZack Cerza <zack@redhat.com>
Wed, 30 Nov 2016 20:58:42 +0000 (13:58 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 2 Dec 2016 17:27:10 +0000 (10:27 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
scripts/suite.py
teuthology/suite/placeholder.py
teuthology/suite/run.py
teuthology/suite/test/test_placeholder.py
teuthology/suite/test/test_util.py
teuthology/suite/util.py

index c5a49bc537ac749dcbfcb71b1239cbaba55d3a6f..76d1e5d1218f08401c6dd62af1cada24d8180611 100644 (file)
@@ -57,6 +57,8 @@ Standard arguments:
                               Distribution to run against
   -D <distroversion>, --distro-version <distroversion>
                               Distro version to run against
+  --suite-repo <suite_repo>   Use tasks and suite definition in this repository
+                              [default: {default_suite_repo}]
   --suite-branch <suite_branch>
                               Use this suite branch instead of the ceph branch
   --suite-dir <suite_dir>     Use this alternative directory as-is when
@@ -117,8 +119,11 @@ Scheduler arguments:
                               'fail', 'pass', 'queued', 'running', 'waiting'
                               [default: fail,dead]
 
-""".format(default_machine_type=config.default_machine_type,
-           default_results_timeout=config.results_timeout)
+""".format(
+    default_machine_type=config.default_machine_type,
+    default_results_timeout=config.results_timeout,
+    default_suite_repo=config.get_ceph_qa_suite_git_url(),
+)
 
 
 def main(argv=sys.argv[1:]):
index d10a0d08066f96199672b40fffc3dd201a4ac81f..fe068c94070ff33b1d7dd7c26677b0e87210c237 100644 (file)
@@ -96,6 +96,7 @@ dict_templ = {
         }
     },
     'suite': Placeholder('suite'),
+    'suite_repo': Placeholder('suite_repo'),
     'suite_branch': Placeholder('suite_branch'),
     'suite_sha1': Placeholder('suite_hash'),
     'tasks': [],
index 0763cab71213267b910236a142171e45dd41ed88..13225f70e257a55160fad8e7beb003a4132fb21b 100644 (file)
@@ -36,6 +36,10 @@ class Run(object):
         """
         self.args = args
         self.name = self.make_run_name()
+
+        if self.args.suite_repo:
+            config.ceph_qa_suite_git_url = self.args.suite_repo
+
         self.base_config = self.create_initial_config()
         # caches package versions to minimize requests to gbs
         self.package_versions = dict()
@@ -102,6 +106,7 @@ class Run(object):
             distro_version=self.args.distro_version,
             archive_upload=config.archive_upload,
             archive_upload_key=config.archive_upload_key,
+            suite_repo=config.get_ceph_qa_suite_git_url(),
         )
         return self.build_base_config()
 
@@ -189,30 +194,50 @@ class Run(object):
         log.info("teuthology branch: %s", teuthology_branch)
         return teuthology_branch
 
+    @property
+    def suite_repo_name(self):
+        if self.args.suite_repo:
+            return self.args.suite_repo.split('/')[-1].rstrip('.git')
+        else:
+            return 'ceph-qa-suite'
+
     def choose_suite_branch(self):
+        suite_repo_name = self.suite_repo_name
+        suite_repo_project_or_url = self.args.suite_repo or 'ceph-qa-suite'
         suite_branch = self.args.suite_branch
         ceph_branch = self.args.ceph_branch
         if suite_branch and suite_branch != 'master':
-            if not util.git_branch_exists('ceph-qa-suite', suite_branch):
-                exc = BranchNotFoundError(suite_branch, 'ceph-qa-suite.git')
+            if not util.git_branch_exists(
+                suite_repo_project_or_url,
+                suite_branch
+            ):
+                exc = BranchNotFoundError(suite_branch, suite_repo_name)
                 util.schedule_fail(message=str(exc), name=self.name)
         elif not suite_branch:
-            # Decide what branch of ceph-qa-suite to use
-            if util.git_branch_exists('ceph-qa-suite', ceph_branch):
+            # Decide what branch of the suite repo to use
+            if util.git_branch_exists(suite_repo_project_or_url, ceph_branch):
                 suite_branch = ceph_branch
             else:
                 log.info(
-                    "branch {0} not in ceph-qa-suite.git; will use master for"
-                    " ceph-qa-suite".format(ceph_branch))
+                    "branch {0} not in {1}; will use master for"
+                    " ceph-qa-suite".format(
+                        ceph_branch,
+                        suite_repo_name
+                    ))
                 suite_branch = 'master'
         return suite_branch
 
     def choose_suite_hash(self, suite_branch):
-        suite_hash = util.git_ls_remote('ceph-qa-suite', suite_branch)
+        suite_repo_name = self.suite_repo_name
+        suite_repo_project_or_url = self.args.suite_repo or 'ceph-qa-suite'
+        suite_hash = util.git_ls_remote(
+            suite_repo_project_or_url,
+            suite_branch
+        )
         if not suite_hash:
-            exc = BranchNotFoundError(suite_branch, 'ceph-qa-suite.git')
+            exc = BranchNotFoundError(suite_branch, suite_repo_name)
             util.schedule_fail(message=str(exc), name=self.name)
-        log.info("ceph-qa-suite branch: %s %s", suite_branch, suite_hash)
+        log.info("%s branch: %s %s", suite_repo_name, suite_branch, suite_hash)
         return suite_hash
 
     def build_base_config(self):
index 51683e642095bec1e293a4e96c13e94e32853584..03d04d35da6c035b3c3ae7ec41b6c5ea0a94c808 100644 (file)
@@ -18,6 +18,7 @@ class TestPlaceholder(object):
             distro_version='distro_version',
             archive_upload='archive_upload',
             archive_upload_key='archive_upload_key',
+            suite_repo='https://example.com/ceph/suite.git',
         )
         output_dict = substitute_placeholders(dict_templ, input_dict)
         assert output_dict['suite'] == 'suite'
@@ -40,6 +41,7 @@ class TestPlaceholder(object):
             archive_upload_key='archive_upload_key',
             distro=None,
             distro_version=None,
+            suite_repo='https://example.com/ceph/suite.git',
         )
         output_dict = substitute_placeholders(dict_templ, input_dict)
         assert 'os_type' not in output_dict
index ae46dc9f8a57b8e6ab3e1da13021431ba3a0cc18..c587a205c6ed37242163945939d9f676d0e1f4d4 100644 (file)
@@ -10,12 +10,20 @@ from teuthology.orchestra.opsys import OS
 from teuthology.suite import util
 
 
+REPO_PROJECTS_AND_URLS = [
+    'ceph',
+    'https://github.com/not_ceph/ceph.git',
+]
+
+
+@pytest.mark.parametrize('project_or_url', REPO_PROJECTS_AND_URLS)
 @patch('subprocess.check_output')
-def test_git_branch_exists(m_check_output):
+def test_git_branch_exists(m_check_output, project_or_url):
     m_check_output.return_value = ''
-    assert False == util.git_branch_exists('ceph', 'nobranchnowaycanthappen')
+    assert False == util.git_branch_exists(
+        project_or_url, 'nobranchnowaycanthappen')
     m_check_output.return_value = 'HHH branch'
-    assert True == util.git_branch_exists('ceph', 'master')
+    assert True == util.git_branch_exists(project_or_url, 'master')
 
 
 @pytest.fixture
index 8d372769f1965ac9fa846bfbba68f8c5eed15adc..2538c12b08a60a42ef6b1d304fa13c7341651d8b 100644 (file)
@@ -169,13 +169,20 @@ def get_distro_defaults(distro, machine_type):
     )
 
 
-def git_ls_remote(project, branch, project_owner='ceph'):
+def git_ls_remote(project_or_url, branch, project_owner='ceph'):
     """
     Find the latest sha1 for a given project's branch.
 
+    :param project_or_url: Either a project name or a full URL
+    :param branch:         The branch to query
+    :param project_owner:  The GitHub project owner. Only used when a project
+                           name is passed; not when a URL is passed
     :returns: The sha1 if found; else None
     """
-    url = build_git_url(project, project_owner)
+    if '://' in project_or_url:
+        url = project_or_url
+    else:
+        url = build_git_url(project_or_url, project_owner)
     return repo_utils.ls_remote(url, branch)
 
 
@@ -205,11 +212,16 @@ def git_validate_sha1(project, sha1, project_owner='ceph'):
     return None
 
 
-def git_branch_exists(project, branch, project_owner='ceph'):
+def git_branch_exists(project_or_url, branch, project_owner='ceph'):
     """
     Query the git repository to check the existence of a project's branch
+
+    :param project_or_url: Either a project name or a full URL
+    :param branch:         The branch to query
+    :param project_owner:  The GitHub project owner. Only used when a project
+                           name is passed; not when a URL is passed
     """
-    return git_ls_remote(project, branch, project_owner) is not None
+    return git_ls_remote(project_or_url, branch, project_owner) is not None
 
 
 def get_branch_info(project, branch, project_owner='ceph'):