예제 #1
0
파일: admin.py 프로젝트: B-Rich/crashkit
 def process_pending_reports(self, item):
   if item == None:
     return 40, Report.all().filter('status =', 0)
   try:
     process_report(item)
   except Exception, e:
     item.status = 2
     item.put()
     self.response.out.write("""<div>Error: %s %s</div>""" % (e.__class__.__name__, e.message));
예제 #2
0
    def test_params_plumbing_success(self, MockProcessor):
        # Set up mock context manager to return self.
        mock = MockProcessor.return_value
        mock.__enter__.return_value = mock
        mock.check_existing_run.return_value = False
        mock.results = ['/tmp/wpt_report.json.gz']
        mock.raw_results_url = 'https://wpt.fyi/test/report.json'
        mock.results_url = 'https://wpt.fyi/test'
        mock.test_run_id = 654321

        # NOTE: if you need to change the following params, you probably also
        # want to change api/receiver/api.go.
        params = MultiDict({
            'uploader':
            'blade-runner',
            'id':
            '654321',
            'callback_url':
            'https://test.wpt.fyi/api',
            'labels':
            'foo,bar',
            'results':
            'https://wpt.fyi/wpt_report.json.gz',
            'browser_name':
            'Chrome',
            'browser_version':
            '70',
            'os_name':
            'Linux',
            'os_version':
            '5.0',
            'revision':
            '21917b36553562d21c14fe086756a57cbe8a381b',
        })
        process_report('12345', params)
        mock.assert_has_calls([
            call.update_status('654321', 'WPTFYI_PROCESSING', None,
                               'https://test.wpt.fyi/api'),
            call.download(['https://wpt.fyi/wpt_report.json.gz'], [], None),
        ])
        mock.report.update_metadata.assert_called_once_with(
            revision='21917b36553562d21c14fe086756a57cbe8a381b',
            browser_name='Chrome',
            browser_version='70',
            os_name='Linux',
            os_version='5.0')
        mock.create_run.assert_called_once_with('654321', 'foo,bar',
                                                'blade-runner',
                                                'https://test.wpt.fyi/api')
예제 #3
0
    def test_params_plumbing_empty(self, MockProcessor):
        # Set up mock context manager to return self.
        mock = MockProcessor.return_value
        mock.__enter__.return_value = mock
        mock.results = []

        params = MultiDict({
            'uploader': 'blade-runner',
            'id': '654321',
        })
        with self.assertLogs():
            process_report('12345', params)
        mock.assert_has_calls([
            call.update_status('654321', 'WPTFYI_PROCESSING', None, None),
            call.download([], [], None),
            call.update_status('654321', 'EMPTY', None, None),
        ])
        mock.create_run.assert_not_called()
예제 #4
0
def task_handler():
    _atomic_write(TIMESTAMP_FILE, str(time.time()))

    app.logger.info('Processing task %s',
                    flask.request.headers.get('X-AppEngine-TaskName'))
    resp = processor.process_report(flask.request.form)
    status = HTTPStatus.CREATED if resp else HTTPStatus.NO_CONTENT
    app.logger.info(resp)

    return (resp, status)
예제 #5
0
    def test_params_plumbing_duplicate(self, MockProcessor):
        # Set up mock context manager to return self.
        mock = MockProcessor.return_value
        mock.__enter__.return_value = mock
        mock.check_existing_run.return_value = True
        mock.results = ['/tmp/wpt_report.json.gz']
        mock.raw_results_url = 'https://wpt.fyi/test/report.json'

        params = MultiDict({
            'uploader': 'blade-runner',
            'id': '654321',
            'results': 'https://wpt.fyi/wpt_report.json.gz',
        })
        with self.assertLogs():
            process_report('12345', params)
        mock.update_status.assert_has_calls([
            call('654321', 'WPTFYI_PROCESSING', None, None),
            call('654321', 'DUPLICATE', None, None),
        ])
        mock.create_run.assert_not_called()
예제 #6
0
    def test_params_plumbing(self, MockProcessor):
        mock = MockProcessor.return_value
        mock.__enter__.return_value = mock
        mock.check_existing_run.return_value = False
        mock.results = ['/tmp/wpt_report.json.gz']
        mock.raw_results_url = 'https://wpt.fyi/test/report.json'
        mock.results_url = 'https://wpt.fyi/test'
        mock.test_run_id = 654321

        # NOTE: if you need to change the following params, you probably also
        # want to change api/receiver/api.go.
        params = MultiDict({
            'uploader': 'blade-runner',
            'id': '654321',
            'callback_url': 'https://test.wpt.fyi/api',
            'labels': 'foo,bar',
            'results': 'https://wpt.fyi/wpt_report.json.gz',
        })
        process_report('12345', params)
        mock.download.assert_called_once()
        mock.create_run.assert_called_once_with('654321', 'foo,bar',
                                                'blade-runner',
                                                'https://test.wpt.fyi/api')
예제 #7
0
    def test_params_plumbing_error(self, MockProcessor):
        # Set up mock context manager to return self.
        mock = MockProcessor.return_value
        mock.__enter__.return_value = mock
        mock.results = ['/tmp/wpt_report.json.gz']
        mock.load_report.side_effect = wptreport.InvalidJSONError

        params = MultiDict({
            'uploader': 'blade-runner',
            'id': '654321',
            'results': 'https://wpt.fyi/wpt_report.json.gz',
        })
        # Suppress print_exception.
        with patch('traceback.print_exception'):
            process_report('12345', params)
        mock.assert_has_calls([
            call.update_status('654321', 'WPTFYI_PROCESSING', None, None),
            call.download(['https://wpt.fyi/wpt_report.json.gz'], [], None),
            call.load_report(),
            call.update_status(
                '654321', 'INVALID',
                "Invalid JSON (['https://wpt.fyi/wpt_report.json.gz'])", None),
        ])
        mock.create_run.assert_not_called()