def test_parameter_support(self): 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_safe_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_configuration(job_ctx) # raw dict parser = JobParser() obj = PipelineDevice(device_config) pipeline_job = parser.parse(job.definition, obj, job.id, None, "") allow_missing_path( pipeline_job.pipeline.validate_actions, self, "qemu-system-x86_64" ) pipeline = pipeline_job.describe() testdata, _ = TestData.objects.get_or_create(testjob=job) retval = _get_action_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_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_configuration(job_ctx) # raw dict parser = JobParser() obj = PipelineDevice(device_config) pipeline_job = parser.parse(job.definition, obj, job.id, None, "") 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_action_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): job = TestJob.from_yaml_and_user(self.factory.make_job_yaml(), self.user) job_def = yaml_safe_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_configuration(job_ctx) # raw dict parser = JobParser() obj = PipelineDevice(device_config) pipeline_job = parser.parse(job.definition, obj, job.id, None, "") allow_missing_path( pipeline_job.pipeline.validate_actions, self, "qemu-system-x86_64" ) pipeline = pipeline_job.describe() testdata, _ = TestData.objects.get_or_create(testjob=job) retval = _get_action_metadata(pipeline["job"]["actions"]) self.assertEqual( retval, { "test.1.common.definition.from": "git", "test.0.common.definition.repository": "git://git.linaro.org/lava-team/lava-functional-tests.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": "lava-test-shell/smoke-tests-basic.yaml", "test.1.common.definition.path": "lava-test-shell/single-node/singlenode03.yaml", }, )
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_configuration(job_ctx) # raw dict parser = JobParser() obj = PipelineDevice(device_config) pipeline_job = parser.parse(job.definition, obj, job.id, None, "") 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_action_metadata(pipeline['job']['actions']) self.assertEqual( retval, { 'test.1.common.definition.from': 'git', 'test.0.common.definition.repository': 'git://git.linaro.org/lava-team/lava-functional-tests.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': 'lava-test-shell/smoke-tests-basic.yaml', 'test.1.common.definition.path': 'lava-test-shell/single-node/singlenode03.yaml'} )