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

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 11:10:33 PDT 2017


Author: matze
Date: Mon Jul 10 11:10:32 2017
New Revision: 307562

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

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/
    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=307562&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 Mon Jul 10 11:10:32 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_table_if_empty(trans, name):
+    num = trans.execute('SELECT COUNT(*) FROM "%s"' % name).first()
+    if num[0] == 0:
+        trans.execute('DROP TABLE "%s"' % name)
+        return True
+    return False
+
+
+def upgrade(engine):
+    # The following is expected to fail if the user never had an old
+    # version of the database that create the Compile_XXX tables.
+    try:
+        renames = {
+            'Compile_Machine': 'compile_Machine',
+            'Compile_Order': 'compile_Order',
+            'Compile_Run': 'compile_Run',
+            'Compile_Sample': 'compile_Sample',
+            'Compile_Profile': 'compile_Profile',
+            'Compile_FieldChange': 'compile_FieldChange',
+            'Compile_FieldChangeV2': 'compile_FieldChangeV2',
+            'Compile_Regression': 'compile_Regression',
+            'Compile_RegressionIndicator': 'compile_RegressionIndicator',
+            'Compile_ChangeIgnore': 'compile_ChangeIgnore',
+            'Compile_BaseLine': 'compile_Baseline',
+        }
+        with engine.begin() as trans:
+            for old_name, new_name in renames.items():
+                if _drop_table_if_empty(trans, old_name):
+                    continue;
+                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)
+    except Exception as e:
+        import traceback
+        traceback.print_exc()
+
+    # Drop Compile suite information from meta tables
+    with engine.begin() as trans:
+        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'
+''')

Added: lnt/trunk/schemas/README.md
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/schemas/README.md?rev=307562&view=auto
==============================================================================
--- lnt/trunk/schemas/README.md (added)
+++ lnt/trunk/schemas/README.md Mon Jul 10 11:10:32 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=307562&view=auto
==============================================================================
--- lnt/trunk/schemas/compile.yaml (added)
+++ lnt/trunk/schemas/compile.yaml Mon Jul 10 11:10:32 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=307562&r1=307561&r2=307562&view=diff
==============================================================================
--- lnt/trunk/tests/SharedInputs/create_temp_instance.py (original)
+++ lnt/trunk/tests/SharedInputs/create_temp_instance.py Mon Jul 10 11:10:32 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=307562&r1=307561&r2=307562&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/CreateV4TestSuite.py (original)
+++ lnt/trunk/tests/server/db/CreateV4TestSuite.py Mon Jul 10 11:10:32 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