diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 548: Merge add-on-to-testdef-yaml branch which adds additional metadata parameters

Message ID 20130129103312.11798.50225.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Senthil Kumaran Jan. 29, 2013, 10:33 a.m. UTC
Merge authors:
  Senthil Kumaran S (stylesen)
Related merge proposals:
  https://code.launchpad.net/~stylesen/lava-dispatcher/add-on-to-testdef-yaml/+merge/144214
  proposed by: Senthil Kumaran S (stylesen)
------------------------------------------------------------
revno: 548 [merge]
committer: Senthil Kumaran <senthil.kumaran@linaro.org>
branch nick: trunk
timestamp: Tue 2013-01-29 16:01:10 +0530
message:
  Merge add-on-to-testdef-yaml branch which adds additional metadata parameters
  to test definition YAML format.
modified:
  lava_dispatcher/actions/lava_test_shell.py
  lava_dispatcher/lava_test_shell.py
  lava_dispatcher/test_data.py
  lava_test_shell/lava-test-runner-android
  lava_test_shell/lava-test-runner-ubuntu


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/actions/lava_test_shell.py'
--- lava_dispatcher/actions/lava_test_shell.py	2013-01-15 17:23:13 +0000
+++ lava_dispatcher/actions/lava_test_shell.py	2013-01-28 08:51:59 +0000
@@ -53,6 +53,7 @@ 
 #          uuid                    The "analyzer_assigned_uuid" of the
 #                                  test_run that is being generated.
 #          testdef.yml             The test definition.
+#          testdef_metadata        Metadata extracted from test definition.
 #          install.sh              The install steps.
 #          run.sh                  The run steps.
 #          [repos]                 The test definition can specify bzr or git
@@ -74,6 +75,7 @@ 
 #          pkgs.txt                Ditto
 #       ${IDX}_${TEST_ID}-${TIMESTAMP}/
 #          testdef.yml
+#          testdef_metadata
 #          stdout.log
 #          return_code             The exit code of run.sh.
 #          analyzer_assigned_uuid
@@ -173,8 +175,7 @@ 
     cwd = os.getcwd()
     gitdir = os.path.join(tmpdir, 'gittestrepo')
     try:
-        subprocess.check_call(['git', 'clone', testdef_repo,
-                                  gitdir])
+        subprocess.check_call(['git', 'clone', testdef_repo, gitdir])
         if revision:
             os.chdir(gitdir)
             subprocess.check_call(['git', 'checkout', revision])
@@ -201,6 +202,26 @@ 
         logging.error('Unable to get test definition from bzr\n' + str(e))
 
 
+def _get_testdef_info(testdef):
+    metadata = {'os': '', 'devices': '', 'environment': ''}
+    metadata['version'] = str(testdef['metadata'].get('version'))
+    metadata['description'] = str(testdef['metadata'].get('description'))
+    metadata['format'] = str(testdef['metadata'].get('format'))
+
+    # Convert list to comma separated string.
+    if testdef['metadata'].get('os'):
+        metadata['os'] = ','.join(testdef['metadata'].get('os'))
+
+    if testdef['metadata'].get('devices'):
+        metadata['devices'] = ','.join(testdef['metadata'].get('devices'))
+
+    if testdef['metadata'].get('environment'):
+        metadata['environment'] = ','.join(
+            testdef['metadata'].get('environment'))
+
+    return metadata
+
+
 class TestDefinitionLoader(object):
     """
     A TestDefinitionLoader knows how to load test definitions from the data
@@ -227,7 +248,10 @@ 
 
         idx = len(self.testdefs)
 
-        self._append_testdef(URLTestDefinition(self.context, idx, testdef))
+        testdef_metadata = {'url': url, 'location': 'URL'}
+        testdef_metadata.update(_get_testdef_info(testdef))
+        self._append_testdef(URLTestDefinition(self.context, idx, testdef,
+                                               testdef_metadata))
 
     def load_from_repo(self, testdef_repo):
         tmpdir = utils.mkdtemp(self.tmpbase)
@@ -289,9 +313,10 @@ 
     A test definition that was loaded from a URL.
     """
 
-    def __init__(self, context, idx, testdef):
+    def __init__(self, context, idx, testdef, testdef_metadata):
         self.context = context
         self.testdef = testdef
+        self.testdef_metadata = testdef_metadata
         self.idx = idx
         self.test_run_id = '%s_%s' % (idx, self.testdef['metadata']['name'])
         self.uuid = str(uuid4())
@@ -378,6 +403,9 @@ 
         with open('%s/uuid' % hostdir, 'w') as f:
             f.write(self.uuid)
 
+        with open('%s/testdef_metadata' % hostdir, 'w') as f:
+            f.write(yaml.dump(self.testdef_metadata))
+
         if 'install' in self.testdef:
             self._create_repos(hostdir)
             self._create_target_install(hostdir, targetdir)
@@ -408,7 +436,14 @@ 
     """
 
     def __init__(self, context, idx, testdef, repo, info):
-        URLTestDefinition.__init__(self, context, idx, testdef)
+        testdef_metadata = {}
+        testdef_metadata.update({'url': info['branch_url']})
+        testdef_metadata.update({'location': info['branch_vcs'].upper()})
+        testdef_metadata.update({'repo_rev': info['branch_revision']})
+        testdef_metadata.update(_get_testdef_info(testdef))
+
+        URLTestDefinition.__init__(self, context, idx, testdef,
+                                   testdef_metadata)
         self.repo = repo
         self._sw_sources.append(info)
 

=== modified file 'lava_dispatcher/lava_test_shell.py'
--- lava_dispatcher/lava_test_shell.py	2013-01-14 03:08:36 +0000
+++ lava_dispatcher/lava_test_shell.py	2013-01-28 08:29:21 +0000
@@ -292,8 +292,11 @@ 
     uuid = _read_content(os.path.join(test_run_dir, 'analyzer_assigned_uuid'))
     attachments = _get_run_attachments(test_run_dir, testdef, stdout)
     attributes = _attributes_from_dir(os.path.join(test_run_dir, 'attributes'))
+    testdef_metadata = _read_content(os.path.join(test_run_dir,
+                                                  'testdef_metadata'))
 
     testdef = yaml.load(testdef)
+    testdef_metadata = yaml.load(testdef_metadata)
     if uuid in testdefs_by_uuid:
         sw_sources = testdefs_by_uuid[uuid]._sw_sources
     else:
@@ -311,6 +314,7 @@ 
         'hardware_context': hwcontext,
         'attachments': attachments,
         'attributes': attributes,
+        'testdef_metadata': testdef_metadata,
     }
 
 

=== modified file 'lava_dispatcher/test_data.py'
--- lava_dispatcher/test_data.py	2012-07-31 20:20:02 +0000
+++ lava_dispatcher/test_data.py	2013-01-28 08:29:21 +0000
@@ -34,7 +34,8 @@ 
     def __init__(self, test_id='lava'):
         self.job_status = 'pass'
         self.metadata = {}
-        self._test_run = { 'test_results':[], 'attachments':[], 'tags':[] }
+        self._test_run = { 'test_results':[], 'attachments':[], 'tags':[],
+                           'testdef_metadata':{} }
         self._test_run['test_id'] = test_id
         self._assign_date()
         self._assign_uuid()
@@ -75,4 +76,3 @@ 
     def get_test_run(self):
         self.add_result('job_complete', self.job_status)
         return self._test_run
-

=== modified file 'lava_test_shell/lava-test-runner-android'
--- lava_test_shell/lava-test-runner-android	2013-01-04 13:23:08 +0000
+++ lava_test_shell/lava-test-runner-android	2013-01-28 08:51:59 +0000
@@ -92,6 +92,7 @@ 
 		mkdir ${odir}
 		mkdir ${odir}/attachments/
 		cp ${line}/testdef.yaml ${odir}/
+		cp ${line}/testdef_metadata ${odir}/
 		cp ${line}/uuid ${odir}/analyzer_assigned_uuid
 		cp ${line}/run.sh ${odir}/attachments/
 		echo 'text/plain' > ${odir}/attachments/run.sh.mimetype

=== modified file 'lava_test_shell/lava-test-runner-ubuntu'
--- lava_test_shell/lava-test-runner-ubuntu	2013-01-14 16:30:05 +0000
+++ lava_test_shell/lava-test-runner-ubuntu	2013-01-28 08:51:59 +0000
@@ -76,6 +76,7 @@ 
 	mkdir ${odir}/attachments/
 	cp ${line}/uuid ${odir}/analyzer_assigned_uuid
 	cp ${line}/testdef.yaml ${odir}/
+	cp ${line}/testdef_metadata ${odir}/
 	cp ${line}/run.sh ${odir}/attachments/
 	echo 'text/plain' > ${odir}/attachments/run.sh.mimetype
 	if [ -f ${line}/install.sh ]; then