def create_test_execution_event(content_metadata, custom_metadata,
                                test_execution):
    """
    Creates code_testrun event for GAIA message gateway. For data format see https://github.com/gaia-adm/api-data-format.
    """
    test_run_event = {'event': 'code_testrun'}
    dateTime = parseDateTime(custom_metadata['BUILD_START_TIME'])
    dateTime = dateTime.replace(microsecond=0)
    test_run_event['time'] = dateTime.isoformat()
    # source
    source = {}
    source['build_server_uri'] = custom_metadata['BUILD_SERVER_URI']
    source['build_server_host'] = urlparse(
        custom_metadata['BUILD_SERVER_URI']).hostname
    source['build_uri'] = custom_metadata.get('BUILD_URI')
    source['job_name'] = custom_metadata.get('SCM_REPO_NAME')
    source['repository'] = custom_metadata.get('SCM_URL')
    source['branch'] = custom_metadata.get('SCM_BRANCH')
    source['source_type'] = 'circleci'
    test_run_event['source'] = source
    # tags
    tags = {}
    tags['build_result'] = custom_metadata.get('BUILD_STATUS')
    tags['test_source'] = test_execution['source_type']
    test_run_event['tags'] = tags
    # id part
    id = {}
    id['file'] = test_execution['file']
    id['method'] = test_execution['name']
    package, clazz = parse_class_name(test_execution['classname'])
    if package != None:
        id['package'] = package
    if clazz != None:
        id['class'] = clazz
    id['build_number'] = custom_metadata.get('BUILD_NUMBER')
    test_run_event['id'] = id
    # result part
    result = {}
    result['status'] = test_execution['result']
    result['error'] = test_execution.get('message')
    result['run_time'] = float(test_execution.get('run_time'))
    test_run_event['result'] = result
    return test_run_event
def create_test_execution_event(content_metadata, custom_metadata, test_execution):
    """
    Creates code_testrun event for GAIA message gateway. For data format see https://github.com/gaia-adm/api-data-format.
    """
    test_run_event = {'event': 'code_testrun'}
    dateTime = parseDateTime(custom_metadata['BUILD_START_TIME'])
    dateTime = dateTime.replace(microsecond = 0)
    test_run_event['time'] = dateTime.isoformat()
    # source
    source = {}
    source['build_server_uri'] = custom_metadata['BUILD_SERVER_URI']
    source['build_server_host'] = urlparse(custom_metadata['BUILD_SERVER_URI']).hostname
    source['build_uri'] = custom_metadata.get('BUILD_URI')
    source['job_name'] = custom_metadata.get('SCM_REPO_NAME')
    source['repository'] = custom_metadata.get('SCM_URL')
    source['branch'] = custom_metadata.get('SCM_BRANCH')
    source['source_type'] = 'circleci'
    test_run_event['source'] = source
    # tags
    tags = {}
    tags['build_result'] = custom_metadata.get('BUILD_STATUS')
    tags['test_source'] = test_execution['source_type']
    test_run_event['tags'] = tags
    # id part
    id = {}
    id['file'] = test_execution['file']
    id['method'] = test_execution['name']
    package, clazz = parse_class_name(test_execution['classname'])
    if package != None:
        id['package'] = package
    if clazz != None:
        id['class'] = clazz
    id['build_number'] = custom_metadata.get('BUILD_NUMBER')
    test_run_event['id'] = id
    # result part
    result = {}
    result['status'] = test_execution['result']
    result['error'] = test_execution.get('message')
    result['run_time'] = float(test_execution.get('run_time'))
    test_run_event['result'] = result
    return test_run_event
Exemplo n.º 3
0
def parseTime(s):
    """Return a time object corresponding to the given string."""
    return parseDateTime(s).time()
Exemplo n.º 4
0
def parseTime(s):
    """Return a time object corresponding to the given string."""
    return parseDateTime(s).time()