+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"
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
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)