Beispiel #1
0
def test_not_expired_job_priority():
    jp = JobPriority(testtype='web-platform-tests-1',
                     buildtype='opt',
                     platform='windows8-64',
                     priority=1,
                     expiration_date=TOMORROW,
                     buildsystem='taskcluster')
    assert not jp.has_expired()
def _update_table(data):
    """Add new jobs to the priority table and update the build system if required.
    data - it is a list of dictionaries that describe a job type

    returns the number of new, failed and updated jobs
    """
    jp_index, priority, expiration_date = _initialize_values()

    total_jobs = len(data)
    new_jobs, failed_changes, updated_jobs = 0, 0, 0
    # Loop through sanitized jobs, add new jobs and update the build system if needed
    for job in data:
        key = _unique_key(job)
        if key in jp_index:
            # We already know about this job, we might need to update the build system
            # We're seeing the job again with another build system (e.g. buildbot vs
            # taskcluster). We need to change it to '*'
            if jp_index[key]['build_system_type'] != '*' and jp_index[key][
                    'build_system_type'] != job["build_system_type"]:
                db_job = JobPriority.objects.get(pk=jp_index[key]['pk'])
                db_job.buildsystem = '*'
                db_job.save()

                logger.info('Updated %s/%s from %s to %s', db_job.testtype,
                            db_job.buildtype, job['build_system_type'],
                            db_job.buildsystem)
                updated_jobs += 1

        else:
            # We have a new job from runnablejobs to add to our master list
            try:
                jobpriority = JobPriority(testtype=str(job["testtype"]),
                                          buildtype=str(
                                              job["platform_option"]),
                                          platform=str(job["platform"]),
                                          priority=priority,
                                          expiration_date=expiration_date,
                                          buildsystem=job["build_system_type"])
                jobpriority.save()
                logger.info('New job was found (%s,%s,%s,%s)', job['testtype'],
                            job['platform_option'], job['platform'],
                            job["build_system_type"])
                new_jobs += 1
            except Exception as error:
                logger.warning(str(error))
                failed_changes += 1

    logger.info(
        'We have %s new jobs and %s updated jobs out of %s total jobs processed.',
        new_jobs, updated_jobs, total_jobs)

    if failed_changes != 0:
        logger.warning(
            'We have failed %s changes out of %s total jobs processed.',
            failed_changes, total_jobs)

    return new_jobs, failed_changes, updated_jobs
Beispiel #3
0
def job_priority_list(sanitized_data):
    jp_list = []
    for datum in sanitized_data:
        jp_list.append(
            JobPriority(
                testtype=datum['testtype'],
                buildtype=datum['platform_option'],
                platform=datum['platform'],
                buildsystem=datum['build_system_type'],
                priority=SETA_HIGH_VALUE_PRIORITY,
            ))
        # Mark the reftest-e10s-2 TC job as low priority (unique to TC)
        if datum['testtype'] == 'reftest-e10s-2':
            jp_list[-1].priority = SETA_LOW_VALUE_PRIORITY
        # Mark the web-platform-tests-1 BB job as low priority (unique to BB)
        if datum['testtype'] == 'web-platform-tests-1':
            jp_list[-1].priority = SETA_LOW_VALUE_PRIORITY

    return jp_list