Exemple #1
0
 def test_extract_metadata_from_lava_job(self):
     metadata = extract_metadata({
         "actions": [{
             "command": "dummy_deploy",
             "metadata": {
                 "foo": "bar"
             }
         }]
     })
     self.assertEqual(metadata['foo'], 'bar')
Exemple #2
0
    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')
Exemple #3
0
 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')
Exemple #4
0
    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
Exemple #5
0
    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
Exemple #6
0
 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')
Exemple #7
0
 def test_extract_metadata_from_lava_job(self):
     metadata = extract_metadata({"actions": [{"command": "dummy_deploy", "metadata": {"foo": "bar"}}]})
     self.assertEqual(metadata['foo'], 'bar')
Exemple #8
0
    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')
Exemple #9
0
    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')
Exemple #10
0
 def test_extract_metadata_from_empty_definition(self):
     self.assertEqual({}, extract_metadata(None))
Exemple #11
0
 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 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()
Exemple #14
0
 def test_invalid_json(self):
     self.assertEqual({}, extract_metadata('//'))
Exemple #15
0
    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')
Exemple #16
0
 def test_extract_metadata_from_empty_definition(self):
     self.assertEqual({}, extract_metadata(None))