예제 #1
0
    def execute(self, session, master_collection, new_name, display_name,
                target, dest_tag):
        master = (session.db.query(Collection).filter_by(
            name=master_collection)).one()
        if not master:
            sys.exit("Collection not found")
        forked = (session.db.query(Collection).filter_by(
            name=new_name)).first()
        if forked:
            sys.exit("Forked collection already exists")
        forked = Collection(
            name=new_name,
            target=target,
            dest_tag=dest_tag,
            order=master.order,
            display_name=display_name,
        )
        for key in ('secondary_mode', 'priority_coefficient',
                    'bugzilla_product', 'poll_untracked', 'build_group',
                    'bugzilla_version'):
            setattr(forked, key, getattr(master, key))
        self.set_koji_tags(session, forked)
        session.db.add(forked)
        session.db.flush()
        for group_rel in (session.db.query(CollectionGroupRelation).filter_by(
                collection_id=master.id)):
            session.db.add(
                CollectionGroupRelation(
                    collection_id=forked.id,
                    group_id=group_rel.group_id,
                ))

        data.copy_collection(session, master, forked, minimal=True)
        session.log_user_action("Collection {} forked from {}".format(
            new_name, master_collection))
예제 #2
0
 def prepare_multiple(self):
     self.prepare_build('xpp3', True)
     self.prepare_build('xpp', None)
     self.prepare_build('xpp2', False)
     self.collection = Collection(
         name="epel7",
         display_name="EPEL 7",
         target="epel7",
         dest_tag='epel7',
         build_tag="epel7-build",
         priority_coefficient=0.2,
         latest_repo_resolved=False,
         latest_repo_id=456,
     )
     self.db.add(self.collection)
     self.db.commit()
     self.prepare_build('rnv', True)
     self.prepare_build('fop', False)
예제 #3
0
    def prepare_collection(self, name, **kwargs):
        values = dict(
            name=name,
            target=name,
            display_name="Fedora Rawhide",
            latest_repo_resolved=True,
            latest_repo_id=123,
            bugzilla_product="Fedora",
            bugzilla_version="rawhide",
            build_tag=f'{name}-build',
            dest_tag=f'{name}-build',
        )
        values.update(**kwargs)

        collection = Collection(**values)
        self.db.add(collection)
        self.db.commit()
        return collection
예제 #4
0
 def __init__(self, *args, **kwargs):
     super(DBTest, self).__init__(*args, **kwargs)
     self.db = None
     self.task_id_counter = 1
     self.pkg_name_counter = 1
     self.collection = Collection(
         name="f25",
         display_name="Fedora Rawhide",
         target="f25",
         dest_tag='f25',
         build_tag="f25-build",
         priority_coefficient=1.0,
         latest_repo_resolved=True,
         latest_repo_id=123,
         bugzilla_product="Fedora",
         bugzilla_version="25",
     )
     self.session = None
예제 #5
0
 def test_collections_diff(self):
     base_id = self.collection.id
     self.prepare_build('good', True)
     self.prepare_build('bad', False)
     self.prepare_build('broken', True)
     self.prepare_build('fixed', False)
     self.db.commit()
     self.collection = Collection(
         name="epel7", display_name="EPEL 7", target="epel7",
         dest_tag='epel7', build_tag="epel7-build", priority_coefficient=0.2,
         latest_repo_resolved=False, latest_repo_id=456,
     )
     self.db.add(self.collection)
     self.db.commit()
     self.prepare_build('good', True)
     self.prepare_build('bad', False)
     self.prepare_build('fixed', True)
     self.assertFalse(collection_has_broken_package(self.db, self.collection.id, base_id))
     self.prepare_build('broken', False)
     self.assertTrue(collection_has_broken_package(self.db, self.collection.id, base_id))
예제 #6
0
    def execute(self, session, master_collection, new_name, display_name,
                target, bugzilla_version):
        master = (
            session.db.query(Collection)
            .filter_by(name=master_collection)
        ).first()
        if not master:
            sys.exit("Collection not found")
        branched = (
            session.db.query(Collection)
            .filter_by(name=new_name)
        ).first()
        if branched:
            sys.exit("Branched collection exists already")
        branched = Collection(
            display_name=display_name,
            bugzilla_version=bugzilla_version,
        )
        for key in ('secondary_mode', 'priority_coefficient', 'bugzilla_product',
                    'poll_untracked', 'build_group', 'target', 'name', 'order'):
            setattr(branched, key, getattr(master, key))
        master.name = new_name
        master.target = target
        master.order += 1
        self.set_koji_tags(session, branched)
        self.set_koji_tags(session, master)
        session.db.add(branched)
        session.db.flush()
        for group_rel in (
                session.db.query(CollectionGroupRelation)
                .filter_by(collection_id=master.id)
        ):
            session.db.add(CollectionGroupRelation(
                collection_id=branched.id,
                group_id=group_rel.group_id,
            ))

        data.copy_collection(session, master, branched)
        session.log_user_action(
            "Collection {} branched from {}".format(new_name, master_collection)
        )
예제 #7
0
 def test_collections_diff(self):
     self.prepare_build('good', True)
     self.prepare_build('bad', False)
     self.prepare_build('broken', True)
     self.prepare_build('fixed', False)
     self.db.commit()
     self.collection = Collection(
         name="epel7",
         display_name="EPEL 7",
         target="epel7",
         dest_tag='epel7',
         build_tag="epel7-build",
         priority_coefficient=0.2,
         latest_repo_resolved=False,
         latest_repo_id=456,
     )
     self.db.add(self.collection)
     self.prepare_build('good', True)
     self.prepare_build('bad', False)
     self.prepare_build('broken', False)
     self.prepare_build('fixed', True)
     [broken, fixed] = self.api_call('collections/diff/f25/epel7')
     self.assertDictEqual(broken, {
         'name': 'broken',
         'state': {
             'f25': 'ok',
             'epel7': 'failing'
         }
     })
     self.assertDictEqual(fixed, {
         'name': 'fixed',
         'state': {
             'f25': 'failing',
             'epel7': 'ok'
         }
     })
예제 #8
0
 def execute(self, backend, **kwargs):
     backend.db.add(Collection(**kwargs))
     backend.db.commit()
예제 #9
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)