def test_extract_metadata_from_lava_job(self): metadata = extract_metadata({ "actions": [{ "command": "dummy_deploy", "metadata": { "foo": "bar" } }] }) self.assertEqual(metadata['foo'], 'bar')
def test_extract_metadata_from_nested_metadata(self): metadata = extract_metadata({ "something": { "name": "foobar", "metadata": { "foo": "bar", "baz": "qux" } } }) self.assertEqual(metadata['foo'], 'bar') self.assertEqual(metadata['baz'], 'qux')
def test_extract_metadata_from_lava_job_with_multiple_actions(self): metadata = extract_metadata({ "actions": [{ "command": "dummy_deploy", "metadata": { "foo": "bar" } }, { "command": "dummy_deploy", "metadata": { "baz": "qux" } }] }) self.assertEqual(metadata['foo'], 'bar') self.assertEqual(metadata['baz'], 'qux')
def get_test_job_details(self, job_id): """ returns test job metadata, for example device type the tests were run on """ details = dict(testertype="lava") status = self.call_xmlrpc('scheduler.job_status', job_id) if 'bundle_sha1' in status: details.update({"bundle": status['bundle_sha1']}) content = self.call_xmlrpc('scheduler.job_details', job_id) definition = json.loads(content['definition']) if content['multinode_definition']: definition = json.loads(content['multinode_definition']) details.update({"definition": str(json.dumps(definition))}) details['metadata'] = extract_metadata(definition) details['metadata']['device'] = extract_device(definition) details['name'] = extract_name(definition) for action in definition['actions']: if action['command'].startswith("submit_results"): if 'stream' in action['parameters'].keys(): details.update({"bundlestream": action['parameters']['stream']}) return details
def get_test_job_details(self, job_id): """ returns test job metadata, for example device type the tests were run on """ details = dict(testertype="lava") status = self.call_xmlrpc('scheduler.job_status', job_id) if 'bundle_sha1' in status: details.update({"bundle": status['bundle_sha1']}) content = self.call_xmlrpc('scheduler.job_details', job_id) definition = json.loads(content['definition']) if content['multinode_definition']: definition = json.loads(content['multinode_definition']) details.update({"definition": str(json.dumps(definition))}) details['metadata'] = extract_metadata(definition) details['metadata']['device'] = extract_device(definition) details['name'] = extract_name(definition) for action in definition['actions']: if action['command'].startswith("submit_results"): if 'stream' in action['parameters'].keys(): details.update( {"bundlestream": action['parameters']['stream']}) return details
def test_extract_metadata_from_lava_job_with_multiple_actions(self): metadata = extract_metadata({"actions": [{"command": "dummy_deploy", "metadata": {"foo": "bar"}}, {"command": "dummy_deploy", "metadata": {"baz": "qux"}}]}) self.assertEqual(metadata['foo'], 'bar') self.assertEqual(metadata['baz'], 'qux')
def test_extract_metadata_from_lava_job(self): metadata = extract_metadata({"actions": [{"command": "dummy_deploy", "metadata": {"foo": "bar"}}]}) self.assertEqual(metadata['foo'], 'bar')
def test_extract_metadata_from_nested_metadata(self): metadata = extract_metadata({ "something": { "name": "foobar", "metadata" : { "foo": "bar", "baz": "qux" } } }) self.assertEqual(metadata['foo'], 'bar') self.assertEqual(metadata['baz'], 'qux')
def test_extract_metadata_from_json_definition(self): metadata = extract_metadata({ "metadata" : { "foo": "bar", "baz": "qux" } }) self.assertEqual(metadata['foo'], 'bar') self.assertEqual(metadata['baz'], 'qux')
def test_extract_metadata_from_empty_definition(self): self.assertEqual({}, extract_metadata(None))
def test_invalid_json(self): self.assertEqual({}, extract_metadata('//'))
def populate_testjob_metadata(apps, schema_editor): TestJob = apps.get_model('benchmarks', 'TestJob') for testjob in TestJob.objects.all(): testjob.metadata = extract_metadata(testjob.definition) testjob.save()
def test_extract_metadata_from_json_definition(self): metadata = extract_metadata({"metadata": {"foo": "bar", "baz": "qux"}}) self.assertEqual(metadata['foo'], 'bar') self.assertEqual(metadata['baz'], 'qux')