示例#1
0
    def test_filter_binaries_by_sha1(self, session):
        models.Binary(
            'ceph-1.0.deb',
            self.p,
            ref='firefly',
            distro='ubuntu',
            distro_version='precise',
            arch='all',
            sha1="sha1",
            )
        models.Binary(
            'ceph-1.0.deb',
            self.p,
            ref='firefly',
            distro='ubuntu',
            distro_version='trusty',
            arch='all',
            sha1="head",
            )

        models.commit()
        result = util.get_extra_binaries(
            'ceph',
            'ubuntu',
            'trusty',
            distro_versions=['precise', 'trusty'],
            ref='firefly',
            sha1="sha1")
        assert len(result) == 1
示例#2
0
    def test_ref_matches_binaries_from_distro_versions(self, session):
        models.Binary(
            'ceph-1.0.deb',
            self.p,
            ref='firefly',
            distro='ubuntu',
            distro_version='precise',
            arch='all',
            )
        models.Binary(
            'ceph-1.0.deb',
            self.p,
            ref='firefly',
            distro='ubuntu',
            distro_version='trusty',
            arch='all',
            )

        models.commit()
        result = util.get_extra_binaries(
            'ceph',
            'ubuntu',
            'trusty',
            distro_versions=['precise', 'trusty'],
            ref='firefly')
        assert len(result) == 2
示例#3
0
    def test_no_ref_matches_binaries(self, session):
        models.Binary(
            'ceph-1.1.deb',
            self.p,
            distro='ubuntu',
            distro_version='trusty',
            arch='all',
            )
        models.Binary(
            'ceph-1.0.deb',
            self.p,
            distro='ubuntu',
            distro_version='trusty',
            arch='all',
            )

        models.commit()
        result = util.get_extra_binaries('ceph', 'ubuntu', 'trusty')
        assert len(result) == 2
示例#4
0
 def test_no_distro_versions_binary_no_fallback_generic(self, session, tmpdir):
     pecan.conf.distributions_root = str(tmpdir)
     binary = models.Binary(
         'ceph-1.1.deb',
         self.p,
         ref='firefly',
         distro='ubuntu',
         distro_version='generic',
         arch='all',
         )
     commands = util.reprepro_commands('/path', binary)
     assert commands == []
示例#5
0
 def test_deb_changes(self, session, tmpdir):
     pecan.conf.distributions_root = str(tmpdir)
     binary = models.Binary(
         'ceph-1.1.changes',
         self.p,
         ref='firefly',
         distro='ubuntu',
         distro_version='trusty',
         arch='all',
         )
     command = util.reprepro_command('/path', binary)
     assert command[-3] == 'include'
示例#6
0
 def test_no_distro_versions_binary_with_fallback_generic(self, session, tmpdir):
     pecan.conf.distributions_root = str(tmpdir)
     binary = models.Binary(
         'ceph-1.1.deb',
         self.p,
         ref='firefly',
         distro='ubuntu',
         distro_version='generic',
         arch='all',
         )
     commands = util.reprepro_commands('/path', binary, fallback_version='jessie')
     command = commands[0]
     assert len(commands) == 1
     assert 'jessie' in command
示例#7
0
 def test_multiple_distro_versions_non_generic(self, session, tmpdir):
     pecan.conf.distributions_root = str(tmpdir)
     binary = models.Binary(
         'ceph-1.1.deb',
         self.p,
         ref='firefly',
         distro='ubuntu',
         distro_version='trusty',
         arch='all',
     )
     commands = util.reprepro_commands(
         '/path', binary, distro_versions=['precise', 'trusty', 'wheezy'])
     command = commands[0]
     assert len(commands) == 1
     assert 'trusty' in command
示例#8
0
    def index_post(self):
        contents = request.POST.get('file', False)
        if contents is False:
            error('/errors/invalid/',
                  'no file object found in "file" param in POST request')
        file_obj = contents.file
        filename = contents.filename
        self.binary = self.get_binary(filename)
        self.binary_name = filename
        if self.binary is not None:
            if os.path.exists(self.binary.path):
                if request.POST.get('force', False) is False:
                    error(
                        '/errors/invalid',
                        'resource already exists and "force" key was not used')

        full_path = self.save_file(file_obj)

        if self.binary is None:
            path = full_path
            distro = request.context['distro']
            distro_version = request.context['distro_version']
            arch = request.context['arch']
            ref = request.context['ref']
            sha1 = request.context['sha1']

            self.binary = models.Binary(self.binary_name,
                                        self.project,
                                        arch=arch,
                                        distro=distro,
                                        distro_version=distro_version,
                                        ref=ref,
                                        sha1=sha1,
                                        path=path,
                                        size=os.path.getsize(path),
                                        flavor=self.flavor)
        else:
            self.binary.path = full_path

        # check if this binary is interesting for other configured projects,
        # and if so, then mark those other repos so that they can be re-built
        self.mark_related_repos()

        return dict()
示例#9
0
 def test_distro_versions_binary_with_fallback_generic(
         self, session, tmpdir):
     distro_versions = ['trusty', 'wheezy', 'precise']
     pecan.conf.distributions_root = str(tmpdir)
     binary = models.Binary(
         'ceph-1.1.deb',
         self.p,
         ref='firefly',
         distro='ubuntu',
         distro_version='generic',
         arch='all',
     )
     commands = util.reprepro_commands('/path',
                                       binary,
                                       distro_versions=distro_versions,
                                       fallback_version='jessie')
     assert len(commands) == 3
     # this is a poor use of assert here, but we are trying to ensure that
     # all distro_versions were used correctly, if something fails here it
     # means that they didn't get added to the reprepro command
     for c in commands:
         assert c[-2] in distro_versions