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')
def test_repositories(self): # pylint: disable=too-many-locals job = TestJob.from_yaml_and_user(self.factory.make_job_yaml(), self.user) job_def = yaml.load(job.definition) job_ctx = job_def.get('context', {}) job_ctx.update( {'no_kvm': True}) # override to allow unit tests on all types of systems 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']) self.assertEqual(device_values, {'target.device_type': 'qemu'}) del pipeline['device']['device_type'] self.assertNotIn('device_type', pipeline['device']) 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']) if 'lava-server-version' in retval: del retval['lava-server-version'] self.assertEqual( retval, { 'test.1.common.definition.from': 'git', 'test.0.common.definition.repository': 'git://git.linaro.org/qa/test-definitions.git', 'test.0.common.definition.name': 'smoke-tests', 'test.1.common.definition.repository': 'http://git.linaro.org/lava-team/lava-functional-tests.git', 'boot.0.common.method': 'qemu', 'test.1.common.definition.name': 'singlenode-advanced', 'test.0.common.definition.from': 'git', 'test.0.common.definition.path': 'ubuntu/smoke-tests-basic.yaml', 'test.1.common.definition.path': 'lava-test-shell/single-node/singlenode03.yaml' })
def test_multinode_v2_metadata(self): device_type = self.factory.make_device_type() self.factory.make_device(device_type, 'fakeqemu1') self.factory.make_device(device_type, 'fakeqemu2') client_submission = yaml.load(open( os.path.join(os.path.dirname(__file__), 'kvm-multinode-client.yaml'), 'r')) job_ctx = client_submission.get('context', {}) device = Device.objects.get(hostname='fakeqemu1') device_config = device.load_device_configuration(job_ctx) # raw dict parser_device = PipelineDevice(device_config, device.hostname) parser = JobParser() pipeline_job = parser.parse( yaml.dump(client_submission), parser_device, 4212, None, None, None, output_dir='/tmp/test') pipeline = pipeline_job.describe() from lava_results_app.dbutils import _get_job_metadata self.assertEqual( { 'test.0.definition.name': 'multinode-basic', 'test.0.definition.path': 'lava-test-shell/multi-node/multinode01.yaml', 'test.0.definition.from': 'git', 'boot.0.method': 'qemu', 'test.0.definition.repository': 'http://git.linaro.org/lava-team/lava-functional-tests.git' }, _get_job_metadata(pipeline['job']['actions']) ) # simulate dynamic connection dynamic = yaml.load(open( os.path.join(os.path.dirname(__file__), 'pipeline_refs', 'connection-description.yaml'), 'r')) self.assertEqual( _get_job_metadata(dynamic['job']['actions']), { 'omitted.1.inline.name': 'ssh-client', 'test.0.definition.repository': 'git://git.linaro.org/qa/test-definitions.git', 'test.0.definition.name': 'smoke-tests', 'boot.0.method': 'ssh', 'omitted.1.inline.path': 'inline/ssh-client.yaml', 'test.0.definition.from': 'git', 'test.0.definition.path': 'ubuntu/smoke-tests-basic.yaml' } )
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', {}) job_ctx.update( {'no_kvm': True}) # override to allow unit tests on all types of systems 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')
def test_repositories(self): # pylint: disable=too-many-locals job = TestJob.from_yaml_and_user( self.factory.make_job_yaml(), 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']) self.assertEqual( device_values, {'target.device_type': 'qemu'} ) del pipeline['device']['device_type'] self.assertNotIn('device_type', pipeline['device']) 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']) if 'lava-server-version' in retval: del retval['lava-server-version'] self.assertEqual( retval, { 'test.1.common.definition.from': 'git', 'test.0.common.definition.repository': 'git://git.linaro.org/qa/test-definitions.git', 'test.0.common.definition.name': 'smoke-tests', 'test.1.common.definition.repository': 'http://git.linaro.org/lava-team/lava-functional-tests.git', 'boot.0.common.method': 'qemu', 'test.1.common.definition.name': 'singlenode-advanced', 'test.0.common.definition.from': 'git', 'test.0.common.definition.path': 'ubuntu/smoke-tests-basic.yaml', 'test.1.common.definition.path': 'lava-test-shell/single-node/singlenode03.yaml'} )