From b025445fa30a94c8e3383c68900cceb8a8266867 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Wed, 29 Jun 2016 16:47:07 -0700 Subject: [PATCH] GitbuilderProject: allow setting tag or ref in config dict Precedence: ref, tag, branch, sha1. (this is debatable.) Also change log.debug() default-to-master to log.warning() Signed-off-by: Dan Mick --- teuthology/packaging.py | 13 +++++++++---- teuthology/test/test_packaging.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/teuthology/packaging.py b/teuthology/packaging.py index d253bbb8f5..f4afd54dcd 100644 --- a/teuthology/packaging.py +++ b/teuthology/packaging.py @@ -474,6 +474,7 @@ class GitbuilderProject(object): self.codename = self.job_config.get("codename") self.os_version = self._get_version() self.branch = self.job_config.get("branch") + self.tag = self.job_config.get("tag") self.ref = self.job_config.get("ref") self.distro = self._get_distro( distro=self.os_type, @@ -643,19 +644,23 @@ class GitbuilderProject(object): self.job_config, 'branch') sha1 = _get_config_value_for_remote(self.ctx, self.remote, self.job_config, 'sha1') + ref = None else: - sha1 = self.sha1 + ref = self.ref + tag = self.tag branch = self.branch + sha1 = self.sha1 - if tag: + if ref: + uri = 'ref'/ + ref + elif tag: uri = 'ref/' + tag elif branch: uri = 'ref/' + branch elif sha1: uri = 'sha1/' + sha1 else: - # FIXME: Should master be the default? - log.debug("defaulting to master branch") + log.warning("defaulting to master branch") uri = getattr(self, 'ref', 'ref/master') return uri diff --git a/teuthology/test/test_packaging.py b/teuthology/test/test_packaging.py index 46aea554c0..7e1ac2364f 100644 --- a/teuthology/test/test_packaging.py +++ b/teuthology/test/test_packaging.py @@ -371,6 +371,37 @@ class TestGitbuilderProject(object): expected = 'ref/jewel' assert result == expected + @patch("teuthology.packaging.config") + def test_init_from_config_tag_ref(self, m_config): + m_config.baseurl_template = \ + 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}' + m_config.gitbuilder_host = "gitbuilder.ceph.com" + config = dict( + os_type="ubuntu", + os_version="14.04", + tag='v10.0.1', + ) + gp = packaging.GitbuilderProject("ceph", config) + result = gp.uri_reference + expected = 'ref/v10.0.1' + assert result == expected + + @patch("teuthology.packaging.config") + def test_init_from_config_tag_overrides_branch_ref(self, m_config): + m_config.baseurl_template = \ + 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}' + m_config.gitbuilder_host = "gitbuilder.ceph.com" + config = dict( + os_type="ubuntu", + os_version="14.04", + branch='jewel', + tag='v10.0.1', + ) + gp = packaging.GitbuilderProject("ceph", config) + result = gp.uri_reference + expected = 'ref/v10.0.1' + assert result == expected + @patch("teuthology.packaging.config") @patch("teuthology.packaging._get_config_value_for_remote") @patch("teuthology.packaging._get_response") -- 2.39.5