예제 #1
0
 def test_rpmevr_db_comparison(self):
     dep = Dependency(name='foo',
                      version='1.1',
                      release='8.fc26',
                      arch='x86_64')
     self.db.add(dep)
     evr = RpmEVR(0, '1.1', '11.fc26')
     res = (self.db.query(Dependency).filter(Dependency.evr > evr).first())
     self.assertIsNone(res)
     res = (self.db.query(Dependency).filter(Dependency.evr < evr).first())
     self.assertIs(dep, res)
예제 #2
0
 def prepare_old_build(self):
     old_build = self.prepare_foo_build(repo_id=555, version='3')
     old_build.deps_processed = old_build.deps_resolved = True
     old_deps = FOO_DEPS[:]
     old_deps[2] = ('C', 1, '2', '1.fc22', 'x86_64')
     del old_deps[4] # E
     package_id = old_build.package_id
     for n, e, v, r, a in old_deps:
         self.s.add(Dependency(package_id=package_id, repo_id=555, arch=a,
                               name=n, epoch=e, version=v, release=r))
     self.s.commit()
     return old_build
예제 #3
0
 def resolve_dependencies(self, sack, br):
     resolve_dependencies_time.start()
     deps = None
     resolved, problems, installs = util.run_goal(sack, self.group, br)
     if resolved:
         problems = []
         deps = [Dependency(name=pkg.name, epoch=pkg.epoch,
                            version=pkg.version, release=pkg.release,
                            arch=pkg.arch)
                 for pkg in installs if pkg.arch != 'src']
         util.compute_dependency_distances(sack, br, deps)
     resolve_dependencies_time.stop()
     return (resolved, problems, deps)
예제 #4
0
 def prepare_old_build(self):
     old_build = self.prepare_foo_build(repo_id=122, version='3')
     old_build.deps_resolved = True
     old_deps = FOO_DEPS[:]
     old_deps[2] = ('C', 1, '2', '1.fc22', 'x86_64')
     del old_deps[4]  # E
     dependency_keys = []
     for n, e, v, r, a in old_deps:
         dep = Dependency(arch=a, name=n, epoch=e, version=v, release=r)
         self.db.add(dep)
         self.db.flush()
         dependency_keys.append(dep.id)
     old_build.dependency_keys = dependency_keys
     self.db.commit()
     return old_build
예제 #5
0
    def store_deps(self, repo_id, package_id, installs):
        new_deps = []
        for install in installs or []:
            if install.arch != 'src':
                dep = Dependency(repo_id=repo_id, package_id=package_id,
                                 name=install.name, epoch=install.epoch,
                                 version=install.version,
                                 release=install.release,
                                 arch=install.arch)
                new_deps.append(dep)

        if new_deps:
            # pylint: disable=E1101
            table = Dependency.__table__
            dicts = [{c.name: getattr(dep, c.name) for c in table.c
                      if not c.primary_key}
                     for dep in new_deps]
            self.db.connection().execute(table.insert(), dicts)
            self.db.expire_all()
예제 #6
0
 def resolve_dependencies(self, package, srpm):
     goal, problems = self.prepare_goal(srpm)
     if goal is not None:
         resolved = False
         if not problems:
             resolved = goal.run()
             problems = goal.problems
         self.resolved_packages[package.id] = resolved
         if resolved:
             # pylint: disable=E1101
             deps = [Dependency(name=pkg.name, epoch=pkg.epoch,
                                version=pkg.version, release=pkg.release,
                                arch=pkg.arch)
                     for pkg in goal.list_installs() if pkg.arch != 'src']
             self.compute_dependency_distances(srpm, deps)
             return deps
         else:
             for problem in sorted(set(problems)):
                 entry = dict(package_id=package.id,
                              problem=problem)
                 self.problems.append(entry)
예제 #7
0
    def test_copy_collection(self):
        now = datetime.now()
        source = self.collection
        _, _, maven1 = self.prepare_packages('rnv', 'eclipse', 'maven')
        self.prepare_build('rnv')
        self.prepare_build('eclipse')
        # the next build is old and shouldn't be copied
        self.prepare_build('maven', state=True, started='2016-01-01')
        old_build1 = self.prepare_build(
            'maven',
            state=True,
            started=datetime.fromtimestamp(time.time() - 10))
        new_build1 = self.prepare_build('maven', started=now)
        copy = Collection(
            name='copy',
            display_name='copy',
            target='a',
            build_tag='b',
            dest_tag='c',
        )
        self.db.add(copy)
        prev_dep = Dependency(name='foo',
                              version='1',
                              release='1',
                              arch='x86_64')
        curr_dep = Dependency(name='foo',
                              version='1',
                              release='2',
                              arch='x86_64')
        change1 = AppliedChange(
            build_id=old_build1.id,
            prev_dep=prev_dep,
            curr_dep=curr_dep,
        )
        self.db.add(change1)
        task1 = KojiTask(
            build_id=new_build1.id,
            task_id=new_build1.task_id,
            state=1,
            arch='x86_64',
            started=new_build1.started,
        )
        self.db.add(task1)
        rchange1 = ResolutionChange(
            package_id=maven1.id,
            resolved=False,
            timestamp=now,
        )
        self.db.add(rchange1)
        self.db.flush()
        problem1 = ResolutionProblem(
            resolution_id=rchange1.id,
            problem="It's broken",
        )
        self.db.add(problem1)
        self.db.commit()

        data.copy_collection(self.session, source, copy)
        self.db.commit()

        maven2 = self.db.query(Package).filter_by(collection=copy,
                                                  name='maven').first()
        self.assertIsNotNone(maven2)
        self.assertNotEqual(maven1.id, maven2.id)
        self.assertEqual(source.id, maven1.collection_id)
        self.assertEqual(copy.id, maven2.collection_id)
        self.assertEqual('maven', maven2.name)

        self.assertEqual(2, len(maven2.all_builds))
        new_build2, old_build2 = maven2.all_builds
        self.assertNotEqual(new_build1.id, new_build2.id)
        self.assertNotEqual(old_build1.id, old_build2.id)
        self.assertEqual(new_build1.id, maven1.last_build_id)
        self.assertEqual(old_build1.id, maven1.last_complete_build_id)
        self.assertEqual(new_build2.id, maven2.last_build_id)
        self.assertEqual(old_build2.id, maven2.last_complete_build_id)
        self.assertEqual(1, new_build2.build_arch_tasks[0].state)

        self.assertEqual(1, len(old_build2.dependency_changes))
        change2 = old_build2.dependency_changes[0]
        self.assertEqual('2', change2.curr_dep.release)

        rchange2 = self.db.query(ResolutionChange).filter_by(
            package_id=maven2.id).one()
        self.assertEqual("It's broken", rchange2.problems[0].problem)