Esempio n. 1
0
 def testUpdateQuickLog_WithJobResults_NoError(self, mock_logging_error):
     job = self._AddTryJob(111,
                           'started',
                           'win_perf',
                           results_data=_SAMPLE_BISECT_RESULTS_JSON)
     update_bug_with_results.UpdateQuickLog(job)
     self.assertEqual(0, mock_logging_error.call_count)
Esempio n. 2
0
 def testUpdateQuickLog_NoResultsData_ReportsError(self, mock_log,
                                                   mock_logging_error):
     job = self._AddTryJob(111, 'started', 'win_perf')
     update_bug_with_results.UpdateQuickLog(job)
     self.assertEqual(0, mock_log.call_count)
     mock_logging_error.assert_called_once_with(
         'Bisect report returns empty for job id %s, bug_id %s.', 1, 111)
    def post(self):
        """Validates data parameter and saves to TryJob entity.

    Bisect results come from a "data" parameter, which is a JSON encoding of a
    dictionary.

    The required fields are "master", "bot", "test".

    Request parameters:
      data: JSON encoding of a dictionary.

    Outputs:
      Empty 200 response with if successful,
      200 response with warning message if optional data is invalid,
      403 response with error message if sender IP is not white-listed,
      400 response with error message if required data is invalid.
      500 with error message otherwise.
    """
        datastore_hooks.SetPrivilegedRequest()
        if not self._CheckIpAgainstWhitelist():
            return

        data = self.request.get('data')
        if not data:
            self.ReportError('Missing "data" parameter.', status=400)
            return

        try:
            data = json.loads(self.request.get('data'))
        except ValueError:
            self.ReportError('Invalid JSON string.', status=400)
            return

        logging.info('Received data: %s', data)

        try:
            _ValidateResultsData(data)
            job = _GetTryJob(data)
            if not job:
                self.ReportWarning('No try job found.')
                return
            _UpdateTryJob(job, data)
            update_bug_with_results.UpdateQuickLog(job)
        except BadRequestError as error:
            self.ReportError(error.message, status=400)