Esempio n. 1
0
def build_action(action_data, testdata, submission):
    # test for a known section
    logger = logging.getLogger("lava-master")
    if "section" not in action_data:
        logger.warning("Invalid action data - missing section")
        return

    metatype = MetaType.get_section(action_data["section"])
    if metatype is None:  # 0 is allowed
        logger.debug("Unrecognised metatype in action_data: %s",
                     action_data["section"])
        return
    # lookup the type from the job definition.
    type_name = MetaType.get_type_name(action_data, submission)
    if not type_name:
        logger.debug(
            "type_name failed for %s metatype %s",
            action_data["section"],
            MetaType.TYPE_CHOICES[metatype],
        )
        return
    action_meta, _ = MetaType.objects.get_or_create(name=type_name,
                                                    metatype=metatype)
    max_retry = action_data.get("max_retries")

    # find corresponding test case
    match_case = None
    test_cases = TestCase.objects.filter(suite__job=testdata.testjob,
                                         suite__name="lava")
    for case in test_cases:
        if case.action_metadata:
            if case.action_metadata.get("level") == action_data["level"]:
                match_case = case
Esempio n. 2
0
def build_action(action_data, testdata, submission):
    # test for a known section
    logger = logging.getLogger("lava_results_app")
    if "section" not in action_data:
        logger.warn("Invalid action data - missing section")
        return

    metatype = MetaType.get_section(action_data["section"])
    if metatype is None:  # 0 is allowed
        logger.debug("Unrecognised metatype in action_data: %s" % action_data["section"])
        return
    # lookup the type from the job definition.
    type_name = MetaType.get_type_name(action_data["section"], submission)
    if not type_name:
        logger.debug("type_name failed for %s metatype %s" % (action_data["section"], MetaType.TYPE_CHOICES[metatype]))
        return
    action_meta, created = MetaType.objects.get_or_create(name=type_name, metatype=metatype)
    if created:
        action_meta.save()
    max_retry = None
    if "max_retries" in action_data:
        max_retry = action_data["max_retries"]

    action = ActionData.objects.create(
        action_name=action_data["name"],
        action_level=action_data["level"],
        action_summary=action_data["summary"],
        testdata=testdata,
        action_description=action_data["description"],
        meta_type=action_meta,
        max_retries=max_retry,
        timeout=int(Timeout.parse(action_data["timeout"])),
    )
    with transaction.atomic():
        action.save()
Esempio n. 3
0
def build_action(action_data, testdata, submission):
    # test for a known section
    logger = logging.getLogger('lava-master')
    if 'section' not in action_data:
        logger.warning("Invalid action data - missing section")
        return

    metatype = MetaType.get_section(action_data['section'])
    if metatype is None:  # 0 is allowed
        logger.debug("Unrecognised metatype in action_data: %s", action_data['section'])
        return
    # lookup the type from the job definition.
    type_name = MetaType.get_type_name(action_data, submission)
    if not type_name:
        logger.debug(
            "type_name failed for %s metatype %s",
            action_data['section'], MetaType.TYPE_CHOICES[metatype])
        return
    action_meta, _ = MetaType.objects.get_or_create(name=type_name,
                                                    metatype=metatype)
    max_retry = action_data.get('max_retries')

    # find corresponding test case
    match_case = None
    test_cases = TestCase.objects.filter(suite__job=testdata.testjob, suite__name='lava')
    for case in test_cases:
        if 'level' in case.action_metadata:
            if case.action_metadata['level'] == action_data['level']:
                match_case = case

    # maps the static testdata derived from the definition to the runtime pipeline construction
    ActionData.objects.create(
        action_name=action_data['name'],
        action_level=action_data['level'],
        action_summary=action_data['summary'],
        testdata=testdata,
        action_description=action_data['description'],
        meta_type=action_meta,
        max_retries=max_retry,
        timeout=int(Timeout.parse(action_data['timeout'])),
        testcase=match_case
    )
Esempio n. 4
0
def build_action(action_data, testdata, submission):
    # test for a known section
    logger = logging.getLogger('dispatcher-master')
    if 'section' not in action_data:
        logger.warning("Invalid action data - missing section")
        return

    metatype = MetaType.get_section(action_data['section'])
    if metatype is None:  # 0 is allowed
        logger.debug("Unrecognised metatype in action_data: %s", action_data['section'])
        return
    # lookup the type from the job definition.
    type_name = MetaType.get_type_name(action_data, submission)
    if not type_name:
        logger.debug(
            "type_name failed for %s metatype %s",
            action_data['section'], MetaType.TYPE_CHOICES[metatype])
        return
    action_meta, created = MetaType.objects.get_or_create(
        name=type_name, metatype=metatype)
    if created:
        action_meta.save()
    max_retry = None
    if 'max_retries' in action_data:
        max_retry = action_data['max_retries']

    # maps the static testdata derived from the definition to the runtime pipeline construction
    action = ActionData.objects.create(
        action_name=action_data['name'],
        action_level=action_data['level'],
        action_summary=action_data['summary'],
        testdata=testdata,
        action_description=action_data['description'],
        meta_type=action_meta,
        max_retries=max_retry,
        timeout=int(Timeout.parse(action_data['timeout']))
    )
    with transaction.atomic():
        action.save()
Esempio n. 5
0
def build_action(action_data, testdata, submission):
    # test for a known section
    logger = logging.getLogger('dispatcher-master')
    if 'section' not in action_data:
        logger.warning("Invalid action data - missing section")
        return

    metatype = MetaType.get_section(action_data['section'])
    if metatype is None:  # 0 is allowed
        logger.debug("Unrecognised metatype in action_data: %s", action_data['section'])
        return
    # lookup the type from the job definition.
    type_name = MetaType.get_type_name(action_data['section'], submission)
    if not type_name:
        logger.debug(
            "type_name failed for %s metatype %s",
            action_data['section'], MetaType.TYPE_CHOICES[metatype])
        return
    action_meta, created = MetaType.objects.get_or_create(
        name=type_name, metatype=metatype)
    if created:
        action_meta.save()
    max_retry = None
    if 'max_retries' in action_data:
        max_retry = action_data['max_retries']

    # maps the static testdata derived from the definition to the runtime pipeline construction
    action = ActionData.objects.create(
        action_name=action_data['name'],
        action_level=action_data['level'],
        action_summary=action_data['summary'],
        testdata=testdata,
        action_description=action_data['description'],
        meta_type=action_meta,
        max_retries=max_retry,
        timeout=int(Timeout.parse(action_data['timeout']))
    )
    with transaction.atomic():
        action.save()