[llvm-commits] [LNT] r169642 - in /lnt/trunk/lnt/server/db: migrations/__init__.py migrations/upgrade_2_to_3.py testsuitedb.py v4db.py
Michael Gottesman
mgottesman at apple.com
Fri Dec 7 14:04:55 PST 2012
Author: mgottesman
Date: Fri Dec 7 16:04:55 2012
New Revision: 169642
URL: http://llvm.org/viewvc/llvm-project?rev=169642&view=rev
Log:
[fieldchange] Added v3 of the schema that includes the new data FieldChange.
This will be used for tracking regressions.
Added:
lnt/trunk/lnt/server/db/migrations/__init__.py
lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py
Modified:
lnt/trunk/lnt/server/db/testsuitedb.py
lnt/trunk/lnt/server/db/v4db.py
Added: lnt/trunk/lnt/server/db/migrations/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/__init__.py?rev=169642&view=auto
==============================================================================
(empty)
Added: lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py?rev=169642&view=auto
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py (added)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py Fri Dec 7 16:04:55 2012
@@ -0,0 +1,64 @@
+# Version 3 of the database adds the FieldChange class to track flagged
+# regressions in the database.
+
+import os
+import sys
+
+import sqlalchemy
+from sqlalchemy import *
+from sqlalchemy.schema import Index
+from sqlalchemy.orm import relation
+
+# Import the original schema from upgrade_0_to_1 since upgrade_1_to_2 does not
+# change the actual schema, but rather adds functionality vis-a-vis orders.
+import lnt.server.db.migrations.upgrade_0_to_1 as upgrade_0_to_1
+
+###
+# Upgrade TestSuite
+
+def add_fieldchange(test_suite):
+ # Grab the Base for the previous schema so that we have all
+ # the definitions we need.
+ Base = upgrade_0_to_1.get_base_for_testsuite(test_suite)
+ # Grab our db_key_name for our test suite so we can properly
+ # prefix our fields/table names.
+ db_key_name = test_suite.db_key_name
+
+ class FieldChange(Base):
+ __tablename__ = db_key_name + '_FieldChange'
+ id = Column("ID", Integer, primary_key = True)
+ start_order_id = Column("StartOrderID", Integer,
+ ForeignKey("%s_Order.ID" % db_key_name))
+ end_order_id = Column("EndOrderID", Integer,
+ ForeignKey("%s_Order.ID" % db_key_name))
+ test_id = Column("TestID", Integer,
+ ForeignKey("%s_Test.ID" % db_key_name))
+ machine_id = Column("MachineID", Integer,
+ ForeignKey("%s_Machine.ID" % db_key_name))
+ field_id = Column("FieldID", Integer,
+ ForeignKey(upgrade_0_to_1.SampleField.id))
+
+ return Base
+
+def upgrade_testsuite(engine, session, name):
+ # Grab Test Suite.
+ test_suite = session.query(upgrade_0_to_1.TestSuite).\
+ filter_by(name=name).first()
+ assert(test_suite is not None)
+
+ # Add FieldChange to the test suite.
+ Base = add_fieldchange(test_suite)
+
+ # Create tables.
+ Base.metadata.create_all(engine)
+
+def upgrade(engine):
+ # Create a session.
+ session = sqlalchemy.orm.sessionmaker(engine)()
+
+ # Create our FieldChangeField table and commit.
+ upgrade_testsuite(engine, session, 'nts')
+ upgrade_testsuite(engine, session, 'compile')
+
+ # Commit changes.
+ session.commit()
Modified: lnt/trunk/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/testsuitedb.py?rev=169642&r1=169641&r2=169642&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/testsuitedb.py (original)
+++ lnt/trunk/lnt/server/db/testsuitedb.py Fri Dec 7 16:04:55 2012
@@ -366,18 +366,62 @@
def __repr__(self):
fields = dict((item.name, self.get_field(item))
- for item in self.fields)
+ for item in self.fields)
return '%s_%s(%r, %r, **%r)' % (
db_key_name, self.__class__.__name__,
self.run, self.test, fields)
+
+ class FieldChange(self.base, ParameterizedMixin):
+ """FieldChange represents a change in between the values
+ of the same field belonging to two samples from consecutive runs."""
+
+ __tablename__ = db_key_name + '_FieldChange'
+ id = Column("ID", Integer, primary_key = True)
+ start_order_id = Column("StartOrderID", Integer,
+ ForeignKey("%s_Order.ID" % db_key_name))
+ end_order_id = Column("EndOrderID", Integer,
+ ForeignKey("%s_Order.ID" % db_key_name))
+ test_id = Column("TestID", Integer,
+ ForeignKey("%s_Test.ID" % db_key_name))
+ machine_id = Column("MachineID", Integer,
+ ForeignKey("%s_Machine.ID" % db_key_name))
+ field_id = Column("FieldID", Integer,
+ ForeignKey(self.v4db.SampleField.id))
+
+ start_order = sqlalchemy.orm.relation(Order,
+ primaryjoin='FieldChange.'\
+ 'start_order_id==Order.id')
+ end_order = sqlalchemy.orm.relation(Order,
+ primaryjoin='FieldChange.'\
+ 'end_order_id==Order.id')
+ test = sqlalchemy.orm.relation(Test)
+ machine = sqlalchemy.orm.relation(Machine)
+ field = sqlalchemy.orm.relation(self.v4db.SampleField,
+ primaryjoin= \
+ self.v4db.SampleField.id == \
+ field_id)
+
+ def __init__(self, start_order, end_order, test, machine,
+ field):
+ self.start_order = start_order
+ self.end_order = end_order
+ self.test = test
+ self.machine = machine
+ self.field = field
+
+ def __repr__(self):
+ return '%s_%s%r' % (db_key_name, self.__class__.__name__,
+ (self.start_order, self.end_order,
+ self.test, self.machine, self.field))
self.Machine = Machine
self.Run = Run
self.Test = Test
self.Sample = Sample
self.Order = Order
-
+ self.FieldChange = FieldChange
+
# Create the compound index we cannot declare inline.
sqlalchemy.schema.Index("ix_%s_Sample_RunID_TestID" % db_key_name,
Sample.run_id, Sample.test_id)
Modified: lnt/trunk/lnt/server/db/v4db.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/v4db.py?rev=169642&r1=169641&r2=169642&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/v4db.py (original)
+++ lnt/trunk/lnt/server/db/v4db.py Fri Dec 7 16:04:55 2012
@@ -100,6 +100,7 @@
self.SampleType = testsuite.SampleType
self.StatusKind = testsuite.StatusKind
self.TestSuite = testsuite.TestSuite
+ self.SampleField = testsuite.SampleField
# Resolve or create the known status kinds.
self.pass_status_kind = self.query(testsuite.StatusKind)\
More information about the llvm-commits
mailing list