def testGetCoordinatesData(self):
    master_name = 'm'
    builder_name = 'b'
    build_number = 123
    step_name = 's'
    test_name = 't'
    success_rate = .9
    try_job_url = 'try_job_url'
    analysis = MasterFlakeAnalysis.Create(
        master_name, builder_name, build_number, step_name, test_name)
    data_point_1 = DataPoint()
    data_point_1.build_number = build_number
    data_point_1.pass_rate = success_rate
    data_point_1.commit_position = 5
    data_point_1.git_hash = 'git_hash_5'
    data_point_1.previous_build_commit_position = 4
    data_point_1.previous_build_git_hash = 'git_hash_4'
    data_point_1.try_job_url = try_job_url
    analysis.data_points.append(data_point_1)

    data_point_2 = DataPoint()
    data_point_2.build_number = build_number - 3
    data_point_2.pass_rate = success_rate
    data_point_2.commit_position = 2
    data_point_2.git_hash = 'git_hash_2'
    data_point_2.previous_build_commit_position = 1
    data_point_2.previous_build_git_hash = 'git_hash_1'
    data_point_2.try_job_url = try_job_url
    analysis.data_points.append(data_point_2)
    analysis.Save()

    expected_result = [
        {
            'commit_position': 2,
            'pass_rate': success_rate,
            'task_id': None,
            'build_number': build_number - 3,
            'git_hash': 'git_hash_2',
            'try_job_url': try_job_url
        },
        {
            'commit_position': 5,
            'pass_rate': success_rate,
            'task_id': None,
            'build_number': build_number,
            'git_hash': 'git_hash_5',
            'lower_bound_commit_position': 2,
            'lower_bound_git_hash': 'git_hash_2',
            'try_job_url': try_job_url
        }
    ]
    self.assertEqual(expected_result, check_flake._GetCoordinatesData(analysis))
  def testGetSuspectedFlakeInfo(self):
    analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't')
    analysis.suspected_flake_build_number = 123
    data_point = DataPoint()
    data_point.build_number = 123
    data_point.pass_rate = 0.9
    data_point.commit_position = 2
    data_point.git_hash = 'git_hash_2'
    data_point.previous_build_commit_position = 1
    data_point.previous_build_git_hash = 'git_hash_1'
    analysis.data_points.append(data_point)
    analysis.confidence_in_suspected_build = 0
    analysis.Save()

    expected_result = {
        'confidence': 0,
        'build_number': analysis.suspected_flake_build_number,
        'commit_position': 2,
        'git_hash': 'git_hash_2',
        'lower_bound_commit_position': 1,
        'lower_bound_git_hash': 'git_hash_1',
        'triage_result': 0
    }
    self.assertEqual(expected_result,
                     check_flake._GetSuspectedFlakeInfo(analysis))
Beispiel #3
0
    def _UpdateMasterFlakeAnalysis(self,
                                   master_name,
                                   builder_name,
                                   build_number,
                                   step_name,
                                   master_build_number,
                                   test_name,
                                   version_number,
                                   pass_rate,
                                   flake_swarming_task,
                                   has_valid_artifact=True):
        """Update MasterFlakeAnalysis to include result of the swarming task."""
        master_flake_analysis = MasterFlakeAnalysis.GetVersion(
            master_name,
            builder_name,
            master_build_number,
            step_name,
            test_name,
            version=version_number)
        logging.info(
            'Updating MasterFlakeAnalysis swarming task data %s/%s/%s/%s/%s',
            master_name, builder_name, master_build_number, step_name,
            test_name)

        data_point = DataPoint()
        data_point.build_number = build_number
        data_point.pass_rate = pass_rate
        data_point.task_id = flake_swarming_task.task_id
        data_point.has_valid_artifact = has_valid_artifact

        # Include git information about each build that was run.
        build_info = build_util.GetBuildInfo(master_name, builder_name,
                                             build_number)
        data_point.commit_position = build_info.commit_position
        data_point.git_hash = build_info.chromium_revision

        if build_number > 0:
            previous_build = build_util.GetBuildInfo(master_name, builder_name,
                                                     build_number - 1)
            data_point.previous_build_commit_position = previous_build.commit_position
            data_point.previous_build_git_hash = previous_build.chromium_revision
            data_point.blame_list = _GetCommitsBetweenRevisions(
                previous_build.chromium_revision, build_info.chromium_revision)
        else:
            data_point.blame_list = build_info.blame_list

        master_flake_analysis.data_points.append(data_point)

        results = flake_swarming_task.GetFlakeSwarmingTaskData()
        # TODO(lijeffrey): Determine whether or not this flake swarming task
        # was a cache hit (already ran results for more iterations than were
        # requested) and update results['cache_hit'] accordingly.
        master_flake_analysis.swarming_rerun_results.append(results)
        master_flake_analysis.put()
Beispiel #4
0
def _GenerateDataPoint(pass_rate=None,
                       build_number=None,
                       task_id=None,
                       try_job_url=None,
                       commit_position=None,
                       git_hash=None,
                       previous_build_commit_position=None,
                       previous_build_git_hash=None,
                       blame_list=None):
    data_point = DataPoint()
    data_point.pass_rate = pass_rate
    data_point.build_number = build_number
    data_point.task_id = task_id
    data_point.try_job_url = try_job_url
    data_point.commit_position = commit_position
    data_point.git_hash = git_hash
    data_point.previous_build_commit_position = previous_build_commit_position
    data_point.previous_build_git_hash = previous_build_git_hash
    data_point.blame_list = blame_list if blame_list else []
    return data_point