[llvm-commits] [LNT] r154719 - in /lnt/trunk: lnt/testing/__init__.py lnt/util/ImportData.py tests/server/db/ImportV4TestSuiteInstance.py
Daniel Dunbar
daniel at zuster.org
Fri Apr 13 16:36:28 PDT 2012
Author: ddunbar
Date: Fri Apr 13 18:36:28 2012
New Revision: 154719
URL: http://llvm.org/viewvc/llvm-project?rev=154719&view=rev
Log:
lnt.util.ImportData: Add some report versioning, so that we can auto-upgrade incoming reports.
- This is a companion to the previous commit (which was aimed at upgrading the exist database), for ensuring that imports of old reports result in the new run order variant.
Modified:
lnt/trunk/lnt/testing/__init__.py
lnt/trunk/lnt/util/ImportData.py
lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py
Modified: lnt/trunk/lnt/testing/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/__init__.py?rev=154719&r1=154718&r2=154719&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/__init__.py (original)
+++ lnt/trunk/lnt/testing/__init__.py Fri Apr 13 18:36:28 2012
@@ -6,8 +6,9 @@
data suitable for submitting to the server.
"""
-import time
import datetime
+import time
+import re
try:
import json
@@ -138,4 +139,83 @@
'Info' : self.info,
'Data' : self.data }
+###
+# Report Versioning
+
+# We record information on the report "version" to allow the server to support
+# some level of auto-upgrading data from submissions of older reports.
+#
+# We recorder the report version as a reserved key in the run information
+# (primarily so that it can be accessed post-import on the server).
+#
+# Version 0 -- : initial (and unversioned).
+#
+# Version 1 -- 2012-04-12: run_order was changed to not be padded, and allow
+# non-integral values.
+current_version = 1
+
+def upgrade_0_to_1(data):
+ # We recompute the run_order here if it looks like this run_order was
+ # derived (we presume from sniffing a compiler).
+ run_info = data['Run']['Info']
+ run_order = run_info.get('run_order')
+ inferred_run_order = run_info.get('inferred_run_order')
+
+ # If the run order is missing, or wasn't the inferred one, do nothing.
+ if run_order is None or (run_order != inferred_run_order and
+ inferred_run_order is not None):
+ return
+
+ # Otherwise, assume this run order was derived.
+
+ # Trim whitespace.
+ run_order = run_order.strip()
+ run_info['run_order'] = run_info['inferred_run_order'] = run_order
+
+ # If this was a production Clang build, try to recompute the src tag.
+ if 'clang' in run_info.get('cc_name','') and \
+ run_info.get('cc_build') == 'PROD' and \
+ run_info.get('cc_src_tag') and \
+ run_order == run_info['cc_src_tag'].strip():
+ # Extract the version line.
+ version_ln = None
+ for ln in run_info.get('cc_version', '').split('\n'):
+ if ' version ' in ln:
+ version_ln = ln
+ break
+ else:
+ # We are done if we didn't find one.
+ return
+
+ # Extract the build string.
+ m = re.match(r'(.*) version ([^ ]*) (\([^(]*\))(.*)',
+ version_ln)
+ if not m:
+ return
+
+ cc_name,cc_version_num,cc_build_string,cc_extra = m.groups()
+ m = re.search('clang-([0-9.]*)', cc_build_string)
+ if m:
+ run_info['run_order'] = run_info['inferred_run_order'] = \
+ run_info['cc_src_tag'] = m.group(1)
+
+def upgrade_report(data):
+ # Get the report version.
+ report_version = int(data['Run']['Info'].get('__report_version__', 0))
+
+ # Check if the report is current.
+ if report_version == current_version:
+ return data
+
+ # Check if the version is out-of-range.
+ if report_version > current_version:
+ raise ValueError("unknown report version: %r" % (report_version,))
+
+ # Otherwise, we need to upgrade it.
+ for version in range(report_version, current_version):
+ upgrade_method = globals().get('upgrade_%d_to_%d' % (
+ version, version+1))
+ upgrade_method(data)
+ data['Run']['Info']['__report_version__'] = str(version + 1)
+
__all__ = ['Report', 'Machine', 'Run', 'TestSamples']
Modified: lnt/trunk/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/ImportData.py?rev=154719&r1=154718&r2=154719&view=diff
==============================================================================
--- lnt/trunk/lnt/util/ImportData.py (original)
+++ lnt/trunk/lnt/util/ImportData.py Fri Apr 13 18:36:28 2012
@@ -1,6 +1,7 @@
import os, re, time
import lnt.db.perfdb
+import lnt.testing
from lnt import formats
from lnt.db import runinfo
from lnt.util import NTEmailReport
@@ -46,6 +47,9 @@
result['load_time'] = time.time() - startTime
+ # Auto-upgrade the data, if necessary.
+ lnt.testing.upgrade_report(data)
+
# Find the database config, if we have a configuration object.
if config:
db_config = config.databases[db_name]
Modified: lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py?rev=154719&r1=154718&r2=154719&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py (original)
+++ lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py Fri Apr 13 18:36:28 2012
@@ -80,10 +80,10 @@
print order_b
assert order_a.previous_order_id is None
assert order_a.next_order_id is order_b.id
-assert order_a.llvm_project_revision == u'% 7d' % 1
+assert order_a.llvm_project_revision == '1'
assert order_b.previous_order_id is order_a.id
assert order_b.next_order_id is None
-assert order_b.llvm_project_revision == u'% 7d' % 2
+assert order_b.llvm_project_revision == '2'
# Validate the runs.
runs = list(ts.query(ts.Run))
@@ -97,8 +97,10 @@
assert run_b.imported_from.endswith("sample-b-small.plist")
assert run_a.start_time == datetime.datetime(2009, 11, 17, 2, 12, 25)
assert run_a.end_time == datetime.datetime(2009, 11, 17, 3, 44, 48)
-assert not run_a.parameters
-assert not run_b.parameters
+assert tuple(sorted(run_a.parameters.items())) == \
+ (('__report_version__', '1'), ('inferred_run_order', '1'))
+assert tuple(sorted(run_b.parameters.items())) == \
+ (('__report_version__', '1'), ('inferred_run_order', '2'))
# Validate the samples.
samples = list(ts.query(ts.Sample))
More information about the llvm-commits
mailing list