Example #1
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()
Example #2
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
Example #3
0
 def test_duration(self):
     TestJob.from_yaml_and_user(
         self.factory.make_job_yaml(), self.user)
     metatype = MetaType(name='fake', metatype=MetaType.DEPLOY_TYPE)
     metatype.save()
     action_data = ActionData(meta_type=metatype, action_level='1.2.3', action_name='fake')
     action_data.save()
     action_data.duration = '1.2'
     action_data.save(update_fields=['duration'])
     action_data = ActionData.objects.get(id=action_data.id)  # reload
     self.assertIsInstance(action_data.duration, decimal.Decimal)
     # unit tests check the instance as well as the value.
     self.assertEqual(float(action_data.duration), 1.2)
     action_data.timeout = 300
     action_data.save(update_fields=['timeout'])
     self.assertEqual(action_data.timeout, 300)
Example #4
0
 def test_duration(self):
     TestJob.from_yaml_and_user(
         self.factory.make_job_yaml(), self.user)
     metatype = MetaType(name='fake', metatype=MetaType.DEPLOY_TYPE)
     metatype.save()
     action_data = ActionData(meta_type=metatype, action_level='1.2.3', action_name='fake')
     action_data.save()
     action_data.duration = '1.2'
     action_data.save(update_fields=['duration'])
     action_data = ActionData.objects.get(id=action_data.id)  # reload
     self.assertIsInstance(action_data.duration, decimal.Decimal)
     # unit tests check the instance as well as the value.
     self.assertEqual(float(action_data.duration), 1.2)
     action_data.timeout = 300
     action_data.save(update_fields=['timeout'])
     self.assertEqual(action_data.timeout, 300)
Example #5
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
    )
Example #6
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()
Example #7
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()