コード例 #1
0
  def _GetIssueGenerator(self, new_issue=True):
    luci_project = 'chromium'
    normalized_step_name = 'step'

    flake0 = Flake.Create(luci_project, normalized_step_name, 'suite.test0',
                          'suite.test0')
    flake0.tags = ['component::Blink']
    flake0.put()
    flake1 = Flake.Create(luci_project, normalized_step_name, 'suite.test1',
                          'suite.test1')
    flake1.tags = ['component::Blink/Infra']
    flake1.put()
    flake2 = Flake.Create(luci_project, normalized_step_name, 'suite.test2',
                          'suite.test2')
    flake2.put()
    flake3 = Flake.Create(luci_project, 'other_step', 'other_test',
                          'other_test')
    flake3.put()

    issue_generator_new = issue_generator.FlakeDetectionGroupIssueGenerator(
        flakes=[flake0, flake1, flake2],
        num_occurrences=5,
        canonical_step_name=normalized_step_name)

    flake_issue = FlakeIssue.Create(luci_project, 12345)
    flake_issue.put()
    issue_generator_old = issue_generator.FlakeDetectionGroupIssueGenerator(
        flakes=[flake1, flake2, flake3],
        num_occurrences=5,
        flake_issue=flake_issue,
        flakes_with_same_occurrences=False)

    return issue_generator_new if new_issue else issue_generator_old
コード例 #2
0
  def testDetectCQHiddenFlakesShouldRun(self, _):
    flake = Flake.Create(
        luci_project='luci_project',
        normalized_step_name='s',
        normalized_test_name='t',
        test_label_name='t')
    flake.put()
    existing_occurrence = FlakeOccurrence.Create(
        flake_type=FlakeType.CQ_HIDDEN_FLAKE,
        build_id=123,
        step_ui_name='s',
        test_name='t',
        luci_project='luci_project',
        luci_bucket='luci_bucket',
        luci_builder='luci_builder',
        legacy_master_name='legacy_master_name',
        legacy_build_number=123,
        time_happened=datetime(2018, 12, 19, 20),
        gerrit_cl_id=654321,
        parent_flake_key=flake.key,
        tags=[])
    existing_occurrence.time_detected = datetime(2018, 12, 19, 20)
    existing_occurrence.put()

    self.assertEqual(('2018-12-19 19:40:00 UTC', '2018-12-19 22:00:00 UTC'),
                     detect_flake_occurrences._GetCQHiddenFlakeQueryStartTime())
コード例 #3
0
  def testAnalysisIsNeededForCrashedAnalysisWithForce(self):
    master_name = 'm'
    builder_name = 'b 1'
    build_number = 123
    step_name = 's'
    test_name = 't'
    flake = Flake.Create('chromium', step_name, test_name, 'l')
    _CreateAndSaveMasterFlakeAnalysis(
        master_name,
        builder_name,
        build_number,
        step_name,
        test_name,
        status=analysis_status.ERROR)

    mocked_now = datetime(2017, 05, 01, 10, 10, 10)
    self.MockUTCNow(mocked_now)

    test = TestInfo(master_name, builder_name, build_number, step_name,
                    test_name)
    need_analysis, analysis = initialize_flake_pipeline._NeedANewAnalysis(
        test,
        test,
        flake.key,
        None,
        user_email='*****@*****.**',
        allow_new_analysis=True,
        force=True)

    self.assertTrue(need_analysis)
    self.assertIsNotNone(analysis)
    self.assertFalse(analysis.triggering_user_email_obscured)
    self.assertEqual(mocked_now, analysis.request_time)
    self.assertEqual(analysis.version_number, 2)
コード例 #4
0
  def testDetectCQHiddenFlakesShouldSkip(self, mock_query, *_):
    flake = Flake.Create(
        luci_project='luci_project',
        normalized_step_name='s',
        normalized_test_name='t',
        test_label_name='t')
    flake.put()
    existing_occurrence = FlakeOccurrence.Create(
        flake_type=FlakeType.CQ_HIDDEN_FLAKE,
        build_id=123,
        step_ui_name='s',
        test_name='t',
        luci_project='luci_project',
        luci_bucket='luci_bucket',
        luci_builder='luci_builder',
        legacy_master_name='legacy_master_name',
        legacy_build_number=123,
        time_happened=datetime(2018, 12, 19, 23),
        gerrit_cl_id=654321,
        parent_flake_key=flake.key,
        tags=[])
    existing_occurrence.time_detected = datetime(2018, 12, 19, 23, 30)
    existing_occurrence.put()

    mock_query.side_effect = [(False, []), (True, [])]

    detect_flake_occurrences.QueryAndStoreHiddenFlakes()
    self.assertIsNone(detect_flake_occurrences._GetLastCQHiddenFlakeQueryTime())
    detect_flake_occurrences.QueryAndStoreHiddenFlakes()
    self.assertEqual(
        datetime(2018, 12, 20),
        detect_flake_occurrences._GetLastCQHiddenFlakeQueryTime())
    detect_flake_occurrences.QueryAndStoreHiddenFlakes()
コード例 #5
0
def GetFlake(luci_project, original_step_name, original_test_name, master_name,
             builder_name, build_number):
    """Returns an existing Flake or creates one as needed.

  Args:
    luci_project (str): The project being analyzed, e.g. 'chromium'.
    original_step_name (str): The original step name which may contain hardware
      information and 'with(out) patch' etc. suffixes.
    original_test_name (str): The original test name.
    master_name (str): Master name of the build of the step.
    builder_name (str): Builder name of the build of the step.
    build_number (int): Build number of the build of the step.
  """
    normalized_step_name = Flake.LegacyNormalizeStepName(
        original_step_name, master_name, builder_name, build_number)
    normalized_test_name = Flake.NormalizeTestName(original_test_name,
                                                   original_step_name)
    flake = Flake.Get(luci_project, normalized_step_name, normalized_test_name)

    if not flake:  # pragma: no branch
        label = Flake.GetTestLabelName(original_test_name, original_step_name)
        flake = Flake.Create(luci_project, normalized_step_name,
                             normalized_test_name, label)
        flake.put()

    return flake
コード例 #6
0
    def testCIFlakes(self, _):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step_name'

        flake4 = Flake.Create(luci_project=luci_project,
                              normalized_step_name=normalized_step_name,
                              normalized_test_name='normalized_test_name_4',
                              test_label_name='test_label4')
        flake4.last_occurred_time = datetime(2018, 9, 1)
        flake4.put()
        flake4_key = flake4.key

        step_ui_name = 'step'
        luci_bucket = 'try'
        luci_builder = 'luci builder'
        legacy_master_name = 'buildbot master'

        for i in xrange(98761, 98765):
            occurrence = FlakeOccurrence.Create(
                flake_type=FlakeType.CQ_HIDDEN_FLAKE,
                build_id=i,
                step_ui_name=step_ui_name,
                test_name='t4',
                luci_project=luci_project,
                luci_bucket=luci_bucket,
                luci_builder=luci_builder,
                legacy_master_name=legacy_master_name,
                legacy_build_number=i,
                time_happened=datetime(2018, 8, 31),
                gerrit_cl_id=i,
                parent_flake_key=flake4_key)
            occurrence.put()

        occurrence10 = FlakeOccurrence.Create(
            flake_type=FlakeType.CI_FAILED_STEP,
            build_id=76543,
            step_ui_name=step_ui_name,
            test_name='t4',
            luci_project=luci_project,
            luci_bucket=luci_bucket,
            luci_builder=luci_builder,
            legacy_master_name=legacy_master_name,
            legacy_build_number=76543,
            time_happened=datetime(2018, 8, 31),
            gerrit_cl_id=-1,
            parent_flake_key=flake4_key)
        occurrence10.put()

        UpdateFlakeCounts()

        flake4 = flake4_key.get()
        self.assertEqual([
            FlakeCountsByType(flake_type=FlakeType.CQ_HIDDEN_FLAKE,
                              impacted_cl_count=4,
                              occurrence_count=4),
            FlakeCountsByType(flake_type=FlakeType.CI_FAILED_STEP,
                              impacted_cl_count=-1,
                              occurrence_count=1)
        ], flake4.flake_counts_last_week)
        self.assertEqual(14, flake4.flake_score_last_week)
コード例 #7
0
    def testGetFlakeIssueNoIssueKey(self):
        flake = Flake.Create(luci_project='chromium',
                             normalized_step_name='step',
                             normalized_test_name='suite.test',
                             test_label_name='*/suite.test/*')
        flake.put()

        self.assertIsNone(flake.GetIssue())
コード例 #8
0
    def testCreate(self):
        luci_project = 'chromium'
        step_ui_name = 'step'
        test_name = 'test'

        normalized_step_name = 'normalized_step_name'
        normalized_test_name = 'normalized_test_name'
        test_label_name = 'test_label'
        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)
        flake.put()

        build_id = 123
        luci_bucket = 'try'
        luci_builder = 'luci builder'
        legacy_master_name = 'buildbot master'
        legacy_build_number = 999
        time_happened = datetime.datetime(2018, 1, 1)
        gerrit_cl_id = 98765

        cq_false_rejection_occurrence = FlakeOccurrence.Create(
            FlakeType.CQ_FALSE_REJECTION,
            build_id=build_id,
            step_ui_name=step_ui_name,
            test_name=test_name,
            luci_project=luci_project,
            luci_bucket=luci_bucket,
            luci_builder=luci_builder,
            legacy_master_name=legacy_master_name,
            legacy_build_number=legacy_build_number,
            time_happened=time_happened,
            gerrit_cl_id=gerrit_cl_id,
            parent_flake_key=flake.key)
        cq_false_rejection_occurrence.put()

        retry_with_patch_occurrence = FlakeOccurrence.Create(
            FlakeType.RETRY_WITH_PATCH,
            build_id=build_id,
            step_ui_name=step_ui_name,
            test_name=test_name,
            luci_project=luci_project,
            luci_bucket=luci_bucket,
            luci_builder=luci_builder,
            legacy_master_name=legacy_master_name,
            legacy_build_number=legacy_build_number,
            time_happened=time_happened,
            gerrit_cl_id=gerrit_cl_id,
            parent_flake_key=flake.key)
        retry_with_patch_occurrence.put()

        fetched_flake_occurrences = FlakeOccurrence.query().fetch()
        self.assertEqual(2, len(fetched_flake_occurrences))
        self.assertIn(cq_false_rejection_occurrence, fetched_flake_occurrences)
        self.assertIn(retry_with_patch_occurrence, fetched_flake_occurrences)
        self.assertIsNotNone(fetched_flake_occurrences[0].time_detected)
        self.assertIsNotNone(fetched_flake_occurrences[1].time_detected)
コード例 #9
0
  def testAuthorizedAccessAndNewAnalysisNeededButNotTriggered(
      self, mock_mon, _):
    step = BuildStep.Create('m', 'b', 80, 's', datetime(2016, 10, 20))
    step.step_metadata = {
        'isolate_target_name': 'wf_s',
        'canonical_step_name': 'wf_s'
    }
    flake = Flake.Create('chromium', 's', 't', 'l')
    request = FlakeAnalysisRequest.Create('flake', False, 123)
    request.flake_key = flake.key
    request.build_steps = [step]
    user_email = '*****@*****.**'
    triggering_source = triggering_sources.FINDIT_UI

    def CheckForNewAnalysis(*_):
      step.wf_master_name = 'wf_m'
      step.wf_builder_name = 'wf_b'
      step.wf_build_number = 100
      step.wf_step_name = 'wf_s'
      return 1, step

    normalized_test = TestInfo('wf_m', 'wf_b', 100, 'wf_s', 'flake')
    original_test = TestInfo('m', 'b', 80, 's', 'flake')
    with mock.patch.object(
        flake_analysis_service,
        '_CheckForNewAnalysis',
        side_effect=CheckForNewAnalysis) as (
            mocked_CheckForNewAnalysis), mock.patch.object(
                flake_analysis_service.initialize_flake_pipeline,
                'ScheduleAnalysisIfNeeded',
                return_value=None) as (
                    mocked_ScheduleAnalysisIfNeeded), mock.patch.object(
                        flake_analysis_service.FlakeAnalysisRequest,
                        'GetVersion',
                        return_value=None) as mocked_GetVersion:
      self.assertFalse(
          flake_analysis_service.ScheduleAnalysisForFlake(
              request, user_email, True, triggering_sources.FINDIT_UI))
      mocked_CheckForNewAnalysis.assert_called_once_with(request, False)
      mocked_ScheduleAnalysisIfNeeded.assert_called_once_with(
          normalized_test,
          original_test,
          flake.key,
          bug_id=123,
          allow_new_analysis=True,
          manually_triggered=False,
          user_email=user_email,
          triggering_source=triggering_source,
          queue_name=constants.WATERFALL_ANALYSIS_QUEUE,
          force=False)
      self.assertFalse(mocked_GetVersion.called)
      mock_mon.assert_called_once_with(
          source='waterfall',
          operation='error',
          trigger='auto',
          canonical_step_name='wf_s',
          isolate_target_name='wf_s')
コード例 #10
0
  def testRemoveDisabledFlakes(self):
    flake_1 = Flake.Create('a', 'b', '1', 'test_label')
    flake_2 = Flake.Create('a', 'b', '2', 'test_label')
    flake_3 = Flake.Create('a', 'b', '3', 'test_label')

    luci_test_1 = LuciTest(
        key=LuciTest.CreateKey('a', 'b', 1),
        disabled_test_variants={('config',)},
    )
    luci_test_1.put()
    luci_test_2 = LuciTest(
        key=LuciTest.CreateKey('a', 'b', 2),
        disabled_test_variants=set(),
    )
    luci_test_2.put()
    self.assertEqual([flake_2, flake_3],
                     flake_detection_utils.RemoveDisabledFlakes(
                         [flake_1, flake_2, flake_3]))
コード例 #11
0
    def testGetIssueNoIssue(self):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step'
        normalized_test_name = 'a/b.html'
        test_label_name = 'test_label'

        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)

        self.assertIsNone(flake.GetIssue())
コード例 #12
0
    def testGetTestSuiteName(self):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step'
        normalized_test_name = 'a/b.html'
        test_label_name = 'test_label'

        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)
        flake.tags.append('suite::a')
        flake.put()
        self.assertEqual('a', flake.GetTestSuiteName())
コード例 #13
0
  def testRerunAnalysisWithAnalyzeFlakePipeline(
      self, mocked_analysis, mocked_pipeline, mocked_need_analysis,
      mocked_build_info, mock_dimensions, *_):
    buildbucket_id = 'id'
    mock_dimensions.return_value = ['os:Mac', 'cpu:x86']
    start_commit_position = 1000
    start_build_info = BuildInfo('m', 'b 1', 123)
    start_build_info.commit_position = start_commit_position
    start_build_info.chromium_revision = 'r1000'
    start_build_info.buildbucket_id = buildbucket_id
    mocked_build_info.return_value = start_build_info
    mocked_analysis.pipeline_status_path.return_value = 'status'
    mocked_analysis.key.urlsafe.return_value = 'urlsafe_key'
    mocked_need_analysis.return_value = (True, mocked_analysis)
    test = TestInfo('m', 'b 1', 123, 's', 't')
    manually_triggered = False
    flake = Flake.Create('chromium', 's', 't', 'l')

    analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded(
        test,
        test,
        flake.key,
        bug_id=None,
        allow_new_analysis=True,
        manually_triggered=manually_triggered,
        force=True,
        queue_name=constants.DEFAULT_QUEUE)

    self.assertIsNotNone(analysis)
    self.assertEqual(buildbucket_id, analysis.build_id)
    self.assertEqual(buildbucket_id, analysis.original_build_id)

    analyze_flake_input = AnalyzeFlakeInput(
        analysis_urlsafe_key='urlsafe_key',
        analyze_commit_position_parameters=NextCommitPositionOutput(
            culprit_commit_id=None,
            next_commit_id=CommitID(
                commit_position=start_commit_position,
                revision=start_build_info.chromium_revision)),
        commit_position_range=IntRange(lower=None, upper=start_commit_position),
        dimensions=ListOfBasestring.FromSerializable(
            ['os:Mac', 'cpu:x86', 'pool:luci.chromium.findit']),
        manually_triggered=manually_triggered,
        rerun=True,
        retries=0,
        step_metadata=StepMetadata.FromSerializable({}))

    mocked_pipeline.assert_has_calls([
        mock.call(analyze_flake_input),
        mock.call().start(queue_name=constants.DEFAULT_QUEUE)
    ])
コード例 #14
0
ファイル: component_test.py プロジェクト: xinghun61/infra
def _CreateFlake(flake_data, with_component=True):
    """
  Args:
    with_component (bool): Sets flake.component if True, otherwise sets tags.
  """

    luci_project = 'chromium'
    normalized_step_name = 'normalized_step_name'

    flake_issue = _GetOrCreateFlakeIssue(flake_data['bug_id'])

    flake = Flake.Create(normalized_test_name=flake_data['test'],
                         luci_project=luci_project,
                         normalized_step_name=normalized_step_name,
                         test_label_name='test_label')

    if with_component:
        flake.component = flake_data['component']
    else:
        flake.tags = ['component::{}'.format(flake_data['component'])]
    flake.flake_issue_key = flake_issue.key
    flake.flake_counts_last_week = []
    for flake_type, counts in flake_data['counts'].iteritems():
        flake.flake_counts_last_week.append(
            FlakeCountsByType(flake_type=flake_type,
                              occurrence_count=counts[0],
                              impacted_cl_count=counts[1]))
    flake.last_occurred_time = datetime.strptime(
        flake_data['last_occurred_time'], '%Y-W%W-%w')
    flake.put()

    for occurrence_data in flake_data['occurrences']:
        time_happened = datetime.strptime('2018-%d-4' % occurrence_data[2],
                                          '%Y-%W-%w')
        hour = occurrence_data[3]
        time_happened += timedelta(hours=hour)
        occurrence = FlakeOccurrence.Create(
            flake_type=occurrence_data[0],
            build_id=123 + hour,
            step_ui_name='step',
            test_name=flake.normalized_test_name,
            luci_project='chromium',
            luci_bucket='try',
            luci_builder='builder',
            legacy_master_name='master',
            legacy_build_number=42,
            time_happened=time_happened,
            gerrit_cl_id=occurrence_data[1],
            parent_flake_key=flake.key)
        occurrence.put()
コード例 #15
0
    def testGetFlakeIssue(self):
        flake_issue = FlakeIssue.Create(monorail_project='chromium',
                                        issue_id=12345)
        flake_issue.put()
        flake_issue_key = flake_issue.key
        flake = Flake.Create(luci_project='chromium',
                             normalized_step_name='step',
                             normalized_test_name='suite.test',
                             test_label_name='*/suite.test/*')
        flake.flake_issue_key = flake_issue_key
        flake.put()

        self.assertEqual(flake_issue_key,
                         flake.GetIssue(up_to_date=True, key_only=True))
コード例 #16
0
    def testGetFlakeInformationNoOccurrences(self):

        luci_project = 'chromium'
        normalized_step_name = 'normalized_step_name'
        normalized_test_name = 'normalized_test_name_2'
        test_label_name = 'test_label'
        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)
        flake.put()

        self.assertIsNone(
            flake_detection_utils.GetFlakeInformation(flake, None))
コード例 #17
0
    def testGetIssue(self):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step'
        normalized_test_name = 'a/b.html'
        test_label_name = 'test_label'
        bug_id = 12345

        flake_issue = FlakeIssue.Create(luci_project, bug_id)
        flake_issue.put()
        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)
        flake.flake_issue_key = flake_issue.key
        self.assertEqual(flake_issue, flake.GetIssue())
コード例 #18
0
    def testGetFlakeIssueDataInconsistent(self):
        flake_issue = FlakeIssue.Create(monorail_project='chromium',
                                        issue_id=12345)
        flake_issue.put()
        flake_issue_key = flake_issue.key
        flake = Flake.Create(luci_project='chromium',
                             normalized_step_name='step',
                             normalized_test_name='suite.test',
                             test_label_name='*/suite.test/*')
        flake.flake_issue_key = flake_issue_key
        flake.put()

        flake_issue_key.delete()

        self.assertIsNone(flake.GetIssue())
コード例 #19
0
    def testCreate(self):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step'
        normalized_test_name = 'normalized_test'
        test_label_name = 'test_label'

        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)

        flake.put()

        fetched_flakes = Flake.query().fetch()
        self.assertEqual(1, len(fetched_flakes))
        self.assertEqual(flake, fetched_flakes[0])
コード例 #20
0
    def testAttachCulpritFlakeIssueToFlakeNoCulpritFlakeIssue(self):
        project = 'chromium'
        step_name = 's'
        test_name = 't'
        label = 'l'
        revision = 'r1000'
        commit_position = 1000

        flake = Flake.Create(project, step_name, test_name, label)
        flake.put()

        culprit = FlakeCulprit.Create(project, revision, commit_position)
        culprit.put()
        self.assertIsNone(
            flake_analysis_actions._AttachCulpritFlakeIssueToFlake(
                flake, culprit.key))
コード例 #21
0
    def testGetComponent(self):
        flake = Flake.Create(luci_project='chromium',
                             normalized_step_name='step',
                             normalized_test_name='suite.test',
                             test_label_name='*/suite.test/*')
        flake.put()
        self.assertEqual('Unknown', flake.GetComponent())

        flake.tags = ['component::ComponentA']
        flake.put()
        self.assertEqual('ComponentA', flake.GetComponent())

        # Just for test purpose, flake.component should be the same as its component
        # tag.
        flake.component = 'ComponentB'
        flake.put()
        self.assertEqual('ComponentB', flake.GetComponent())
コード例 #22
0
    def testOnCulpritIdentified(self, mocked_update_monorail,
                                mocked_update_issues, mocked_merge):
        project = 'chromium'
        master_name = 'm'
        builder_name = 'b'
        build_number = 123
        step_name = 's'
        test_name = 't'
        label = 'l'
        bug_id = 12345
        merged_bug_id = 12344
        revision = 'r1000'
        commit_position = 1000

        merged_issue = FlakeIssue.Create(project, merged_bug_id)
        merged_issue.put()
        issue = FlakeIssue.Create(project, bug_id)
        issue.merge_destination_key = merged_issue.key
        issue.put()

        flake = Flake.Create(project, step_name, test_name, label)
        flake.flake_issue_key = issue.key
        flake.put()

        culprit = FlakeCulprit.Create(project, revision, commit_position)
        culprit.flake_issue_key = merged_issue.key
        culprit.put()

        mocked_merge.return_value = (issue.key, merged_issue.key)

        analysis = MasterFlakeAnalysis.Create(master_name, builder_name,
                                              build_number, step_name,
                                              test_name)
        analysis.flake_key = flake.key
        analysis.culprit_urlsafe_key = culprit.key.urlsafe()
        analysis.confidence_in_culprit = 0.9
        analysis.put()

        flake_analysis_actions.OnCulpritIdentified(analysis.key.urlsafe())

        mocked_merge.assert_called_once_with(issue.key, culprit.key)
        mocked_update_issues.assert_called_once_with(
            issue.key, issue.merge_destination_key)
        mocked_update_monorail.assert_called_once_with(analysis.key.urlsafe())
コード例 #23
0
ファイル: flake_util_test.py プロジェクト: xinghun61/infra
  def testGetFlakeExisting(self, mocked_create, mocked_test_name,
                           mocked_step_name):
    luci_project = 'chromium'
    step_name = 'step_name'
    test_name = 'test_name'
    master_name = 'm'
    builder_name = 'b'
    build_number = 123
    label = 'label'
    mocked_test_name.return_value = test_name
    mocked_step_name.return_value = step_name

    flake = Flake.Create(luci_project, step_name, test_name, label)
    flake.put()

    self.assertEqual(
        flake,
        flake_util.GetFlake(luci_project, step_name, test_name, master_name,
                            builder_name, build_number))
コード例 #24
0
  def testAnalysisIsNeededWhenNoneExistsAndAllowedToSchedule(self):
    mocked_now = datetime(2017, 05, 01, 10, 10, 10)
    self.MockUTCNow(mocked_now)

    test = TestInfo('m', 'b 1', 123, 's', 't')
    flake = Flake.Create('chromium', 's', 't', 'label')
    need_analysis, analysis = initialize_flake_pipeline._NeedANewAnalysis(
        test,
        test,
        flake.key,
        None,
        user_email='*****@*****.**',
        allow_new_analysis=True)

    self.assertTrue(need_analysis)
    self.assertIsNotNone(analysis)
    self.assertEqual(flake.key, analysis.flake_key)
    self.assertFalse(analysis.triggering_user_email_obscured)
    self.assertEqual(mocked_now, analysis.request_time)
コード例 #25
0
    def testNoOccurrences(self, _):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step_name'

        flake2 = Flake.Create(luci_project=luci_project,
                              normalized_step_name=normalized_step_name,
                              normalized_test_name='normalized_test_name_2',
                              test_label_name='test_label2')
        flake2.last_occurred_time = datetime(2017, 9, 1)
        flake2.false_rejection_count_last_week = 5
        flake2.impacted_cl_count_last_week = 3
        flake2.flake_score_last_week = 10
        flake2.put()
        flake2_key = flake2.key

        UpdateFlakeCounts()

        flake2 = flake2_key.get()
        self.assertEqual([], flake2.flake_counts_last_week)
        self.assertEqual(0, flake2.flake_score_last_week)
コード例 #26
0
    def testGet(self):
        luci_project = 'chromium'
        normalized_step_name = 'normalized_step'
        normalized_test_name = 'normalized_test'
        test_label_name = 'test_label'

        flake = Flake.Create(luci_project=luci_project,
                             normalized_step_name=normalized_step_name,
                             normalized_test_name=normalized_test_name,
                             test_label_name=test_label_name)

        flake.put()

        retrieved_flake = Flake.Get(luci_project, normalized_step_name,
                                    normalized_test_name)
        self.assertIsNotNone(retrieved_flake)
        self.assertEqual(normalized_test_name,
                         retrieved_flake.normalized_test_name)
        self.assertEqual(normalized_step_name,
                         retrieved_flake.normalized_step_name)
コード例 #27
0
  def testGetTestLocationWithFlake(self):
    luci_project = detect_disabled_tests._DEFAULT_LUCI_PROJECT
    normalized_step_name = 'normal_step'
    normalized_test_name = 'normal_test'
    flake = Flake.Create(luci_project, normalized_step_name,
                         normalized_test_name, 'label')
    flake.tags = sorted({
        'watchlist::feature',
        'watchlist::url',
        'directory::base/feature/',
        'directory::base/',
        'source::base/feature/url_test.cc',
        'component::root>a>b',
        'parent_component::root>a>b',
        'parent_component::root>a',
        'parent_component::root',
        'step::from/flake',
        'test_type::from/flake',
        'other_tag::from/flake',
    })
    flake.put()

    expected_tags = sorted({
        'test_type::step',
        'step::step (with patch)',
        'watchlist::feature',
        'watchlist::url',
        'directory::base/feature/',
        'directory::base/',
        'source::base/feature/url_test.cc',
        'component::root>a>b',
        'parent_component::root>a>b',
        'parent_component::root>a',
        'parent_component::root',
    })
    self.assertEqual(
        expected_tags,
        sorted(
            detect_disabled_tests._GetNewTestTags(
                {}, 'step (with patch)', 'test', normalized_step_name,
                normalized_test_name, 123, {}, {})))
コード例 #28
0
  def testAnalysisIsNeededForCompletedAnalysisWithForce(self):
    master_name = 'm'
    builder_name = 'b 1'
    build_number = 123
    step_name = 's'
    test_name = 't'
    flake = Flake.Create('chromium', step_name, test_name, 'l')
    analysis = _CreateAndSaveMasterFlakeAnalysis(
        master_name,
        builder_name,
        build_number,
        step_name,
        test_name,
        status=analysis_status.COMPLETED)
    analysis.flake_key = flake.key
    data_point = DataPoint()
    data_point.pass_rate = .5
    data_point.build_number = 100
    analysis.data_points.append(data_point)
    analysis.put()

    mocked_now = datetime(2017, 05, 01, 10, 10, 10)
    self.MockUTCNow(mocked_now)

    test = TestInfo(master_name, builder_name, build_number, step_name,
                    test_name)
    need_analysis, analysis = initialize_flake_pipeline._NeedANewAnalysis(
        test,
        test,
        flake.key,
        None,
        user_email='*****@*****.**',
        allow_new_analysis=True,
        force=True)

    self.assertTrue(need_analysis)
    self.assertIsNotNone(analysis)
    self.assertFalse(analysis.triggering_user_email_obscured)
    self.assertEqual(mocked_now, analysis.request_time)
    self.assertEqual(analysis.version_number, 2)
    self.assertEqual([], analysis.data_points)
コード例 #29
0
    def testUpdateMonorailBugWithCulprit(self, mock_update, mock_comments,
                                         mock_get_issue, *_):
        project = 'chromium'
        bug_id = 12345
        step_name = 's'
        test_name = 't'
        label = 'l'

        flake_issue = FlakeIssue.Create(project, bug_id)
        flake_issue.put()

        flake = Flake.Create(project, step_name, test_name, label)
        flake.flake_issue_key = flake_issue.key
        flake.put()

        analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't')
        analysis.flake_key = flake.key
        analysis.put()

        mock_comments.return_value = [
            Comment({
                'author': {
                    'name': '*****@*****.**'
                },
                'content': '',
                'published': None,
                'id': '12345',
            }),
        ]
        mock_get_issue.return_value = Issue({
            'status': 'Available',
            'projectId': 'chromium',
            'id': str(bug_id),
            'state': 'open'
        })
        flake_analysis_actions.UpdateMonorailBugWithCulprit(
            analysis.key.urlsafe())

        mock_update.assert_called_once_with(bug_id, mock.ANY)
        self.assertIsNotNone(
            flake_issue.last_updated_time_with_analysis_results)
コード例 #30
0
def _CreateFlakeFromRow(row):
    """Creates a Flake entity from a row fetched from BigQuery."""
    luci_project = row['luci_project']
    luci_builder = row['luci_builder']
    legacy_master_name = row['legacy_master_name']
    legacy_build_number = row['legacy_build_number']
    step_ui_name = row['step_ui_name']
    test_name = row['test_name']

    normalized_step_name = Flake.NormalizeStepName(
        step_name=step_ui_name,
        master_name=legacy_master_name,
        builder_name=luci_builder,
        build_number=legacy_build_number)
    normalized_test_name = Flake.NormalizeTestName(test_name, step_ui_name)
    test_label_name = Flake.GetTestLabelName(test_name, step_ui_name)

    return Flake.Create(luci_project=luci_project,
                        normalized_step_name=normalized_step_name,
                        normalized_test_name=normalized_test_name,
                        test_label_name=test_label_name)