Test Database

Adapted from an email that Nate wrote

The database files are on tonic in /scratch.1/vdt/test-db. The postgres binaries are in /s/postgresql/bin.

Using the database from the command line

  1. From a CSL machine and your own account, start a PostgreSQL client
    $ /s/postgresql/bin/psql -h tonic -U localtests vdt-tests
  2. Enter the password
    Password: testme

Quick PostgreSQL & schema primer

From the prompt you can run "\d" to get a list of tables. "\d TableName" shows the details on that table. There are a whole bunch of other backslash commands (\q quits, for example) and \? has the complete list. So anyway, if you connect to the database and look at the tables you'll see there's not much there:

vdt-tests=# \d
            List of relations
 Schema |    Name     |   Type   | Owner  
--------+-------------+----------+--------
 public | results     | table    | condor
 public | runs        | table    | condor
 public | runs_id_seq | sequence | condor
(3 rows)

I'm sure you could figure this all out, but the runs table contains information on the run itself -- when it happened, what version, package and os were tested. The results table contains a record for each test.

The database server runs as condor on tonic. If tonic gets rebooted you will need to restart it by running /scratch.1/vdt/test-db/start.sh. Besides that, the only maintenance I've done in the last year or so is cleaning out old runs so my disk didn't fill up. Since tonic has about two orders of magnitude more space then vail that shouldn't be a problem, but in case it is you can clear things out with a query like:

delete from runs where version = '1.3.7';

This will delete all records in the runs table for that version, as well as anything in the results table for those runs (this is done with foreign keys and an on delete action, see "man create table" if you're really interested).

In case something really bad happens and the database gets destroyed it's quite easy to rebuild. As condor on tonic, run "initdb -D /scratch.1/vdt/test- db" to create the initial database files. Make a new start script that just has the command "/s/postgresql-/bin/postmaster -i -S -D /scratch.1/vdt/test-db". Launch up psql and run "\c nightly-tests.what/tests.defs" to initialize the tables and the localtests user.

That should be it, but in case I forgot anything the postgres manuals at www.postgresql.org are very good. There's also a nice little O'Reilly book that's up on safari.oreilly.com.

Tim's Additional Notes

Starting the Server

  1. Log in to tonic as condor
  2. Change to /scratch.1/vdt/test-db
  3. Is PostgreSQL running?
    ps xuc | grep post
    PostgreSQL is running if you see lines like this:
    condor    8721  0.0  0.0 20512 1852 ?        Ss   09:07   0:00 postmaster
    condor    8723  0.0  0.0 11312  888 ?        S    09:07   0:00 postmaster
    condor    8724  0.0  0.0 10320 1032 ?        S    09:07   0:00 postmaster
  4. If PostgreSQL is NOT running, delete any existing postmaster.pid file
  5. Start the database
    ./start.sh
  6. Check if server is running with something like ps -ef | grep post
  7. If needed (and no one else has done so), run the script to generate the nightly test summary:
    /p/vdt/workspace/bin/send-mail.sh