Пример #1
0
    def testToJson(self):
        """Tests ``ToJson`` method of CracasCrashAnalysis."""
        crash_identifiers = {
            'signature': 'signature/here',
        }
        CracasCrashAnalysis.Create(crash_identifiers).put()
        analysis = CracasCrashAnalysis.Get(crash_identifiers)
        analysis.stack_trace = json.dumps(['stack_trace1', 'stack_trace2'])

        self.assertEqual(analysis.ToJson()['stack_trace'],
                         ['stack_trace1', 'stack_trace2'])
Пример #2
0
    def setUp(self):
        super(RerunAnalysesTest, self).setUp()
        self.crash_analyses = [
            CracasCrashAnalysis.Create({'signature': 'sig1'}),
            CracasCrashAnalysis.Create({'signature': 'sig2'}),
            CracasCrashAnalysis.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)

        ndb.put_multi(self.crash_analyses)
 def testDoNotUseIdentifiersToSetProperties(self):
     crash_identifiers = {
         'chrome_version': '1',
         'signature': 'signature/here',
         'channel': 'canary',
         'platform': 'win',
         'process_type': 'browser',
     }
     CracasCrashAnalysis.Create(crash_identifiers).put()
     analysis = CracasCrashAnalysis.Get(crash_identifiers)
     self.assertIsNone(analysis.crashed_version)
     self.assertIsNone(analysis.signature)
     self.assertIsNone(analysis.channel)
     self.assertIsNone(analysis.platform)
Пример #4
0
    def testGetPublishableResultFoundTrue(self):
        analysis_result = {
            'found':
            True,
            'suspected_cls': [{
                'confidence': 0.21434,
                'reasons': ['reason1', 'reason2'],
                'other': 'data'
            }],
            'other_data':
            'data',
        }

        processed_analysis_result = copy.deepcopy(analysis_result)
        for cl in processed_analysis_result['suspected_cls']:
            cl['confidence'] = round(cl['confidence'], 2)

        crash_identifiers = {'signature': 'sig'}
        expected_processed_result = {
            'crash_identifiers': crash_identifiers,
            'client_id': self.findit.client_id,
            'result': processed_analysis_result,
        }

        analysis = CracasCrashAnalysis.Create(crash_identifiers)
        analysis.result = analysis_result

        self.assertDictEqual(
            self.findit.GetPublishableResult(crash_identifiers, analysis),
            expected_processed_result)
Пример #5
0
    def testHandleGetRerunOneCrashAnalysis(self, mock_run):
        """Tests that RerunPipeline ran once if there is one crash analysis."""
        mock_run.return_value = None
        crash_analysis = CracasCrashAnalysis.Create({'signature': 'sig'})
        crash_analysis.put()

        self.mock_current_user(user_email='*****@*****.**', is_admin=True)
        response = self.test_app.get('/process/rerun-analysis?key=%s' %
                                     crash_analysis.key.urlsafe())
        self.assertEqual(response.status_int, 200)
        self.assertTrue(mock_run.called)
Пример #6
0
    def testGetPublishableResultFoundFalse(self):
        analysis_result = {
            'found': False,
        }
        crash_identifiers = {'signature': 'sig'}
        expected_processed_result = {
            'crash_identifiers': crash_identifiers,
            'client_id': self.findit.client_id,
            'result': copy.deepcopy(analysis_result),
        }

        analysis = CracasCrashAnalysis.Create(crash_identifiers)
        analysis.result = analysis_result

        self.assertDictEqual(
            self.findit.GetPublishableResult(crash_identifiers, analysis),
            expected_processed_result)
Пример #7
0
 def GetAnalysis(self, crash_identifiers):
     # TODO: inline CracasCrashAnalysis.Get stuff here.
     return CracasCrashAnalysis.Get(crash_identifiers)
Пример #8
0
 def CreateAnalysis(self, crash_identifiers):
     # TODO: inline CracasCrashAnalysis.Create stuff here.
     return CracasCrashAnalysis.Create(crash_identifiers)