Esempio n. 1
0
 def test_build_queue_3(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
     for build_chroots in [self.b1_bc, self.b2_bc, self.b3_bc, self.b4_bc]:
         for build_chroot in build_chroots:
             build_chroot.status = 0
     self.db.session.commit()
     data = BuildsLogic.get_build_task_queue().all()
     assert len(data) == 0
Esempio n. 2
0
 def test_build_queue_3(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
     for build_chroots in [self.b1_bc, self.b2_bc, self.b3_bc, self.b4_bc]:
         for build_chroot in build_chroots:
             build_chroot.status = 0
     self.db.session.commit()
     data = BuildsLogic.get_build_task_queue().all()
     assert len(data) == 0
Esempio n. 3
0
def waiting():
    """
    Return list of waiting actions and builds.
    """

    # models.Actions
    actions_list = [
        action.to_dict(options={
            "__columns_except__": ["result", "message", "ended_on"]
        })
        for action in actions_logic.ActionsLogic.get_waiting()
    ]

    # tasks represented by models.BuildChroot with some other stuff
    builds_list = []
    for task in BuildsLogic.get_build_task_queue().limit(200):
        try:
            copr = task.build.copr

            # we are using fake username's here
            if copr.is_a_group_project:
                user_name = u"@{}".format(copr.group.name)
            else:
                user_name = copr.user.name

            record = {
                "task_id": task.task_id,
                "build_id": task.build.id,
                "project_owner": user_name,
                "project_name": task.build.copr.name,
                "submitter": task.build.user.name if task.build.user else None, # there is no user for webhook builds
                "pkgs": task.build.pkgs,  # TODO to be removed
                "chroot": task.mock_chroot.name,

                "repos": task.build.repos,
                "memory_reqs": task.build.memory_reqs,
                "timeout": task.build.timeout,
                "enable_net": task.build.enable_net,
                "git_repo": task.build.package.dist_git_repo,
                "git_hash": task.git_hash,
                "git_branch": helpers.chroot_to_branch(task.mock_chroot.name),
                "package_name": task.build.package.name,
                "package_version": task.build.pkg_version
            }
            copr_chroot = CoprChrootsLogic.get_by_name_safe(task.build.copr, task.mock_chroot.name)
            if copr_chroot:
                record["buildroot_pkgs"] = copr_chroot.buildroot_pkgs
            else:
                record["buildroot_pkgs"] = ""

            builds_list.append(record)

        except Exception as err:
            app.logger.exception(err)

    response_dict = {"actions": actions_list, "builds": builds_list}
    return flask.jsonify(response_dict)
Esempio n. 4
0
def waiting():
    """
    Return list of waiting actions and builds.
    """

    # models.Actions
    actions_list = [
        action.to_dict(
            options={"__columns_except__": ["result", "message", "ended_on"]})
        for action in actions_logic.ActionsLogic.get_waiting()
    ]

    # tasks represented by models.BuildChroot with some other stuff
    builds_list = []
    for task in BuildsLogic.get_build_task_queue().limit(200):
        try:
            copr = task.build.copr

            # we are using fake username's here
            if copr.is_a_group_project:
                user_name = u"@{}".format(copr.group.name)
            else:
                user_name = copr.owner.name

            record = {
                "task_id": "{}-{}".format(task.build.id,
                                          task.mock_chroot.name),
                "build_id": task.build.id,
                "project_owner": user_name,
                "project_name": task.build.copr.name,
                "submitter": task.build.user.name,
                "pkgs": task.build.pkgs,  # TODO to be removed
                "chroot": task.mock_chroot.name,
                "repos": task.build.repos,
                "memory_reqs": task.build.memory_reqs,
                "timeout": task.build.timeout,
                "enable_net": task.build.enable_net,
                "git_repo": task.build.package.dist_git_repo,
                "git_hash": task.git_hash,
                "git_branch": helpers.chroot_to_branch(task.mock_chroot.name),
                "package_name": task.build.package.name,
                "package_version": task.build.pkg_version
            }
            copr_chroot = CoprChrootsLogic.get_by_name_safe(
                task.build.copr, task.mock_chroot.name)
            if copr_chroot:
                record["buildroot_pkgs"] = copr_chroot.buildroot_pkgs
            else:
                record["buildroot_pkgs"] = ""

            builds_list.append(record)

        except Exception as err:
            app.logger.exception(err)

    response_dict = {"actions": actions_list, "builds": builds_list}
    return flask.jsonify(response_dict)
Esempio n. 5
0
    def test_build_queue_4(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        for build_chroots in [self.b1_bc, self.b2_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = 3  # running
        for build_chroots in [self.b3_bc, self.b4_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = 0

        time_now = int(time.time())

        self.b1.started_on = time_now - 100000

        self.db.session.commit()
        data = BuildsLogic.get_build_task_queue().all()

        assert len(data) == 1
        assert data[0] == self.b1_bc[0]
Esempio n. 6
0
    def test_build_queue_4(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        time_now = int(time.time())
        for build_chroots in [self.b1_bc, self.b2_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = StatusEnum("running")
                build_chroot.started_on = time_now - 2 * MAX_BUILD_TIMEOUT
                build_chroot.ended_on = None
        for build_chroots in [self.b3_bc, self.b4_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = StatusEnum("failed")
                build_chroot.started_on = time_now - 2 * MAX_BUILD_TIMEOUT
                build_chroot.ended_on = None

        self.db.session.commit()
        data = BuildsLogic.get_build_task_queue().all()

        assert len(data) == 2
        assert set([data[0], data[1]]) == set([self.b1_bc[0], self.b2_bc[0]])
Esempio n. 7
0
    def test_build_queue_4(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        time_now = int(time.time())
        for build_chroots in [self.b1_bc, self.b2_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = StatusEnum("running")
                build_chroot.started_on = time_now - 2 * MAX_BUILD_TIMEOUT
                build_chroot.ended_on = None
        for build_chroots in [self.b3_bc, self.b4_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = StatusEnum("failed")
                build_chroot.started_on = time_now - 2 * MAX_BUILD_TIMEOUT
                build_chroot.ended_on = None

        self.db.session.commit()
        data = BuildsLogic.get_build_task_queue().all()

        assert len(data) == 2
        assert set([data[0], data[1]]) == set([self.b1_bc[0], self.b2_bc[0]])
Esempio n. 8
0
    def test_build_queue_4(self, f_users, f_coprs, f_mock_chroots, f_builds,
                           f_db):
        for build_chroots in [self.b1_bc, self.b2_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = 3  # running
        for build_chroots in [self.b3_bc, self.b4_bc]:
            for build_chroot in build_chroots:
                build_chroot.status = 0

        time_now = int(time.time())

        self.b1.started_on = time_now - 100000

        self.db.session.commit()
        data = BuildsLogic.get_build_task_queue().all()

        assert len(data) == 1
        assert data[0] == self.b1_bc[0]
Esempio n. 9
0
 def test_build_queue_6(self, f_users, f_coprs, f_mock_chroots, f_db):
     self.db.session.commit()
     data = BuildsLogic.get_build_task_queue().all()
     assert len(data) == 0
Esempio n. 10
0
 def test_build_queue_6(self, f_users, f_coprs, f_mock_chroots, f_db):
     self.db.session.commit()
     data = BuildsLogic.get_build_task_queue().all()
     assert len(data) == 0