]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
GitbuilderProject: allow setting tag or ref in config dict
authorDan Mick <dan.mick@redhat.com>
Wed, 29 Jun 2016 23:47:07 +0000 (16:47 -0700)
committerDan Mick <dan.mick@redhat.com>
Thu, 30 Jun 2016 18:24:58 +0000 (11:24 -0700)
Precedence: ref, tag, branch, sha1.  (this is debatable.)

Also change log.debug() default-to-master to log.warning()

Signed-off-by: Dan Mick <dan.mick@redhat.com>
teuthology/packaging.py
teuthology/test/test_packaging.py

index d253bbb8f50cba11f02d623de3da70d6c593d782..f4afd54dcd9e0a07a9e3555db79a5f46749afec8 100644 (file)
@@ -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
 
index 46aea554c05e87d8e135c2e2f626a863c44dadde..7e1ac2364ff5e2a97aafff9de58ca60318da32ce 100644 (file)
@@ -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")