]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite: take shorthand repo, user/repo for --suite-repo and --ceph-repo args
authorSage Weil <sage@redhat.com>
Fri, 16 Dec 2016 20:53:47 +0000 (15:53 -0500)
committerSage Weil <sage@redhat.com>
Fri, 16 Dec 2016 20:53:47 +0000 (15:53 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
scripts/test/test_suite.py
teuthology/suite/__init__.py

index 062aba470d7b234b10a474ec58fb0ea5cf2670e4..79ed4a01f794bb775282f1b310b632169bb550be 100644 (file)
@@ -1,5 +1,22 @@
+import docopt
 from script import Script
+from scripts import suite
+
+doc = suite.__doc__
 
 
 class TestSuite(Script):
     script_name = 'teuthology-suite'
+
+    def test_repo(self):
+        assert suite.expand_short_repo_name('foo', 'https://github.com/ceph/ceph-ci.git') == 'https://github.com/ceph/foo'
+        assert suite.expand_short_repo_name('foo/bar', 'https://github.com/ceph/ceph-ci.git') == 'https://github.com/foo/bar'
+    
+    def test_args(self):
+        args = docopt.docopt(doc, [
+            "--ceph-repo", "foo",
+            "--suite-repo", "foo/bar"
+        ])
+        conf = suite.process_args(args)
+        assert args["ceph_repo"] == "https://github.com/ceph/foo"
+        assert args["suite_repo"] == "https://github.com/foo/bar"
index fc82598c0f67a07c5efb1101435318ba4bd89dd7..bc272849ae47d13d1edb7c36496da292667fab59 100644 (file)
@@ -47,6 +47,14 @@ def process_args(args):
                 value = []
             else:
                 value = [x.strip() for x in value.split(',')]
+        elif key == 'ceph_repo':
+            value = expand_short_repo_name(
+                value,
+                config.get_ceph_git_url())
+        elif key == 'suite_repo':
+            value = expand_short_repo_name(
+                value,
+                config.get_ceph_qa_suite_git_url())
         conf[key] = value
     return conf
 
@@ -54,6 +62,21 @@ def process_args(args):
 def normalize_suite_name(name):
     return name.replace('/', ':')
 
+def expand_short_repo_name(name, orig):
+    # Allow shortname repo name 'foo' or 'foo/bar'.  This works with
+    # github URLs, e.g.
+    #
+    #   foo -> https://github.com/ceph/foo
+    #   foo/bar -> https://github.com/foo/bar
+    #
+    # when the orig URL is also github.  The two-level substitution may not
+    # work with some configs.
+    name_vec = name.split('/')
+    if len(name_vec) < 2 and name.count(':') == 0:
+        orig_vec = orig.split('/')
+        return '/'.join(orig_vec[:-len(name_vec)] + name_vec)
+    # otherwise, assume a full URL
+    return name
 
 def main(args):
     conf = process_args(args)