Exemple #1
0
    def testAnalysisAborted(self):
        crash_identifiers = self.GetDummyChromeCrashData()['crash_identifiers']
        analysis = FracasCrashAnalysis.Create(crash_identifiers)
        analysis.status = analysis_status.RUNNING
        analysis.put()

        pipeline = crash_pipeline.CrashAnalysisPipeline(
            CrashClient.FRACAS, crash_identifiers)
        pipeline._PutAbortedError()
        analysis = FracasCrashAnalysis.Get(crash_identifiers)
        self.assertEqual(analysis_status.ERROR, analysis.status)
Exemple #2
0
 def testDoNotUseIdentifiersToSetProperties(self):
   crash_identifiers = {
     'chrome_version': '1',
     'signature': 'signature/here',
     'channel': 'canary',
     'platform': 'win',
     'process_type': 'browser',
   }
   FracasCrashAnalysis.Create(crash_identifiers).put()
   analysis = FracasCrashAnalysis.Get(crash_identifiers)
   self.assertIsNone(analysis.crashed_version)
   self.assertIsNone(analysis.signature)
   self.assertIsNone(analysis.channel)
   self.assertIsNone(analysis.platform)
    def testProcessResultForPublishing(self, mocked_get_default_host,
                                       mocked_urlsafe):
        mocked_host = 'http://host'
        mocked_get_default_host.return_value = mocked_host
        urlsafe_key = 'abcde'
        mocked_urlsafe.return_value = urlsafe_key

        crash_identifiers = {'signature': 'sig'}
        analysis = FracasCrashAnalysis.Create(crash_identifiers)
        analysis.result = {'other': 'data'}
        expected_processed_suspect = {
            'client_id': self._client.client_id,
            'crash_identifiers': {
                'signature': 'sig'
            },
            'result': {
                'feedback_url':
                crash_analysis._FEEDBACK_URL_TEMPLATE %
                (mocked_host, CrashClient.FRACAS, urlsafe_key),
                'other':
                'data'
            }
        }

        self.assertDictEqual(
            self._client.GetPublishableResult(crash_identifiers, analysis),
            expected_processed_suspect)
 def testGetAnalysis(self):
     crash_identifiers = {'signature': 'sig'}
     # TODO(wrengr): would be less fragile to call
     # FinditForFracas.CreateAnalysis instead.
     analysis = FracasCrashAnalysis.Create(crash_identifiers)
     analysis.put()
     self.assertEqual(self._client.GetAnalysis(crash_identifiers), analysis)
    def testUpdateInvetedIndexHandlerWithStacktraces(self):
        """Tests ``UpdateInvertedIndex`` handler when there are stacktraces."""
        crash_analysis = FracasCrashAnalysis.Create('sig1')
        crash_analysis.identifiers = {'signature': 'sig1'}
        crash_analysis.requested_time = datetime.utcnow() - timedelta(hours=1)

        frames = [
            StackFrame(0, 'src/', 'fun1', 'f1.cc', 'src/f1.cc', [2, 3],
                       'http://repo'),
            StackFrame(0, 'src/', 'fun2', 'f2.cc', 'xx/src/f2.cc', [8, 10],
                       'http://repo'),
            StackFrame(0, 'src/', 'fun3', 'f3.cc', 'y/src/f3.cc', [20, 30],
                       'http://repo')
        ]
        callstack = CallStack(0, frames)

        crash_analysis.stacktrace = Stacktrace([callstack], callstack)
        crash_analysis.put()

        response = self.test_app.get('/process/update-inverted-index',
                                     headers={'X-AppEngine-Cron': 'true'})
        self.assertEqual(response.status_int, 200)
        self.assertEqual(ChromeCrashInvertedIndex.GetRoot().n_of_doc, 1)
        self.assertEqual(ChromeCrashInvertedIndex.Get('src/f1.cc').n_of_doc, 1)
        self.assertEqual(ChromeCrashInvertedIndex.Get('src/f2.cc').n_of_doc, 1)
        self.assertEqual(ChromeCrashInvertedIndex.Get('src/f3.cc').n_of_doc, 1)
    def testUpdateInvetedIndexHandlerWithNoStacktrace(self):
        """Tests ``UpdateInvertedIndex`` handler when there is no stacktraces."""
        crash_analysis1 = FracasCrashAnalysis.Create('sig1')
        crash_analysis1.signature = 'sig1'
        crash_analysis1.requested_time = datetime.utcnow() - timedelta(hours=1)
        crash_analysis1.put()
        crash_analysis2 = FracasCrashAnalysis.Create('sig2')
        crash_analysis2.signature = 'sig2'
        crash_analysis2.requested_time = datetime.utcnow() - timedelta(hours=1)
        crash_analysis2.put()

        response = self.test_app.get('/process/update-inverted-index',
                                     headers={'X-AppEngine-Cron': 'true'})
        self.assertEqual(response.status_int, 200)
        self.assertEqual(ChromeCrashInvertedIndex.GetRoot().n_of_doc, 2)
        self.assertEqual(ChromeCrashInvertedIndex.query().fetch(), [])
Exemple #7
0
    def setUp(self):
        super(RerunPipelineTest, self).setUp()
        self.crash_analyses = [
            FracasCrashAnalysis.Create({'signature': 'sig1'}),
            FracasCrashAnalysis.Create({'signature': 'sig2'}),
            FracasCrashAnalysis.Create({'signature': 'sig3'})
        ]
        self.crash_analyses[0].requested_time = datetime(2017, 6, 1, 2, 0, 0)
        self.crash_analyses[1].requested_time = datetime(2017, 6, 5, 9, 0, 0)
        self.crash_analyses[2].requested_time = datetime(2017, 6, 10, 3, 0, 0)

        self.crash_analyses[0].identifiers = 'sig1'
        self.crash_analyses[1].identifiers = 'sig2'
        self.crash_analyses[2].identifiers = 'sig3'

        ndb.put_multi(self.crash_analyses)
Exemple #8
0
    def testProcessResultForPublishing(self, mocked_get_default_host,
                                       mocked_urlsafe):
        mocked_host = 'http://host'
        mocked_get_default_host.return_value = mocked_host
        urlsafe_key = 'abcde'
        mocked_urlsafe.return_value = urlsafe_key

        crash_identifiers = {
            'testcase_id':
            'predator_for_chromecrash_test_process_result_for_publishing'
        }
        analysis = FracasCrashAnalysis.Create(crash_identifiers)
        analysis.result = {'other': 'data'}
        analysis.status = analysis_status.COMPLETED
        analysis.identifiers = crash_identifiers
        analysis.log.Reset()
        analysis.put()
        expected_processed_suspect = {
            'client_id': self._client.client_id,
            'crash_identifiers': crash_identifiers,
            'result': {
                'feedback_url':
                crash_analysis._FEEDBACK_URL_TEMPLATE %
                (mocked_host, CrashClient.FRACAS, urlsafe_key),
                'other':
                'data'
            }
        }

        self.assertDictEqual(
            self._client.ResultMessageToClient(crash_identifiers),
            expected_processed_suspect)
Exemple #9
0
    def testFindCulpritFails(self, mock_find_culprit):
        crash_identifiers = self.GetDummyChromeCrashData()['crash_identifiers']
        analysis = FracasCrashAnalysis.Create(crash_identifiers)
        analysis.status = analysis_status.RUNNING
        analysis.put()

        mock_find_culprit.side_effect = Exception()
        pipeline = crash_pipeline.CrashAnalysisPipeline(
            CrashClient.FRACAS, crash_identifiers)
        pipeline.run()

        analysis = FracasCrashAnalysis.Get(crash_identifiers)
        self.assertEqual(analysis_status.ERROR, analysis.status)
        self.assertFalse(analysis.result['found'])
        self.assertFalse(analysis.found_suspects)
        self.assertFalse(analysis.found_project)
        self.assertFalse(analysis.found_components)
Exemple #10
0
  def testFindCulpritFails(self):
    crash_identifiers = self.GetDummyChromeCrashData()['crash_identifiers']
    analysis = FracasCrashAnalysis.Create(crash_identifiers)
    analysis.status = analysis_status.RUNNING
    analysis.put()

    self.mock(FinditForFracas, 'FindCulprit', lambda *_: None)
    pipeline = crash_pipeline.CrashAnalysisPipeline(
        CrashClient.FRACAS,
        crash_identifiers)
    pipeline.run()

    analysis = FracasCrashAnalysis.Get(crash_identifiers)
    self.assertEqual(analysis_status.COMPLETED, analysis.status)
    self.assertFalse(analysis.result['found'])
    self.assertFalse(analysis.found_suspects)
    self.assertFalse(analysis.found_project)
    self.assertFalse(analysis.found_components)
Exemple #11
0
    def testFindCulpritSucceeds(self, mock_find_culprit):
        crash_identifiers = self.GetDummyChromeCrashData()['crash_identifiers']
        analysis = FracasCrashAnalysis.Create(crash_identifiers)
        analysis.status = analysis_status.RUNNING
        analysis.put()

        dummy_cl = ChangeLog(
            Contributor('AUTHOR_NAME', 'AUTHOR_EMAIL', 'AUTHOR_TIME'),
            Contributor('COMITTER_NAME', 'COMITTER_EMAIL', 'COMITTER_TIME'),
            'REVISION',
            'COMMIT_POSITION',
            'MESSAGE',
            'TOUCHED_FILES',
            'COMMIT_URL',
        )
        dummy_project_path = 'PROJECT_PATH'
        dummy_suspect = Suspect(dummy_cl, dummy_project_path)
        dummy_culprit = Culprit(
            project='PROJECT',
            components=['COMPONENT_1', 'CPOMPONENT_2'],
            suspected_cls=[dummy_suspect],
            # N.B., we must use a list here for the assertion to work
            # TODO(wrengr): fix that.
            regression_range=['VERSION_0', 'VERSION_1'],
            algorithm='ALGORITHM',
            success=True,
        )
        mock_find_culprit.return_value = dummy_culprit
        pipeline = crash_pipeline.CrashAnalysisPipeline(
            CrashClient.FRACAS, crash_identifiers)
        pipeline.start()
        self.execute_queued_tasks()

        analysis = FracasCrashAnalysis.Get(crash_identifiers)
        self.assertEqual(analysis_status.COMPLETED, analysis.status)
        self.assertTrue(analysis.result['found'])
        self.assertTrue(analysis.found_suspects)
        self.assertTrue(analysis.found_project)
        self.assertTrue(analysis.found_components)
        dummy_suspect, dummy_tags = dummy_culprit.ToDicts()
        self.assertDictEqual(analysis.result, dummy_suspect)
    def setUp(self):
        super(ResultFeedbackTest, self).setUp()
        self.handler = MockResultFeedback()
        self.mock_current_user(user_email='*****@*****.**', is_admin=True)

        analysis = FracasCrashAnalysis.Create({'signature': 'signature'})
        analysis.signature = 'signature'
        analysis.crashed_version = '53.0.2750.0'
        analysis.stack_trace = 'dummy\nframe1\nframe2'
        analysis.platform = 'android'
        analysis.channel = 'canary'
        analysis.status = analysis_status.COMPLETED
        analysis.regression_range = ['53.0.2749.0', '53.0.2750.0']
        analysis.historical_metadata = [{
            'chrome_version': '53.0.2748.0',
            'cpm': 0
        }, {
            'chrome_version': '53.0.2749.0',
            'cpm': 0
        }, {
            'chrome_version': '53.0.2750.0',
            'cpm': 0.8
        }]

        suspected_cl = {
            'url': 'https://chromium.googlesource.com/chromium/src/+/346a',
            'review_url': 'https://review',
            'revision': '346a',
            'project_path': 'src/',
            'author': '*****@*****.**',
            'time': '2016-06-04 00:00:00 UTC',
            'reason': 'some reason',
            'confidence': 1
        }

        analysis.result = {
            'found': True,
            'suspected_cls': [suspected_cl],
            'suspected_components': ['Blink>API', 'Blink>DOM'],
            'suspected_project': 'chromium',
            'regression_range': ['53.0.2749.0', '53.0.2750.0'],
            'log': {
                'warning': {
                    'NoRegressionRange': 'blabla...'
                }
            },
        }
        analysis.found_suspects = True
        analysis.note = 'This is a note.'
        analysis.put()

        self.analysis = analysis
    def testFindCulprit(self):
        self.mock(FinditForChromeCrash, 'FindCulprit', lambda self, *_: None)

        # TODO(wrengr): would be less fragile to call
        # FinditForFracas.CreateAnalysis instead; though if I'm right about
        # the original purpose of this test, then this is one of the few
        # places where calling FracasCrashAnalysis directly would actually
        # make sense.
        analysis = FracasCrashAnalysis.Create({'signature': 'sig'})
        findit_client = _FinditForChromeCrash(
            GitilesRepository.Factory(HttpClientAppengine()),
            CrashConfig.Get())
        self.assertIsNone(findit_client.FindCulprit(analysis))
Exemple #14
0
    def testFindCulprit(self, mock_find_culprit):
        mock_find_culprit.return_value = None

        # TODO(wrengr): would be less fragile to call
        # PredatorForFracas.CreateAnalysis instead; though if I'm right about
        # the original purpose of this test, then this is one of the few
        # places where calling FracasCrashAnalysis directly would actually
        # make sense.
        analysis = FracasCrashAnalysis.Create({'signature': 'sig'})
        predator_client = _PredatorForChromeCrash(
            GitilesRepository.Factory(HttpClientAppengine()),
            CrashConfig.Get())
        self.assertIsNone(predator_client.FindCulprit(analysis))
Exemple #15
0
 def GetAnalysis(self, crash_identifiers):
     # TODO: inline FracasCrashAnalysis.Get stuff here.
     return FracasCrashAnalysis.Get(crash_identifiers)
Exemple #16
0
 def CreateAnalysis(self, crash_identifiers):
     # TODO: inline FracasCrashAnalysis.Create stuff here.
     return FracasCrashAnalysis.Create(crash_identifiers)