コード例 #1
0
 def test_get_dist_release(self, distro, version, codename, expected):
     rem = self._get_remote(distro=distro,
                            version=version,
                            codename=codename)
     ctx = dict(foo="bar")
     gp = packaging.GitbuilderProject("ceph", {}, ctx=ctx, remote=rem)
     assert gp.dist_release == expected
コード例 #2
0
ファイル: test_run_.py プロジェクト: zglnsyyj/teuthology
 def test_regression(
     self,
     m_git_ls_remote,
     m_package_version_for_hash,
     m_git_branch_exists,
     m_fetch_repos,
 ):
     config.use_shaman = False
     config.gitbuilder_host = 'example.com'
     m_package_version_for_hash.return_value = 'ceph_hash'
     m_git_branch_exists.return_value = True
     m_git_ls_remote.return_value = "suite_branch"
     self.args_dict = {
         'base_yaml_paths': [],
         'ceph_branch': 'master',
         'machine_type': 'smithi',
         'kernel_flavor': 'basic',
         'kernel_branch': 'testing',
         'suite': 'krbd',
     }
     self.args = YamlConfig.from_dict(self.args_dict)
     with patch.multiple(
             'teuthology.packaging.GitbuilderProject',
             _get_package_sha1=DEFAULT,
     ) as m:
         assert m != dict()
         m['_get_package_sha1'].return_value = 'SHA1'
         conf = dict(
             os_type='ubuntu',
             os_version='16.04',
         )
         assert packaging.GitbuilderProject('ceph', conf).sha1 == 'SHA1'
         run_ = self.klass(self.args)
         assert run_.base_config['kernel']['sha1'] == 'SHA1'
コード例 #3
0
 def test_get_distro_config(self, distro, version, codename, expected):
     config = dict(
         os_type=distro,
         os_version=version
     )
     gp = packaging.GitbuilderProject("ceph", config)
     assert gp.distro == expected
コード例 #4
0
def _get_gitbuilder_project(ctx, remote, config):
    return packaging.GitbuilderProject(
        config.get('project', 'ceph'),
        config,
        remote=remote,
        ctx=ctx
    )
コード例 #5
0
 def test_init_from_remote_base_url(self, m_get_config_value, m_config):
     m_config.baseurl_template = 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}'
     m_config.gitbuilder_host = "gitbuilder.ceph.com"
     m_get_config_value.return_value = None
     rem = self._get_remote()
     ctx = dict(foo="bar")
     gp = packaging.GitbuilderProject("ceph", {}, ctx=ctx, remote=rem)
     result = gp.base_url
     expected = "http://gitbuilder.ceph.com/ceph-deb-trusty-x86_64-basic/ref/master"
     assert result == expected
コード例 #6
0
 def test_init_from_remote_base_url_debian(self, m_get_config_value, m_config):
     m_config.baseurl_template = 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}'
     m_config.gitbuilder_host = "gitbuilder.ceph.com"
     m_get_config_value.return_value = None
     # remote.os.codename returns and empty string on debian
     rem = self._get_remote(distro="debian", codename='', version="7.1")
     ctx = dict(foo="bar")
     gp = packaging.GitbuilderProject("ceph", {}, ctx=ctx, remote=rem)
     result = gp.base_url
     expected = "http://gitbuilder.ceph.com/ceph-deb-wheezy-x86_64-basic/ref/master"
     assert result == expected
コード例 #7
0
 def test_get_package_sha1_fetched_not_found(self, m_get,
                                             m_get_config_value, m_config):
     m_config.baseurl_template = 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}'
     m_config.gitbuilder_host = "gitbuilder.ceph.com"
     m_get_config_value.return_value = None
     resp = Mock()
     resp.ok = False
     m_get.return_value = resp
     rem = self._get_remote()
     ctx = dict(foo="bar")
     gp = packaging.GitbuilderProject("ceph", {}, ctx=ctx, remote=rem)
     assert not gp.sha1
コード例 #8
0
 def test_init_from_config_base_url(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",
         sha1="sha1",
     )
     gp = packaging.GitbuilderProject("ceph", config)
     result = gp.base_url
     expected = "http://gitbuilder.ceph.com/ceph-deb-trusty-x86_64-basic/sha1/sha1"
     assert result == expected
コード例 #9
0
 def test_get_package_version_not_found(self, m_get_config_value,
                                        m_config, m_get_response):
     m_config.baseurl_template = 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}'
     m_config.gitbuilder_host = "gitbuilder.ceph.com"
     m_get_config_value.return_value = None
     rem = self._get_remote()
     ctx = dict(foo="bar")
     resp = Mock()
     resp.ok = False
     m_get_response.return_value = resp
     gp = packaging.GitbuilderProject("ceph", {}, ctx=ctx, remote=rem)
     with pytest.raises(VersionNotFoundError):
         gp.version
コード例 #10
0
 def test_get_package_version_found(self, m_get_response, m_get_config_value,
                                    m_config):
     m_config.baseurl_template = 'http://{host}/{proj}-{pkg_type}-{dist}-{arch}-{flavor}/{uri}'
     m_config.gitbuilder_host = "gitbuilder.ceph.com"
     m_get_config_value.return_value = None
     resp = Mock()
     resp.ok = True
     resp.text = "0.90.0"
     m_get_response.return_value = resp
     rem = self._get_remote()
     ctx = dict(foo="bar")
     gp = packaging.GitbuilderProject("ceph", {}, ctx=ctx, remote=rem)
     assert gp.version == "0.90.0"
コード例 #11
0
 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
コード例 #12
0
 def test_init_from_config_tag_overrides_branch_ref(self, m_config, caplog):
     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
     expected_log = 'More than one of ref, tag, branch, or sha1 supplied; using tag'
     assert expected_log in caplog.text()
コード例 #13
0
def test_get_tag_branch_sha1():
    gitbuilder = packaging.GitbuilderProject(
        'ceph',
        {
            'os_type': 'centos',
            'os_version': '7.0',
        })
    (tag, branch, sha1) = buildpackages.get_tag_branch_sha1(gitbuilder)
    assert tag == None
    assert branch == None
    assert sha1 is not None

    gitbuilder = packaging.GitbuilderProject(
        'ceph',
        {
            'os_type': 'centos',
            'os_version': '7.0',
            'sha1': 'asha1',
        })
    (tag, branch, sha1) = buildpackages.get_tag_branch_sha1(gitbuilder)
    assert tag == None
    assert branch == None
    assert sha1 == 'asha1'

    remote = Mock
    remote.arch = 'x86_64'
    remote.os = Mock
    remote.os.name = 'ubuntu'
    remote.os.version = '14.04'
    remote.os.codename = 'trusty'
    remote.system_type = 'deb'
    ctx = Mock
    ctx.cluster = Mock
    ctx.cluster.remotes = {remote: ['client.0']}

    expected_tag = 'v0.94.1'
    expected_sha1 = 'expectedsha1'
    def check_output(cmd, shell):
        assert shell == True
        return expected_sha1 + " refs/tags/" + expected_tag
    with patch.multiple(
            buildpackages,
            check_output=check_output,
    ):
        gitbuilder = packaging.GitbuilderProject(
            'ceph',
            {
                'os_type': 'centos',
                'os_version': '7.0',
                'sha1': 'asha1',
                'all': {
                    'tag': tag,
                },
            },
            ctx = ctx,
            remote = remote)
        (tag, branch, sha1) = buildpackages.get_tag_branch_sha1(gitbuilder)
        assert tag == expected_tag
        assert branch == None
        assert sha1 == expected_sha1

    expected_branch = 'hammer'
    expected_sha1 = 'otherexpectedsha1'
    def check_output(cmd, shell):
        assert shell == True
        return expected_sha1 + " refs/heads/" + expected_branch
    with patch.multiple(
            buildpackages,
            check_output=check_output,
    ):
        gitbuilder = packaging.GitbuilderProject(
            'ceph',
            {
                'os_type': 'centos',
                'os_version': '7.0',
                'sha1': 'asha1',
                'all': {
                    'branch': branch,
                },
            },
            ctx = ctx,
            remote = remote)
        (tag, branch, sha1) = buildpackages.get_tag_branch_sha1(gitbuilder)
        assert tag == None
        assert branch == expected_branch
        assert sha1 == expected_sha1