示例#1
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        log_id = int(self.request.get('id', 0))

        log = ReportLog.get_by_id(log_id)
        if not log or not log.commit:
            self.response.out.write("Not processed")
            return

        branch = log.branch()
        platform = log.platform()
        build = Build.get_or_insert_from_log(log)

        for test_name, result_value in log.results().iteritems():
            test = Test.update_or_insert(test_name, branch, platform)
            result = TestResult.get_or_insert_from_parsed_json(test_name, build, result_value)
            runs = Runs.get_by_objects(branch, platform, test)
            regenerate_runs = True
            if runs:
                runs.update_incrementally(build, result)
                regenerate_runs = False
            schedule_runs_update(test.id, branch.id, platform.id, regenerate_runs)

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
示例#2
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        headers = "\n".join([key + ': ' + value for key, value in self.request.headers.items()])

        # Do as best as we can to remove the password
        request_body_without_password = re.sub(r'"password"\s*:\s*".+?",', '', self.request.body)
        log = ReportLog(timestamp=datetime.now(), headers=headers, payload=request_body_without_password)
        log.put()

        try:
            self._body = json.loads(self.request.body)
        except ValueError:
            return self._output('Failed to parse the payload as a json. Report key: %d' % log.key().id())

        builder = self._modelByKeyNameInBodyOrError(Builder, 'builder-name')
        branch = self._modelByKeyNameInBodyOrError(Branch, 'branch')
        platform = self._modelByKeyNameInBodyOrError(Platform, 'platform')
        buildNumber = self._integerInBody('build-number')
        revision = self._integerInBody('revision')
        timestamp = self._timestampInBody()

        failed = False
        if builder and not (self.bypassAuthentication() or builder.authenticate(self._body.get('password', ''))):
            self._output('Authentication failed')
            failed = True

        if not self._resultsAreValid():
            self._output("The payload doesn't contain results or results are malformed")
            failed = True

        if not (builder and branch and platform and buildNumber and revision and timestamp) or failed:
            return

        build = self._createBuildIfPossible(builder, buildNumber, branch, platform, revision, timestamp)
        if not build:
            return

        for testName, result in self._body['results'].iteritems():
            test = self._addTestIfNeeded(testName, branch, platform)
            memcache.delete(Test.cacheKey(test.id, branch.id, platform.id))
            if isinstance(result, dict):
                TestResult(name=testName, build=build, value=float(result.get('avg', 0)), valueMedian=float(result.get('median', 0)),
                    valueStdev=float(result.get('stdev', 0)), valueMin=float(result.get('min', 0)), valueMax=float(result.get('max', 0))).put()
            else:
                TestResult(name=testName, build=build, value=float(result)).put()

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        memcache.delete('dashboard')
        memcache.delete('manifest')

        return self._output('OK')
示例#3
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        log_id = int(self.request.get('id', 0))

        log = ReportLog.get_by_id(log_id)
        if not log or not log.commit:
            self.response.out.write("Not processed")
            return

        branch = log.branch()
        platform = log.platform()
        build = Build.get_or_insert_from_log(log)

        for test_name, result_value in log.results().iteritems():
            unit = result_value.get('unit') if isinstance(result_value,
                                                          dict) else None
            test = Test.update_or_insert(test_name, branch, platform, unit)
            result = TestResult.get_or_insert_from_parsed_json(
                test_name, build, result_value)
            if not result:
                continue
            runs = Runs.get_by_objects(branch, platform, test)
            regenerate_runs = True
            if runs:
                runs.update_incrementally(build, result)
                regenerate_runs = False
            schedule_runs_update(test.id, branch.id, platform.id,
                                 regenerate_runs)

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
示例#4
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        headers = "\n".join([key + ': ' + value for key, value in self.request.headers.items()])

        # Do as best as we can to remove the password
        request_body_without_password = re.sub(r'"password"\s*:\s*".+?",', '', self.request.body)
        log = ReportLog(timestamp=datetime.now(), headers=headers, payload=request_body_without_password)
        log.put()

        try:
            self._body = json.loads(self.request.body)
        except ValueError:
            return self._output('Failed to parse the payload as a json. Report key: %d' % log.key().id())

        builder = self._model_by_key_name_in_body_or_error(Builder, 'builder-name')
        branch = self._model_by_key_name_in_body_or_error(Branch, 'branch')
        platform = self._model_by_key_name_in_body_or_error(Platform, 'platform')
        build_number = self._integer_in_body('build-number')
        timestamp = self._timestamp_in_body()
        revision = self._integer_in_body('webkit-revision')
        chromium_revision = self._integer_in_body('webkit-revision') if 'chromium-revision' in self._body else None

        failed = False
        if builder and not (self.bypass_authentication() or builder.authenticate(self._body.get('password', ''))):
            self._output('Authentication failed')
            failed = True

        if not self._results_are_valid():
            self._output("The payload doesn't contain results or results are malformed")
            failed = True

        if not (builder and branch and platform and build_number and revision and timestamp) or failed:
            return

        build = self._create_build_if_possible(builder, build_number, branch, platform, timestamp, revision, chromium_revision)
        if not build:
            return

        def _float_or_none(dictionary, key):
            value = dictionary.get(key)
            if value:
                return float(value)
            return None

        for test_name, result in self._body['results'].iteritems():
            test = self._add_test_if_needed(test_name, branch, platform)
            memcache.delete(Test.cache_key(test.id, branch.id, platform.id))
            if isinstance(result, dict):
                TestResult(name=test_name, build=build, value=float(result['avg']), valueMedian=_float_or_none(result, 'median'),
                    valueStdev=_float_or_none(result, 'stdev'), valueMin=_float_or_none(result, 'min'), valueMax=_float_or_none(result, 'max')).put()
            else:
                TestResult(name=test_name, build=build, value=float(result)).put()

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        memcache.delete('dashboard')
        memcache.delete('manifest')

        return self._output('OK')