当前位置: 首页>>代码示例>>Python>>正文


Python models.TestJob类代码示例

本文整理汇总了Python中lava_scheduler_app.models.TestJob的典型用法代码示例。如果您正苦于以下问题:Python TestJob类的具体用法?Python TestJob怎么用?Python TestJob使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestJob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_mixed_multinode

 def test_mixed_multinode(self):
     user = self.factory.make_user()
     device_type = self.factory.make_device_type()
     self.factory.make_device(device_type, 'fakeqemu1')
     self.factory.make_device(device_type, 'fakeqemu2')
     self.factory.make_device(device_type, 'fakeqemu3')
     self.factory.make_device(device_type, 'fakeqemu4')
     submission = yaml.load(open(
         os.path.join(os.path.dirname(__file__), 'kvm-multinode.yaml'), 'r'))
     role_list = submission['protocols'][MultinodeProtocol.name]['roles']
     for role in role_list:
         if 'tags' in role_list[role]:
             del role_list[role]['tags']
     job_list = TestJob.from_yaml_and_user(yaml.dump(submission), user)
     self.assertEqual(len(job_list), 2)
     # make the list mixed
     fakeqemu1 = Device.objects.get(hostname='fakeqemu1')
     fakeqemu1.is_pipeline = False
     fakeqemu1.save(update_fields=['is_pipeline'])
     fakeqemu3 = Device.objects.get(hostname='fakeqemu3')
     fakeqemu3.is_pipeline = False
     fakeqemu3.save(update_fields=['is_pipeline'])
     device_list = Device.objects.filter(device_type=device_type, is_pipeline=True)
     self.assertEqual(len(device_list), 2)
     self.assertIsInstance(device_list, RestrictedResourceQuerySet)
     self.assertIsInstance(list(device_list), list)
     job_list = TestJob.from_yaml_and_user(yaml.dump(submission), user)
     self.assertEqual(len(job_list), 2)
     for job in job_list:
         self.assertEqual(job.requested_device_type, device_type)
开发者ID:margam2410,项目名称:lava-server,代码行数:30,代码来源:test_pipeline.py

示例2: testjob_submission

def testjob_submission(job_definition, user, check_device=None):
    """
    Single submission frontend for JSON or YAML
    :param job_definition: string of the job submission
    :param user: user attempting the submission
    :param check_device: set specified device as the target
    **and** thereby set job as a health check job. (JSON only)
    :return: a job or a list of jobs
    :raises: SubmissionException, Device.DoesNotExist,
        DeviceType.DoesNotExist, DevicesUnavailableException,
        JSONDataError, JSONDecodeError, ValueError
    """

    if is_deprecated_json(job_definition):
        allow_health = False
        job_json = simplejson.loads(job_definition)
        target_device = None
        if 'target' in job_json:
            target_device = Device.objects.get(hostname=job_json['target'])
        if check_device:
            job_json['target'] = check_device.hostname
            job_json['health-check'] = True
            job_definition = simplejson.dumps(job_json)
            allow_health = True
        try:
            # returns a single job or a list (not a QuerySet) of job objects.
            job = TestJob.from_json_and_user(job_definition, user, health_check=allow_health)
            if isinstance(job, list):
                # multinode health checks not supported
                return job
            job.health_check = allow_health
            if check_device:
                job.requested_device = check_device
            elif target_device:
                job.requested_device = target_device
            job.save(update_fields=['health_check', 'requested_device'])
        except (JSONDataError, ValueError) as exc:
            if check_device:
                check_device.put_into_maintenance_mode(
                    user, "Job submission failed for health job for %s: %s" % (check_device, exc))
                raise JSONDataError("Health check job submission failed for %s: %s" % (check_device, exc))
            else:
                raise JSONDataError("Job submission failed: %s" % exc)

    else:
        validate_job(job_definition)
        # returns a single job or a list (not a QuerySet) of job objects.
        job = TestJob.from_yaml_and_user(job_definition, user)
        if check_device and isinstance(check_device, Device) and not isinstance(job, list):
            # the slave must neither know nor care if this is a health check,
            # only the master cares and that has the database connection.
            job.health_check = True
            job.requested_device = check_device
            job.save(update_fields=['health_check', 'requested_device'])
    return job
开发者ID:dl9pf,项目名称:lava-server,代码行数:55,代码来源:dbutils.py

示例3: test_from_yaml_unsupported_tags

 def test_from_yaml_unsupported_tags(self):
     self.factory.make_device(self.device_type, 'fakeqemu1')
     self.factory.ensure_tag('usb')
     self.factory.ensure_tag('sata')
     try:
         TestJob.from_yaml_and_user(
             self.factory.make_job_json(tags=['usb', 'sata']),
             self.factory.make_user())
     except DevicesUnavailableException:
         pass
     else:
         self.fail("Device tags failure: job submitted without any devices supporting the requested tags")
开发者ID:margam2410,项目名称:lava-server,代码行数:12,代码来源:test_pipeline.py

示例4: test_from_yaml_and_user_reuses_tag_objects

 def test_from_yaml_and_user_reuses_tag_objects(self):
     self.factory.ensure_tag('tag')
     tags = list(Tag.objects.filter(name='tag'))
     self.factory.make_device(device_type=self.device_type, hostname="fakeqemu1", tags=tags)
     job1 = TestJob.from_yaml_and_user(
         self.factory.make_job_json(tags=['tag']),
         self.factory.make_user())
     job2 = TestJob.from_yaml_and_user(
         self.factory.make_job_json(tags=['tag']),
         self.factory.make_user())
     self.assertEqual(
         set(tag.pk for tag in job1.tags.all()),
         set(tag.pk for tag in job2.tags.all()))
开发者ID:margam2410,项目名称:lava-server,代码行数:13,代码来源:test_pipeline.py

示例5: test_parameter_support

 def test_parameter_support(self):  # pylint: disable=too-many-locals
     data = self.factory.make_job_data()
     test_block = [block for block in data['actions'] if 'test' in block][0]
     smoke = test_block['test']['definitions'][0]
     smoke['parameters'] = {
         'VARIABLE_NAME_1': "first variable value",
         'VARIABLE_NAME_2': "second value"
     }
     job = TestJob.from_yaml_and_user(yaml.dump(data), self.user)
     job_def = yaml.load(job.definition)
     job_ctx = job_def.get('context', {})
     device = Device.objects.get(hostname='fakeqemu1')
     device_config = device.load_device_configuration(job_ctx, system=False)  # raw dict
     parser = JobParser()
     obj = PipelineDevice(device_config, device.hostname)
     pipeline_job = parser.parse(job.definition, obj, job.id, None, "", output_dir='/tmp')
     allow_missing_path(pipeline_job.pipeline.validate_actions, self,
                        'qemu-system-x86_64')
     pipeline = pipeline_job.describe()
     device_values = _get_device_metadata(pipeline['device'])
     try:
         testdata, _ = TestData.objects.get_or_create(testjob=job)
     except (MultipleObjectsReturned):
         self.fail('multiple objects')
     for key, value in device_values.items():
         if not key or not value:
             continue
         testdata.attributes.create(name=key, value=value)
     retval = _get_job_metadata(pipeline['job']['actions'])
     self.assertIn('test.0.common.definition.parameters.VARIABLE_NAME_2', retval)
     self.assertIn('test.0.common.definition.parameters.VARIABLE_NAME_1', retval)
     self.assertEqual(retval['test.0.common.definition.parameters.VARIABLE_NAME_1'], 'first variable value')
     self.assertEqual(retval['test.0.common.definition.parameters.VARIABLE_NAME_2'], 'second value')
开发者ID:dl9pf,项目名称:lava-server,代码行数:33,代码来源:test_metadata.py

示例6: test_metastore

    def test_metastore(self):
        field = TestCase._meta.get_field('metadata')
        level = '1.3.5.1'
        # artificially inflate results to represent a set of kernel messages
        results = {
            'definition': 'lava',
            'case': 'unit-test',
            # list of numbers, generates a much longer YAML string than just the count
            'extra': range(int(field.max_length / 2)),
            'result': 'pass'
        }
        stub = "%s-%s-%s.yaml" % (results['definition'], results['case'], level)
        job = TestJob.from_yaml_and_user(
            self.factory.make_job_yaml(), self.user)
        meta_filename = os.path.join(job.output_dir, 'metadata', stub)
        filename = "%s/job-%s/pipeline/%s/%s-%s.yaml" % (job.output_dir,
                                                         job.id, level.split('.')[0],
                                                         level, results['definition'])

        mkdir(os.path.dirname(filename))
        if os.path.exists(meta_filename):
            # isolate from other unit tests
            os.unlink(meta_filename)
        self.assertEqual(meta_filename, create_metadata_store(results, job, level))
        self.assertTrue(map_scanned_results(results, job, meta_filename))
        self.assertEqual(TestCase.objects.filter(name='unit-test').count(), 1)
        test_data = yaml.load(TestCase.objects.filter(name='unit-test')[0].metadata, Loader=yaml.CLoader)
        self.assertEqual(test_data['extra'], meta_filename)
        self.assertTrue(os.path.exists(meta_filename))
        with open(test_data['extra'], 'r') as extra_file:
            data = yaml.load(extra_file, Loader=yaml.CLoader)
        self.assertIsNotNone(data)
        os.unlink(meta_filename)
        shutil.rmtree(job.output_dir)
开发者ID:dl9pf,项目名称:lava-server,代码行数:34,代码来源:test_metadata.py

示例7: test_level_input

    def test_level_input(self):
        user = self.factory.make_user()
        job = TestJob.from_yaml_and_user(
            self.factory.make_job_yaml(), user)
        suite = TestSuite.objects.create(
            job=job,
            name='test-suite'
        )
        suite.save()
        result_sample = """
results:
  lava-test-shell: !!python/object/apply:collections.OrderedDict
    - - [ping-test, fail]
  power_off: !!python/object/apply:collections.OrderedDict
    - - [status, Complete]
      - [level, 5.1]
        """
        scanned = yaml.load(result_sample)
        ret = map_scanned_results(scanned_dict=scanned, job=job)
        self.assertTrue(ret)
        for testcase in TestCase.objects.filter(suite=suite):
            if testcase.name == 'power_off':
                self.assertTrue(type(testcase.metadata) in [str, unicode])
                self.assertTrue(type(testcase.action_data) == OrderedDict)
                self.assertEqual(testcase.action_data['status'], 'Complete')
                self.assertEqual(testcase.action_data['level'], 5.1)
                self.assertEqual(testcase.action_level, '5.1')
                self.assertEqual(testcase.result, TestCase.RESULT_UNKNOWN)
        self.factory.cleanup()
开发者ID:SivagnanamCiena,项目名称:lava-server,代码行数:29,代码来源:test_names.py

示例8: test_set

    def test_set(self):
        job = TestJob.from_yaml_and_user(
            self.factory.make_job_yaml(), self.user)
        result_samples = [
            {"case": "linux-INLINE-lscpu", "definition": "smoke-tests-basic", "result": "fail", "set": "listing"},
            {"case": "linux-INLINE-lspci", "definition": "smoke-tests-basic", "result": "fail", "set": "listing"}
        ]
        suite = TestSuite.objects.create(
            job=job,
            name='test-suite'
        )
        suite.save()
        self.assertEqual('/results/%s/test-suite' % job.id, suite.get_absolute_url())

        for sample in result_samples:
            ret = map_scanned_results(results=sample, job=job)
            self.assertTrue(ret)

        self.assertEqual(2, TestCase.objects.count())
        val = URLValidator()
        for testcase in TestCase.objects.filter(suite=suite):
            self.assertEqual(testcase.suite, suite)
            self.assertIsNotNone(testcase.name)
            self.assertIsNotNone(testcase.result)
            self.assertIsNone(testcase.metadata)
            self.assertEqual(testcase.result, TestCase.RESULT_PASS)
            self.assertEqual(testcase.test_set.name, 'listing')
            self.assertTrue(testcase.name.startswith('linux-INLINE-'))
            val('http://localhost/%s' % testcase.get_absolute_url())
        self.factory.cleanup()
开发者ID:margam2410,项目名称:lava-server,代码行数:30,代码来源:test_names.py

示例9: definition

    def definition(self, job_id):
        """
        Name
        ----
        `scheduler.jobs.definition` (`job_id`)

        Description
        -----------
        Return the job definition

        Arguments
        ---------
        `job_id`: string
            Job id

        Return value
        ------------
        The job definition or and error.
        """
        try:
            job = TestJob.get_by_job_number(job_id)
        except TestJob.DoesNotExist:
            raise xmlrpclib.Fault(
                404, "Job '%s' was not found." % job_id)

        if not job.can_view(self.user):
            raise xmlrpclib.Fault(
                403, "Job '%s' not available to user '%s'." %
                (job_id, self.user))

        if job.is_multinode:
            return xmlrpclib.Binary(job.multinode_definition)
        else:
            return xmlrpclib.Binary(job.original_definition)
开发者ID:Linaro,项目名称:lava-server,代码行数:34,代码来源:jobs.py

示例10: test_duration

 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)
开发者ID:dl9pf,项目名称:lava-server,代码行数:16,代码来源:test_metadata.py

示例11: test_from_json_and_user_sets_target

 def test_from_json_and_user_sets_target(self):
     panda_board = self.factory.make_device(hostname='panda01')
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(target='panda01'),
         self.factory.make_user())
     self.assertEqual(panda_board, job.requested_device)
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:7,代码来源:test_submission.py

示例12: test_from_json_and_user_does_not_set_device_type_from_target

 def test_from_json_and_user_does_not_set_device_type_from_target(self):
     panda_type = self.factory.ensure_device_type(name='panda')
     self.factory.make_device(device_type=panda_type, hostname='panda01')
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(target='panda01'),
         self.factory.make_user())
     self.assertEqual(None, job.requested_device_type)
开发者ID:OSSystems,项目名称:lava-server,代码行数:7,代码来源:submission.py

示例13: test_from_json_and_user_repeat_parameter_zero

 def test_from_json_and_user_repeat_parameter_zero(self):
     device_type = self.factory.make_device_type('base')
     device = self.factory.make_device(device_type=device_type, hostname="generic")
     repeat = 0
     job_data = {
         'timeout': 1,
         'target': device.hostname,
         'actions': [
             {
                 'command': 'lava_test_shell',
                 'parameters': {
                     'repeat': repeat,
                     'testdef_repos': [
                         {
                             'git-repo': 'git://server/test.git',
                             'testdef': 'testdef.yaml'
                         }
                     ],
                 }
             }
         ],
     }
     job_json = simplejson.dumps(job_data, sort_keys=True, indent=4 * ' ')
     job = TestJob.from_json_and_user(job_json, self.factory.make_user())
     definition_data = simplejson.loads(job.definition)
     self.assertEqual(len(definition_data['actions']), 1)
     self.assertNotIn('repeat_count', definition_data['actions'][0]['parameters'])
     self.assertNotIn('repeat', definition_data['actions'][0]['parameters'])
     self.assertEqual(job.status, TestJob.SUBMITTED)
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:30,代码来源:test_submission.py

示例14: test_select_device

 def test_select_device(self):
     self.restart()
     hostname = 'fakeqemu3'
     device_dict = DeviceDictionary(hostname=hostname)
     device_dict.parameters = self.conf
     device_dict.save()
     device = self.factory.make_device(self.device_type, hostname)
     job = TestJob.from_yaml_and_user(
         self.factory.make_job_yaml(),
         self.factory.make_user())
     # this uses the system jinja2 path - local changes to the qemu.jinja2
     # will not be available.
     selected = select_device(job, self.dispatchers)
     self.assertIsNone(selected)
     job.actual_device = device
     selected = select_device(job, self.dispatchers)
     self.assertIsNone(selected)
     device.worker_host = self.worker
     selected = select_device(job, self.dispatchers)
     self.assertIsNone(selected)
     # device needs to be in reserved state
     # fake up the assignment which needs a separate test
     job.actual_device = device
     job.save()
     device.current_job = job
     device.status = Device.RESERVED
     device.save()
     selected = select_device(job, self.dispatchers)
     self.assertEqual(selected, device)
开发者ID:dl9pf,项目名称:lava-server,代码行数:29,代码来源:test_master.py

示例15: test_from_json_and_user_sets_device_type

 def test_from_json_and_user_sets_device_type(self):
     panda_type = self.factory.ensure_device_type(name='panda')
     job = TestJob.from_json_and_user(
         self.factory.make_job_json(device_type='panda'),
         self.factory.make_user())
     self.assertEqual(panda_type, job.requested_device_type)
     self.factory.cleanup()
开发者ID:jguyot,项目名称:lava-server,代码行数:7,代码来源:test_submission.py


注:本文中的lava_scheduler_app.models.TestJob类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。