[LNT] r307963 - Use yaml schema mechanism to describe compile suite

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 14:20:43 PDT 2017


Author: matze
Date: Thu Jul 13 14:20:43 2017
New Revision: 307963

URL: http://llvm.org/viewvc/llvm-project?rev=307963&view=rev
Log:
Use yaml schema mechanism to describe compile suite

This re-applies r307562 now that the metatables are upgraded in sync
with the yaml so the fieldchange mechanism should work again and migrate
cleanly. It also comes with a more robust migration script.

This converts the existing compile suite schema which was previously
configured via the TestSuiteXXX tables in lnt/server/db/migrations to
use the new yaml schema mechanism instead.

- Adds schemas/compile.yaml with the test suite definition.
- Adds a migration that removes the compile definitions in the
  TestSuiteXXX meta tables. It also drops the compile tables if they are
  empty (and otherwise leaves them untouched).
- This means by default the compile suite will not be visible anymore.
  Users using the 'compile' suite need to copy or symlink
  schemas/compile.yaml into $LNTINSTANCEPATH/schemas/compile.yaml

Added:
    lnt/trunk/lnt/server/db/migrations/upgrade_13_to_14.py
    lnt/trunk/schemas/README.md
    lnt/trunk/schemas/compile.yaml
Modified:
    lnt/trunk/tests/SharedInputs/create_temp_instance.py
    lnt/trunk/tests/server/db/CreateV4TestSuite.py

Added: lnt/trunk/lnt/server/db/migrations/upgrade_13_to_14.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_13_to_14.py?rev=307963&view=auto
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_13_to_14.py (added)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_13_to_14.py Thu Jul 13 14:20:43 2017
@@ -0,0 +1,74 @@
+# The "compile" suite is handled by the compile.yaml schema file now.
+# This means we drop the entry in the TestSuite meta tables.
+# The existing tables are either dropped if they are empty. We have to rename
+# them if they are not empty, as previously the test-suite name was different
+# from the prefix used in the tables. In yaml schemas the name and prefix is
+# always the same so we have to rename from `Compile_XXXX` to `compile_XXX`.
+import sqlalchemy
+
+
+def _drop_suite(trans, name):
+    trans.execute('''
+DELETE FROM "TestSuiteOrderFields"
+    WHERE "TestSuiteID" IN
+        (SELECT "ID" FROM "TestSuite" WHERE "Name" = \'compile\')
+''')
+    trans.execute('''
+DELETE FROM "TestSuiteMachineFields"
+    WHERE "TestSuiteID" IN
+        (SELECT "ID" FROM "TestSuite" WHERE "Name" = \'compile\')
+''')
+    trans.execute('''
+DELETE FROM "TestSuiteRunFields"
+    WHERE "TestSuiteID" IN
+        (SELECT "ID" FROM "TestSuite" WHERE "Name" = \'compile\')
+''')
+    trans.execute('''
+DELETE FROM "TestSuiteSampleFields"
+    WHERE "TestSuiteID" IN
+        (SELECT "ID" FROM "TestSuite" WHERE "Name" = \'compile\')
+''')
+    trans.execute('DELETE FROM "TestSuite" WHERE "Name" = \'compile\'')
+
+
+def upgrade(engine):
+    tablenames = [
+        ('Compile_Baseline', 'compile_Baseline'),
+        ('Compile_ChangeIgnore', 'compile_ChangeIgnore'),
+        ('Compile_RegressionIndicator', 'compile_RegressionIndicator'),
+        ('Compile_FieldChange', 'compile_FieldChange'),
+        ('Compile_FieldChangeV2', 'compile_FieldChangeV2'),
+        ('Compile_Profile', 'compile_Profile'),
+        ('Compile_Regression', 'compile_Regression'),
+        ('Compile_Sample', 'compile_Sample'),
+        ('Compile_Run', 'compile_Run'),
+        ('Compile_Order', 'compile_Order'),
+        ('Compile_Test', 'compile_Test'),
+        ('Compile_Machine', 'compile_Machine'),
+    ]
+    all_empty = True
+    for name, _ in tablenames:
+        num = engine.execute('SELECT COUNT(*) FROM "%s"' % name).first()
+        if num[0] > 0:
+            all_empty = False
+            break
+
+    with engine.begin() as trans:
+        # If nobody ever put data into the compile suite drop it
+        if all_empty:
+            for name, _ in tablenames:
+                trans.execute('DROP TABLE "%s"' % name)
+            _drop_suite(trans, 'compile')
+        else:
+            for old_name, new_name in tablenames:
+                env = {'old_name': old_name, 'new_name': new_name}
+                trans.execute('''
+ALTER TABLE "%(old_name)s" RENAME TO "%(new_name)s_x"
+''' % env)
+                trans.execute('''
+ALTER TABLE "%(new_name)s_x" RENAME TO \"%(new_name)s\"
+''' % env)
+            # Just change the DB_Key to match the name
+            trans.execute('''
+UPDATE "TestSuite" SET "DBKeyName" = \'compile\' WHERE "Name" = \'compile\'
+''')

Added: lnt/trunk/schemas/README.md
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/schemas/README.md?rev=307963&view=auto
==============================================================================
--- lnt/trunk/schemas/README.md (added)
+++ lnt/trunk/schemas/README.md Thu Jul 13 14:20:43 2017
@@ -0,0 +1,2 @@
+This directory contains schema files describing test suites. You can copy them
+or create symlinks to the schemas directory of an lnt instance to enable them.

Added: lnt/trunk/schemas/compile.yaml
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/schemas/compile.yaml?rev=307963&view=auto
==============================================================================
--- lnt/trunk/schemas/compile.yaml (added)
+++ lnt/trunk/schemas/compile.yaml Thu Jul 13 14:20:43 2017
@@ -0,0 +1,30 @@
+# This schema is used by the `lnt runtest compile` suite.
+format_version: '2'
+name: compile
+metrics:
+  - name: user_time
+    type: Real
+  - name: user_status
+    type: Status
+  - name: sys_time
+    type: Real
+  - name: sys_status
+    type: Status
+  - name: wall_time
+    type: Real
+  - name: wall_status
+    type: Status
+  - name: size_bytes
+    type: Real   # Should be Integer but we don't want to invalidate old data
+  - name: size_status
+    type: Status
+  - name: mem_bytes
+    type: Real
+  - name: mem_status
+    type: Status
+run_fields:
+  - name: llvm_project_revision
+    order: true
+machine_fields:
+  - name: hardware
+  - name: os_version

Modified: lnt/trunk/tests/SharedInputs/create_temp_instance.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/SharedInputs/create_temp_instance.py?rev=307963&r1=307962&r2=307963&view=diff
==============================================================================
--- lnt/trunk/tests/SharedInputs/create_temp_instance.py (original)
+++ lnt/trunk/tests/SharedInputs/create_temp_instance.py Thu Jul 13 14:20:43 2017
@@ -128,5 +128,9 @@ def main():
                  dest_dir)
     if extra_sql:
         run_sql_file(lnt_db, extra_sql, dest_dir)
+    os.mkdir(os.path.join(dest_dir, 'schemas'))
+    filedir = os.path.dirname(__file__)
+    os.symlink(os.path.join(filedir, '..', '..', 'schemas', 'compile.yaml'),
+               os.path.join(dest_dir, 'schemas', 'compile.yaml'))
 
 main()

Modified: lnt/trunk/tests/server/db/CreateV4TestSuite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/CreateV4TestSuite.py?rev=307963&r1=307962&r2=307963&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/CreateV4TestSuite.py (original)
+++ lnt/trunk/tests/server/db/CreateV4TestSuite.py Thu Jul 13 14:20:43 2017
@@ -13,9 +13,9 @@ from lnt.server.db import v4db
 # Create an in memory database.
 db = v4db.V4DB("sqlite:///:memory:", Config.dummy_instance(), echo=True)
 
-# We expect exactly two test suites, one for NTS and one for Compile.
+# We expect exactly the NTS test suite.
 test_suites = list(db.query(testsuite.TestSuite))
-assert len(test_suites) == 2
+assert len(test_suites) == 1
 
 # Check the NTS test suite.
 ts = db.query(testsuite.TestSuite).filter_by(name="nts").first()




More information about the llvm-commits mailing list