[llvm-commits] [LNT] r154556 - in /lnt/trunk: lnt/server/db/migrate.py lnt/server/db/migrations/upgrade_0_to_1.py tests/server/db/CreateV4TestSuite.py
Daniel Dunbar
daniel at zuster.org
Wed Apr 11 16:15:04 PDT 2012
Author: ddunbar
Date: Wed Apr 11 18:15:04 2012
New Revision: 154556
URL: http://llvm.org/viewvc/llvm-project?rev=154556&view=rev
Log:
upgrade_0_to_1: Always create test suite definitions for the known test suite types.
Modified:
lnt/trunk/lnt/server/db/migrate.py
lnt/trunk/lnt/server/db/migrations/upgrade_0_to_1.py
lnt/trunk/tests/server/db/CreateV4TestSuite.py
Modified: lnt/trunk/lnt/server/db/migrate.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrate.py?rev=154556&r1=154555&r2=154556&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrate.py (original)
+++ lnt/trunk/lnt/server/db/migrate.py Wed Apr 11 18:15:04 2012
@@ -208,6 +208,6 @@
if not path.startswith('mysql://') and not path.startswith('sqlite://'):
path = 'sqlite:///' + path
- engine = sqlalchemy.create_engine(path, echo=True)
+ engine = sqlalchemy.create_engine(path)
update(engine)
Modified: lnt/trunk/lnt/server/db/migrations/upgrade_0_to_1.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_0_to_1.py?rev=154556&r1=154555&r2=154556&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_0_to_1.py (original)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_0_to_1.py Wed Apr 11 18:15:04 2012
@@ -9,6 +9,9 @@
Base = sqlalchemy.ext.declarative.declarative_base()
+###
+# Core Schema
+
class SampleType(Base):
__tablename__ = 'SampleType'
id = Column("ID", Integer, primary_key=True)
@@ -68,38 +71,117 @@
'TestSuiteSampleFields.ID'))
status_field = relation('SampleField', remote_side=id)
-def create_model_instance(class_, **kwargs):
- instance = class_()
- for key,value in kwargs.items():
- setattr(instance, key, value)
- return instance
-
-def initialize_core(engine):
+def initialize_core(engine, session):
# Create the tables.
Base.metadata.create_all(engine)
- # Create a session.
- session = sqlalchemy.orm.sessionmaker(engine)()
-
# Create the fixed sample kinds.
#
# NOTE: The IDs here are proscribed and should match those from
# 'lnt.testing'.
- session.add(create_model_instance(StatusKind, id=0, name="PASS"))
- session.add(create_model_instance(StatusKind, id=1, name="FAIL"))
- session.add(create_model_instance(StatusKind, id=2, name="XFAIL"))
+ session.add(StatusKind(id=0, name="PASS"))
+ session.add(StatusKind(id=1, name="FAIL"))
+ session.add(StatusKind(id=2, name="XFAIL"))
# Create the fixed status kinds.
- session.add(create_model_instance(SampleType, name="Real"))
- session.add(create_model_instance(SampleType, name="Status"))
+ session.add(SampleType(name="Real"))
+ session.add(SampleType(name="Status"))
session.commit()
+###
+# NTS Testsuite Definition
+
+def initialize_nts_testsuite(engine, session):
+ # Fetch the sample types.
+ real_sample_type = session.query(SampleType).\
+ filter_by(name = "Real").first()
+ status_sample_type = session.query(SampleType).\
+ filter_by(name = "Status").first()
+
+ ts = TestSuite(name="nts", db_key_name="NT")
+
+ # Machine fields.
+ ts.machine_fields.append(MachineField(name="hardware", info_key="hardware"))
+ ts.machine_fields.append(MachineField(name="os", info_key="os"))
+
+ # Order fields.
+ ts.order_fields.append(OrderField(name="llvm_project_revision",
+ info_key="run_order", ordinal=0))
+
+ # Sample fields.
+ compile_status = SampleField(name="compile_status", type=status_sample_type,
+ info_key=".compile.status")
+ compile_time = SampleField(name="compile_time", type=real_sample_type,
+ info_key=".compile", status_field=compile_status)
+ exec_status = SampleField(name="execution_status", type=status_sample_type,
+ info_key=".exec.status")
+ exec_time = SampleField(name="execution_time", type=real_sample_type,
+ info_key=".exec", status_field=exec_status)
+ ts.sample_fields.append(compile_time)
+ ts.sample_fields.append(compile_status)
+ ts.sample_fields.append(exec_time)
+ ts.sample_fields.append(exec_status)
+
+ session.add(ts)
+
+###
+# Compile Testsuite Definition
+
+def initialize_compile_testsuite(engine, session):
+ # Fetch the sample types.
+ real_sample_type = session.query(SampleType).\
+ filter_by(name = "Real").first()
+ status_sample_type = session.query(SampleType).\
+ filter_by(name = "Status").first()
+
+ ts = TestSuite(name="compile", db_key_name="compile")
+
+ # Machine fields.
+ ts.machine_fields.append(MachineField(name="hardware", info_key="hw.model"))
+ ts.machine_fields.append(MachineField(name="os_version",
+ info_key="kern.version"))
+
+ # Order fields.
+ ts.order_fields.append(OrderField(name="llvm_project_revision",
+ info_key="run_order", ordinal=0))
+
+ # Sample fields.
+ for name,type_name in (('user', 'time'),
+ ('sys', 'time'),
+ ('wall', 'time'),
+ ('size', 'bytes'),
+ ('mem', 'bytes')):
+ status = SampleField(
+ name="%s_status" % (name,), type=status_sample_type,
+ info_key=".%s.status" % (name,))
+ ts.sample_fields.append(status)
+ value = SampleField(
+ name="%s_%s" % (name,type_name), type=real_sample_type,
+ info_key=".%s" % (name,), status_field=status)
+ ts.sample_fields.append(value)
+
+ session.add(ts)
+
+###
+
def upgrade(engine):
# This upgrade script is special in that it needs to handle databases "in
# the wild" which have contents but existed before versioning.
+ # Create a session.
+ session = sqlalchemy.orm.sessionmaker(engine)()
+
# If the TestSuite table exists, assume the database is pre-versioning but
# already has the core initalized.
if not TestSuite.__table__.exists(engine):
- initialize_core(engine)
+ initialize_core(engine, session)
+
+ # Initialize all the test suite definitions for NTS and Compile, if they do
+ # not already exist.
+ if session.query(TestSuite).filter_by(name="nts").first() is None:
+ initialize_nts_testsuite(engine, session)
+ if session.query(TestSuite).filter_by(name="compile").first() is None:
+ initialize_compile_testsuite(engine, session)
+
+ session.commit()
Modified: lnt/trunk/tests/server/db/CreateV4TestSuite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/CreateV4TestSuite.py?rev=154556&r1=154555&r2=154556&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/CreateV4TestSuite.py (original)
+++ lnt/trunk/tests/server/db/CreateV4TestSuite.py Wed Apr 11 18:15:04 2012
@@ -12,35 +12,22 @@
# Create an in memory database.
db = v4db.V4DB("sqlite:///:memory:", echo=True)
-# Create a new TestSuite.
-ts = testsuite.TestSuite("nt", "NT")
-db.add(ts)
-
-db.commit()
-
+# We expect exactly two test suites, one for NTS and one for Compile.
test_suites = list(db.query(testsuite.TestSuite))
-assert len(test_suites) == 1
-ts = test_suites[0]
+assert len(test_suites) == 2
-assert ts.name == "nt"
+# Check the NTS test suite.
+ts = db.query(testsuite.TestSuite).filter_by(name="nts").first()
+assert ts.name == "nts"
assert ts.db_key_name == "NT"
-assert len(ts.machine_fields) == 0
-assert len(ts.order_fields) == 0
+assert len(ts.machine_fields) == 2
+assert len(ts.order_fields) == 1
assert len(ts.run_fields) == 0
-# Add a field of each type.
-ts.machine_fields.append(testsuite.MachineField("uname", "uname"))
-ts.order_fields.append(testsuite.OrderField("llvm", "llvm", 0))
-ts.run_fields.append(testsuite.RunField("arch", "ARCH"))
-db.commit()
+assert ts.machine_fields[0].name == "hardware"
+assert ts.machine_fields[1].name == "os"
+
+assert ts.order_fields[0].name == "llvm_project_revision"
-ts = db.query(testsuite.TestSuite).first()
-assert len(ts.machine_fields) == 1
-assert len(ts.order_fields) == 1
-assert len(ts.run_fields) == 1
-assert ts.machine_fields[0].name == "uname"
-assert ts.order_fields[0].name == "llvm"
-assert ts.run_fields[0].name == "arch"
assert ts.machine_fields[0].test_suite is ts
assert ts.order_fields[0].test_suite is ts
-assert ts.run_fields[0].test_suite is ts
More information about the llvm-commits
mailing list