Add tripleo-ci-testing to tripleo-repos for use in periodics

For periodic containers build job tripleo-ci-testing makes more
sense than current. Used by [1] and tracked in [2]. The actual
tripleo-ci-testing repo is specified by [3] in rdo config.
You can see a test review in [4] which runs the periodic container
build job in check with this code.

[1] https://review.openstack.org/638652
[2] https://tree.taiga.io/project/tripleo-ci-board/task/773
[3] https://review.rdoproject.org/r/#/c/18975/
[4] https://review.rdoproject.org/r/19000
Change-Id: I5effd0e77215109720370f470a8fe4e444048afc
This commit is contained in:
Marios Andreou 2019-02-22 14:36:02 +02:00
parent 70e30aa6d3
commit d33ff066fa
2 changed files with 54 additions and 3 deletions

View File

@ -85,7 +85,8 @@ def _parse_args():
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('repos', metavar='REPO', nargs='+',
choices=['current', 'deps', 'current-tripleo',
'current-tripleo-dev', 'ceph', 'opstools'],
'current-tripleo-dev', 'ceph', 'opstools',
'tripleo-ci-testing'],
help='A list of repos. Available repos: '
'%(choices)s. The deps repo will always be '
'included when using current or '
@ -141,10 +142,11 @@ def _validate_distro_repos(args):
"""Validate requested repos are valid for the distro"""
valid_repos = []
if 'fedora' in args.distro:
valid_repos = ['current', 'current-tripleo', 'ceph', 'deps']
valid_repos = ['current', 'current-tripleo', 'ceph', 'deps',
'tripleo-ci-testing']
elif args.distro in ['centos7']:
valid_repos = ['ceph', 'current', 'current-tripleo',
'current-tripleo-dev', 'deps']
'current-tripleo-dev', 'deps', 'tripleo-ci-testing']
invalid_repos = [x for x in args.repos if x not in valid_repos]
if len(invalid_repos) > 0:
raise InvalidArguments('{} repo(s) are not valid for {}. Valid repos '
@ -171,9 +173,25 @@ def _validate_current_tripleo(repos):
return True
def _validate_tripleo_ci_testing(repos):
"""Validate tripleo-ci-testing
With tripleo-ci-testing for repo (currently only periodic container build)
no other repos expected except optionally deps which is enabled regardless.
"""
if 'tripleo-ci-testing' in repos and len(repos) > 1:
if 'deps' in repos and len(repos) == 2:
return True
else:
raise InvalidArguments('Cannot use tripleo-ci-testing at the '
'same time as other repos, except deps.')
return True
def _validate_args(args):
_validate_current_tripleo(args.repos)
_validate_distro_repos(args)
_validate_tripleo_ci_testing(args.repos)
def _remove_existing(args):
@ -266,6 +284,11 @@ def _install_repos(args, base_path):
content += '\n%s' % INCLUDE_PKGS
content = _change_priority(content, 10)
_write_repo(content, args.output_path)
elif repo == 'tripleo-ci-testing':
content = _get_repo(base_path + 'tripleo-ci-testing/delorean.repo',
args)
_write_repo(content, args.output_path)
install_deps(args, base_path)
elif repo == 'ceph':
if args.branch in ['liberty', 'mitaka']:
content = _create_ceph(args, 'hammer')

View File

@ -236,6 +236,25 @@ class TestTripleORepos(testtools.TestCase):
'priority=10' %
main.INCLUDE_PKGS, 'test')
@mock.patch('tripleo_repos.main._get_repo')
@mock.patch('tripleo_repos.main._write_repo')
def test_install_repos_tripleo_ci_testing(self, mock_write, mock_get):
args = mock.Mock()
args.repos = ['tripleo-ci-testing']
args.branch = 'master'
args.output_path = 'test'
mock_get.return_value = '[delorean]\nMr. Fusion'
main._install_repos(args, 'roads/')
self.assertEqual([mock.call('roads/tripleo-ci-testing/delorean.repo',
args),
mock.call('roads/delorean-deps.repo', args),
],
mock_get.mock_calls)
self.assertEqual([mock.call('[delorean]\nMr. Fusion', 'test'),
mock.call('[delorean]\nMr. Fusion', 'test'),
],
mock_write.mock_calls)
@mock.patch('tripleo_repos.main._write_repo')
@mock.patch('tripleo_repos.main._create_ceph')
def test_install_repos_ceph(self, mock_create_ceph, mock_write_repo):
@ -447,6 +466,15 @@ class TestValidate(testtools.TestCase):
self.assertRaises(main.InvalidArguments, main._validate_args,
self.args)
def test_tripleo_ci_testing_and_current_tripleo(self):
self.args.repos = ['current-tripleo', 'tripleo-ci-testing']
self.assertRaises(main.InvalidArguments, main._validate_args,
self.args)
def test_tripleo_ci_testing_and_deps_allowed(self):
self.args.repos = ['deps', 'tripleo-ci-testing']
main._validate_args(self.args)
def test_ceph_and_tripleo_dev(self):
self.args.repos = ['current-tripleo-dev', 'ceph']
self.args.output_path = main.DEFAULT_OUTPUT_PATH