From d33ff066fa62cb7fc3f3f414afaace15bf2944bc Mon Sep 17 00:00:00 2001 From: Marios Andreou Date: Fri, 22 Feb 2019 14:36:02 +0200 Subject: [PATCH] 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 --- tripleo_repos/main.py | 29 ++++++++++++++++++++++++++--- tripleo_repos/tests/test_main.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/tripleo_repos/main.py b/tripleo_repos/main.py index 6d2370a..3ec66d1 100755 --- a/tripleo_repos/main.py +++ b/tripleo_repos/main.py @@ -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') diff --git a/tripleo_repos/tests/test_main.py b/tripleo_repos/tests/test_main.py index 374b4b8..1f460b4 100644 --- a/tripleo_repos/tests/test_main.py +++ b/tripleo_repos/tests/test_main.py @@ -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