[LNT] r214462 - Add PostgreSQL compatibility
Yi Kong
Yi.Kong at arm.com
Thu Jul 31 17:21:01 PDT 2014
Author: kongyi
Date: Thu Jul 31 19:21:00 2014
New Revision: 214462
URL: http://llvm.org/viewvc/llvm-project?rev=214462&view=rev
Log:
Add PostgreSQL compatibility
Make LNT compatible with PostgreSQL.
PostgreSQL is now recommended for production servers.
Added:
lnt/trunk/tests/lnttool/PostgresDB.py
Modified:
lnt/trunk/docs/intro.rst
lnt/trunk/docs/tools.rst
lnt/trunk/lnt/lnttool/create.py
lnt/trunk/lnt/server/config.py
lnt/trunk/tests/lit.cfg
Modified: lnt/trunk/docs/intro.rst
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docs/intro.rst?rev=214462&r1=214461&r2=214462&view=diff
==============================================================================
--- lnt/trunk/docs/intro.rst (original)
+++ lnt/trunk/docs/intro.rst Thu Jul 31 19:21:00 2014
@@ -34,13 +34,13 @@ If you are only interested in using LNT
If you want to run an LNT server, you will need to perform the following
additional steps:
- 2. Create a new LNT installation:
+ 2. Create a new LNT installation::
lnt create path/to/install-dir
This will create the LNT configuration file, the default database, and a
.wsgi wrapper to create the application. You can execute the generated app
- directly to run with the builtin web server, or use
+ directly to run with the builtin web server, or use::
lnt runserver path/to/install-dir
@@ -62,6 +62,21 @@ additional steps:
If running in a virtualenv you will need to configure that as well; see the
`modwsgi wiki <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_.
+For production servers, you should consider using a full DBMS like PostgreSQL.
+To create an LNT instance with PostgreSQL backend, you need to do this instead:
+
+ 1. Create an LNT database in PostgreSQL, also make sure the user has
+ write permission to the database::
+
+ CREATE DATABASE "lnt.db"
+
+ 2. Then create LNT installation::
+
+ lnt create path/to/install-dir --db-dir postgresql://user@host
+
+ 3. Run server normally::
+
+ lnt runserver path/to/install-dir
Development
-----------
@@ -86,7 +101,6 @@ This requires the 'lit' testing tool be
if you prefer 'unittest' style output (this still requires that 'lit' be
installed).
-
Architecture
------------
Modified: lnt/trunk/docs/tools.rst
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/docs/tools.rst?rev=214462&r1=214461&r2=214462&view=diff
==============================================================================
--- lnt/trunk/docs/tools.rst (original)
+++ lnt/trunk/docs/tools.rst Thu Jul 31 19:21:00 2014
@@ -51,7 +51,8 @@ The following tools are used to interact
to tweak the generated server, but they can all be modified after the fact
in the LNT configuration file.
- The default server will have one database named *default*.
+ The default server will have a sqlite3 database named *default*. You can
+ specify to use PostgreSQL using ``--db-dir postgresql://user@hostname``.
``lnt createdb <path>``
Creates a new LNT sqlite3 database at the specified path.
Modified: lnt/trunk/lnt/lnttool/create.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/create.py?rev=214462&r1=214461&r2=214462&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/create.py (original)
+++ lnt/trunk/lnt/lnttool/create.py Thu Jul 31 19:21:00 2014
@@ -151,18 +151,23 @@ def action_create(name, args):
hosturl = "http://%s/%s" % (hostname, hostsuffix)
python_executable = sys.executable
- db_dir_path = os.path.join(basepath, db_dir)
cfg_path = os.path.join(basepath, config)
- db_path = os.path.join(db_dir_path, default_db)
tmp_path = os.path.join(basepath, tmp_dir)
wsgi_path = os.path.join(basepath, wsgi)
secret_key = (opts.secret_key or
hashlib.sha1(str(random.getrandbits(256))).hexdigest())
os.mkdir(path)
- os.mkdir(db_dir_path)
os.mkdir(tmp_path)
+ # If the path does not contain database type, assume relative path.
+ if "://" not in db_dir:
+ db_dir_path = os.path.join(basepath, db_dir)
+ db_path = os.path.join(db_dir_path, default_db)
+ os.mkdir(db_dir_path)
+ else:
+ db_path = os.path.join(db_dir, default_db)
+
cfg_version = kConfigVersion
cfg_file = open(cfg_path, 'w')
cfg_file.write(kConfigTemplate % locals())
Modified: lnt/trunk/lnt/server/config.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/config.py?rev=214462&r1=214461&r2=214462&view=diff
==============================================================================
--- lnt/trunk/lnt/server/config.py (original)
+++ lnt/trunk/lnt/server/config.py Thu Jul 31 19:21:00 2014
@@ -90,7 +90,9 @@ class Config:
default_email_config = EmailConfig(False, '', '', [])
dbDir = data.get('db_dir', '.')
- dbDirPath = os.path.join(baseDir, dbDir)
+
+ # If the path does not contain database type, assume relative path.
+ dbDirPath = dbDir if "://" in dbDir else os.path.join(baseDir, dbDir)
# FIXME: Remove this default.
tempDir = data.get('tmp_dir', 'viewer/resources/graphs')
Modified: lnt/trunk/tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lit.cfg?rev=214462&r1=214461&r2=214462&view=diff
==============================================================================
--- lnt/trunk/tests/lit.cfg (original)
+++ lnt/trunk/tests/lit.cfg Thu Jul 31 19:21:00 2014
@@ -38,6 +38,9 @@ config.substitutions.append(('%{shared_i
if lit_config.params.get('long', None):
config.available_features.add('long')
+if lit_config.params.get('postgres', None):
+ config.available_features.add('postgres')
+
# Enable coverage.py reporting, assuming the coverage module has been installed
# and sitecustomize.py in the virtualenv has been modified appropriately.
if lit_config.params.get('check-coverage', None):
Added: lnt/trunk/tests/lnttool/PostgresDB.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/PostgresDB.py?rev=214462&view=auto
==============================================================================
--- lnt/trunk/tests/lnttool/PostgresDB.py (added)
+++ lnt/trunk/tests/lnttool/PostgresDB.py Thu Jul 31 19:21:00 2014
@@ -0,0 +1,42 @@
+# RUN: rm -rf %t.install
+# RUN: dropdb --if-exists testdb
+# RUN: createdb testdb
+
+# RUN: lnt create %t.install --db-dir postgresql://localhost/ --default-db testdb
+
+# Import a test set.
+# RUN: lnt import %t.install %{shared_inputs}/sample-a-small.plist \
+# RUN: --commit=1 --show-sample-count
+
+# Import a test set.
+# RUN: lnt import %t.install %{shared_inputs}/sample-a-small.plist \
+# RUN: --commit=1 --show-sample-count
+
+# Check that we remove both the sample and the run, and that we don't commit by
+# default.
+#
+# RUN: lnt updatedb %t.install --testsuite nts \
+# RUN: --delete-run 1 --show-sql > %t.out
+# RUN: FileCheck --check-prefix CHECK-RUNRM %s < %t.out
+
+# CHECK-RUNRM: DELETE FROM "NT_Sample" WHERE "NT_Sample"."RunID" IN (%(RunID_1)s)
+# CHECK-RUNRM-NEXT: {'RunID_1': 1}
+# CHECK-RUNRM: DELETE FROM "NT_Run" WHERE "NT_Run"."ID" IN (%(ID_1)s)
+# CHECK-RUNRM-NEXT: {'ID_1': 1}
+# CHECK-RUNRM: ROLLBACK
+
+# Check that we remove runs when we remove a machine.
+#
+# RUN: lnt updatedb %t.install --testsuite nts \
+# RUN: --delete-machine "LNT SAMPLE MACHINE" --commit=1 --show-sql > %t.out
+# RUN: FileCheck --check-prefix CHECK-MACHINERM %s < %t.out
+
+# CHECK-MACHINERM: DELETE FROM "NT_Sample" WHERE "NT_Sample"."RunID" IN (%(RunID_1)s)
+# CHECK-MACHINERM-NEXT: {'RunID_1': 1}
+# CHECK-MACHINERM: DELETE FROM "NT_Run" WHERE "NT_Run"."ID" IN (%(ID_1)s)
+# CHECK-MACHINERM-NEXT: {'ID_1': 1}
+# CHECK-MACHINERM: DELETE FROM "NT_Machine" WHERE "NT_Machine"."Name" = %(Name_1)s
+# CHECK-MACHINERM-NEXT: {'Name_1': 'LNT SAMPLE MACHINE'}
+# CHECK-MACHINERM: COMMIT
+
+# REQUIRES: postgres
More information about the llvm-commits
mailing list