From 6a201c7de813509f42d2583ade36ee86f6b9a8f4 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 27 Feb 2017 16:29:40 +0800 Subject: [PATCH] qa/tasks/workunit: use ceph.git as an alternative of ceph-ci.git for workunit repo if we run upgrade test, where, for example, "jewel" is not in ceph-ci.git repo, we should check ceph.git to clone the workunits. Signed-off-by: Kefu Chai --- qa/tasks/workunit.py | 62 ++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/qa/tasks/workunit.py b/qa/tasks/workunit.py index 2720363b4f98d0..cf5b143a421d42 100644 --- a/qa/tasks/workunit.py +++ b/qa/tasks/workunit.py @@ -309,23 +309,53 @@ def _run_tests(ctx, refspec, role, tests, env, subdir=None, timeout=None): srcdir = '{cdir}/qa/workunits'.format(cdir=clonedir) git_url = teuth_config.get_ceph_qa_suite_git_url() - remote.run( - logger=log.getChild(role), - args=[ - 'rm', - '-rf', - clonedir, - run.Raw('&&'), - 'git', - 'clone', + # if we are running an upgrade test, and ceph-ci does not have branches like + # `jewel`, so should use ceph.git as an alternative. + try: + remote.run( + logger=log.getChild(role), + args=[ + 'rm', + '-rf', + clonedir, + run.Raw('&&'), + 'git', + 'clone', + git_url, + clonedir, + run.Raw('&&'), + 'cd', '--', clonedir, + run.Raw('&&'), + 'git', 'checkout', refspec, + ], + ) + except CommandFailedError: + if not git_url.endswith('/ceph-ci.git'): + raise + alt_git_url = git_url.replace('/ceph-ci.git', '/ceph.git') + log.info( + "failed to check out '%s' from %s; will also try in %s", + refspec, git_url, - clonedir, - run.Raw('&&'), - 'cd', '--', clonedir, - run.Raw('&&'), - 'git', 'checkout', refspec, - ], - ) + alt_git_url, + ) + remote.run( + logger=log.getChild(role), + args=[ + 'rm', + '-rf', + clonedir, + run.Raw('&&'), + 'git', + 'clone', + git_url, + clonedir, + run.Raw('&&'), + 'cd', '--', clonedir, + run.Raw('&&'), + 'git', 'checkout', refspec, + ], + ) remote.run( logger=log.getChild(role), args=[