From 204915a2726535b0f6581a24f45840d2be87d137 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 16 Dec 2016 15:53:47 -0500 Subject: [PATCH] suite: take shorthand repo, user/repo for --suite-repo and --ceph-repo args Signed-off-by: Sage Weil --- scripts/test/test_suite.py | 17 +++++++++++++++++ teuthology/suite/__init__.py | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/scripts/test/test_suite.py b/scripts/test/test_suite.py index 062aba470d..79ed4a01f7 100644 --- a/scripts/test/test_suite.py +++ b/scripts/test/test_suite.py @@ -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" diff --git a/teuthology/suite/__init__.py b/teuthology/suite/__init__.py index fc82598c0f..bc272849ae 100644 --- a/teuthology/suite/__init__.py +++ b/teuthology/suite/__init__.py @@ -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) -- 2.39.5