示例#1
0
    def _add_code_paths(self, builderid, paths):
        path_to_id = {}

        for path in sorted(paths):
            id = self._get_code_path_id(builderid, path)
            if id is not None:
                path_to_id[path] = id
                continue

            id = Row.nextId()
            self.code_paths[id] = {'builderid': builderid, 'path': path}
            path_to_id[path] = id

        return path_to_id
示例#2
0
    def _add_names(self, builderid, names):
        name_to_id = {}

        for name in sorted(names):
            id = self._get_name_id(builderid, name)
            if id is not None:
                name_to_id[name] = id
                continue

            id = Row.nextId()
            self.names[id] = {'builderid': builderid, 'name': name}
            name_to_id[name] = id

        return name_to_id
示例#3
0
 def addTestResultSet(self, builderid, buildid, stepid, description, category, value_unit):
     id = Row.nextId()
     self.result_sets[id] = {
         'id': id,
         'builderid': builderid,
         'buildid': buildid,
         'stepid': stepid,
         'description': description,
         'category': category,
         'value_unit': value_unit,
         'tests_failed': None,
         'tests_passed': None,
         'complete': False
     }
     return defer.succeed(id)
示例#4
0
    def setBuildData(self, buildid, name, value, source):
        assert isinstance(value, bytes)
        row = self._get_build_data_row(buildid, name)
        if row is not None:
            row['value'] = value
            row['source'] = source
            return

        id = Row.nextId()
        self.build_data[id] = {
            'id': id,
            'buildid': buildid,
            'name': name,
            'value': value,
            'source': source
        }
示例#5
0
    def addTestResults(self, builderid, test_result_setid, result_values):
        insert_code_paths = set()
        insert_names = set()
        for result_value in result_values:
            if 'value' not in result_value:
                raise KeyError(
                    'Each of result_values must contain \'value\' key')

            if 'test_name' not in result_value and 'test_code_path' not in result_value:
                raise KeyError(
                    'Each of result_values must contain at least one of '
                    '\'test_name\' or \'test_code_path\' keys')

            if 'test_name' in result_value:
                insert_names.add(result_value['test_name'])
            if 'test_code_path' in result_value:
                insert_code_paths.add(result_value['test_code_path'])

        code_path_to_id = yield self._add_code_paths(builderid,
                                                     insert_code_paths)
        name_to_id = yield self._add_names(builderid, insert_names)

        for result_value in result_values:
            insert_value = {
                'value': result_value['value'],
                'builderid': builderid,
                'test_result_setid': test_result_setid,
                'test_nameid': None,
                'test_code_pathid': None,
                'duration_ns': None,
                'line': None,
            }

            if 'test_name' in result_value:
                insert_value['test_nameid'] = name_to_id[
                    result_value['test_name']]
            if 'test_code_path' in result_value:
                insert_value['test_code_pathid'] = code_path_to_id[
                    result_value['test_code_path']]
            if 'line' in result_value:
                insert_value['line'] = result_value['line']
            if 'duration_ns' in result_value:
                insert_value['duration_ns'] = result_value['duration_ns']

            self.results[Row.nextId()] = insert_value