[llvm-commits] [zorg] r147998 - in /zorg/trunk/lnt/lnt: db/perfdb.py server/config.py server/db/testsuitedb.py server/db/v4db.py util/ImportData.py

Daniel Dunbar daniel at zuster.org
Wed Jan 11 17:27:41 PST 2012


Author: ddunbar
Date: Wed Jan 11 19:27:41 2012
New Revision: 147998

URL: http://llvm.org/viewvc/llvm-project?rev=147998&view=rev
Log:
[lnt/v0.4] lnt.server.db.testsuitedb: Allow configs to declare a "simple run source", in which case the v0.4 import process will attempt to automatically populate the SimpleRunID field.
 - This commit is mostly just threading the config object around, the actual interesting bit is in testsuitedb.py.
 - WIP on <rdar://problem/10665231> [lnt] Support old simple/ links in v0.4 schema

Modified:
    zorg/trunk/lnt/lnt/db/perfdb.py
    zorg/trunk/lnt/lnt/server/config.py
    zorg/trunk/lnt/lnt/server/db/testsuitedb.py
    zorg/trunk/lnt/lnt/server/db/v4db.py
    zorg/trunk/lnt/lnt/util/ImportData.py

Modified: zorg/trunk/lnt/lnt/db/perfdb.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdb.py?rev=147998&r1=147997&r2=147998&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/db/perfdb.py (original)
+++ zorg/trunk/lnt/lnt/db/perfdb.py Wed Jan 11 19:27:41 2012
@@ -341,7 +341,7 @@
         self.session.rollback()
         self.modified_machine = self.modified_test = self.modified_run = False
 
-    def importDataFromDict(self, data):
+    def importDataFromDict(self, data, config=None):
         return importDataFromDict(self, data)
 
     def get_db_summary(self):

Modified: zorg/trunk/lnt/lnt/server/config.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/config.py?rev=147998&r1=147997&r2=147998&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/config.py (original)
+++ zorg/trunk/lnt/lnt/server/config.py Wed Jan 11 19:27:41 2012
@@ -53,16 +53,19 @@
                       bool(dict.get('showSimple')),
                       str(dict.get('db_version', '0.3')),
                       dict.get('shadow_import', None),
+                      dict.get('simple_run_source', None),
                       email_config)
 
     def __init__(self, path, showNightlytest, showGeneral, showSimple,
-                 db_version, shadow_import, email_config):
+                 db_version, shadow_import, simple_run_source, email_config):
+        self.config = None
         self.path = path
         self.showGeneral = showGeneral
         self.showNightlytest = showNightlytest
         self.showSimple = showSimple
         self.db_version = db_version
         self.shadow_import = shadow_import
+        self.simple_run_source = simple_run_source
         self.email_config = email_config
 
 class Config:
@@ -99,6 +102,8 @@
         while self.zorgURL.endswith('/'):
             self.zorgURL = zorgURL[:-1]
         self.databases = databases
+        for db in self.databases.values():
+            db.config = self
 
     def get_database(self, name, echo=False):
         """

Modified: zorg/trunk/lnt/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/testsuitedb.py?rev=147998&r1=147997&r2=147998&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/db/testsuitedb.py (original)
+++ zorg/trunk/lnt/lnt/server/db/testsuitedb.py Wed Jan 11 19:27:41 2012
@@ -568,7 +568,7 @@
 
                 sample.set_field(sample_field, value)
 
-    def importDataFromDict(self, data):
+    def importDataFromDict(self, data, config=None):
         """
         importDataFromDict(data) -> Run, bool
 
@@ -595,8 +595,40 @@
 
         self._importSampleValues(data['Tests'], run, tag)
 
+        # If we have a config object and we have a database which we are
+        # supposed to link simple/ runs from, attempt to find the matching run
+        # in that database.
+        if config and config.simple_run_source:
+            self.find_and_set_simple_run_id(run, data, config)
+
         return True, run
 
+
+    def find_and_set_simple_run_id(self, run, data, config):
+        # Get the database we are supposed to match run IDs in.
+        db = config.config.get_database(config.simple_run_source)
+
+        # Figure out the matching machine.
+        simple_machine,created = db.getOrCreateMachine(
+            data['Machine']['Name'], data['Machine']['Info'].items())
+        if created:
+            # Obviously missing, rollback and abort.
+            db.rollback()
+            return
+
+        run_data = data['Run']
+        simple_run,created = db.getOrCreateRun(
+            simple_machine,
+            run_data.get('Start Time',''), run_data.get('End Time',''),
+            run_data['Info'].items())
+        if created:
+            # Obviously missing, rollback and abort.
+            db.rollback()
+            return
+
+        # Otherwise, we found the run.
+        run.simple_run_id = simple_run.id
+
     # Simple query support (mostly used by templates)
 
     def machines(self, name=None):

Modified: zorg/trunk/lnt/lnt/server/db/v4db.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/v4db.py?rev=147998&r1=147997&r2=147998&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/db/v4db.py (original)
+++ zorg/trunk/lnt/lnt/server/db/v4db.py Wed Jan 11 19:27:41 2012
@@ -108,7 +108,7 @@
         return sum([ts.query(ts.Test).count()
                     for ts in self.testsuite.values()])
 
-    def importDataFromDict(self, data):
+    def importDataFromDict(self, data, config=None):
         # Select the database to import into.
         #
         # FIXME: Promote this to a top-level field in the data.
@@ -121,7 +121,7 @@
             raise ValueError,"test suite %r not present in this database!" % (
                 db_name)
 
-        return db.importDataFromDict(data)
+        return db.importDataFromDict(data, config)
 
     def get_db_summary(self):
         return V4DBSummary(self)

Modified: zorg/trunk/lnt/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=147998&r1=147997&r2=147998&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/util/ImportData.py (original)
+++ zorg/trunk/lnt/lnt/util/ImportData.py Wed Jan 11 19:27:41 2012
@@ -45,10 +45,16 @@
 
     result['load_time'] = time.time() - startTime
 
+    # Find the database config, if we have a configuration object.
+    if config:
+        db_config = config.databases[db_name]
+    else:
+        db_config = None
+
     # Find the email address for this machine's results.
     toAddress = email_config = None
-    if config and not disable_email:
-        email_config = config.databases[db_name].email_config
+    if db_config and not disable_email:
+        email_config = db_config.email_config
         if email_config.enabled:
             # Find the machine name.
             machineName = str(data.get('Machine',{}).get('Name'))
@@ -60,7 +66,7 @@
 
     importStartTime = time.time()
     try:
-        success,run = db.importDataFromDict(data)
+        success,run = db.importDataFromDict(data, config=db_config)
     except KeyboardInterrupt:
         raise
     except:





More information about the llvm-commits mailing list