Example #1
0
def _MakeBisectFYITryJob(test_name, bisect_config):
    """Creates a TryJob entity with the bisect config.

  Args:
    test_name: Name of the test case.
    bisect_config: A dictionary of parameters for a bisect job.

  Returns:
    A TryJob entity, which has not yet been put in the datastore.

  Raises:
    NotBisectableError: A valid bisect config could not be created.
  """
    bisect_bot = bisect_config.get('recipe_tester_name')
    if not bisect_bot:
        raise auto_bisect.NotBisectableError('Could not select a bisect bot.')

    config_python_string = utils.BisectConfigPythonString(bisect_config)
    use_recipe = bool(start_try_job.GetBisectDirectorForTester(bisect_bot))
    bisect_job = try_job.TryJob(bot=bisect_bot,
                                config=config_python_string,
                                bug_id=bisect_config.get('bug_id', -1),
                                master_name='ChromiumPerf',
                                job_type='bisect-fyi',
                                use_buildbucket=use_recipe,
                                job_name=test_name)

    return bisect_job
Example #2
0
def _MakeBisectTryJob(bug_id, run_count=0):
    """Tries to automatically select parameters for a bisect job.

  Args:
    bug_id: A bug ID which some alerts are associated with.
    run_count: An integer; this is supposed to represent the number of times
        that a bisect has been tried for this bug; it is used to try different
        config parameters on different re-try attempts.

  Returns:
    A TryJob entity, which has not yet been put in the datastore.

  Raises:
    NotBisectableError: A valid bisect config could not be created.
  """
    anomalies = anomaly.Anomaly.query(anomaly.Anomaly.bug_id == bug_id).fetch()
    if not anomalies:
        raise NotBisectableError('No Anomaly alerts found for this bug.')

    good_revision, bad_revision = _ChooseRevisionRange(anomalies)
    if not can_bisect.IsValidRevisionForBisect(good_revision):
        raise NotBisectableError('Invalid "good" revision: %s.' %
                                 good_revision)
    if not can_bisect.IsValidRevisionForBisect(bad_revision):
        raise NotBisectableError('Invalid "bad" revision: %s.' % bad_revision)

    test = _ChooseTest(anomalies, run_count)
    if not test or not can_bisect.IsValidTestForBisect(test.test_path):
        raise NotBisectableError('Could not select a test.')

    metric = start_try_job.GuessMetric(test.test_path)

    bisect_bot = start_try_job.GuessBisectBot(test.master_name, test.bot_name)
    if not bisect_bot or '_' not in bisect_bot:
        raise NotBisectableError('Could not select a bisect bot.')

    use_recipe = bool(start_try_job.GetBisectDirectorForTester(bisect_bot))

    new_bisect_config = start_try_job.GetBisectConfig(
        bisect_bot=bisect_bot,
        master_name=test.master_name,
        suite=test.suite_name,
        metric=metric,
        good_revision=good_revision,
        bad_revision=bad_revision,
        repeat_count=10,
        max_time_minutes=20,
        bug_id=bug_id,
        use_archive='true',
        use_buildbucket=use_recipe)

    if 'error' in new_bisect_config:
        raise NotBisectableError('Could not make a valid config.')

    config_python_string = utils.BisectConfigPythonString(new_bisect_config)

    bisect_job = try_job.TryJob(bot=bisect_bot,
                                config=config_python_string,
                                bug_id=bug_id,
                                master_name=test.master_name,
                                internal_only=test.internal_only,
                                job_type='bisect',
                                use_buildbucket=use_recipe)

    return bisect_job