diff options
| author | Yuriy Taraday <yorik.sar@gmail.com> | 2011-07-05 18:08:41 +0400 |
|---|---|---|
| committer | Yuriy Taraday <yorik.sar@gmail.com> | 2011-07-05 18:08:41 +0400 |
| commit | 0dd9400aa339eeeef85d30828b7960ea5de77954 (patch) | |
| tree | 348d76321257e18531edb7da6bde669166d80818 | |
| parent | c48bd132e8a2a4fa9ca8ddec2599af0b63ead102 (diff) | |
Various fixes for test running.
Made sampledata.sh fail if one step fails.
Made run_tests.py use all files related to its dir.
Add check whether data is loaded and server is started.
| -rwxr-xr-x | bin/sampledata.sh | 2 | ||||
| -rw-r--r-- | keystone/test/run_tests.py | 52 |
2 files changed, 32 insertions, 22 deletions
diff --git a/bin/sampledata.sh b/bin/sampledata.sh index bec2d0c5..689e8077 100755 --- a/bin/sampledata.sh +++ b/bin/sampledata.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2010 United States Government as represented by the diff --git a/keystone/test/run_tests.py b/keystone/test/run_tests.py index b1292fc4..190f632d 100644 --- a/keystone/test/run_tests.py +++ b/keystone/test/run_tests.py @@ -1,26 +1,36 @@ +import os import subprocess import time if __name__ == '__main__': - #remove pre-existing test databases - subprocess.call(['rm', 'keystone.db']) - subprocess.call(['rm', 'keystone.token.db']) + test_dir = os.path.dirname(__file__) - # populate the test database - subprocess.call(['../../bin/sampledata.sh']) - - # run the keystone server - server = subprocess.Popen(['../../bin/keystone']) - - # blatent hack. - time.sleep(3) - - # run tests - subprocess.call(['python', 'unit/test_keystone.py']) - - #kill the keystone server - server.kill() - - # remove test databases - subprocess.call(['rm', 'keystone.db']) - subprocess.call(['rm', 'keystone.token.db']) + #remove pre-existing test databases + subprocess.call(['rm', os.path.join(test_dir, 'keystone.db')]) + subprocess.call(['rm', os.path.join(test_dir, 'keystone.token.db')]) + + # populate the test database + subprocess.check_call([os.path.join(test_dir, '../../bin/sampledata.sh')]) + + try: + # run the keystone server + server = subprocess.Popen([os.path.join(test_dir, + '../../bin/keystone')]) + + # blatent hack. + time.sleep(3) + if server.poll() is not None: + print >>sys.stderr, 'Failed to start server' + sys.exit(-1) + + try: + # run tests + subprocess.check_call(['python', + os.path.join(test_dir, 'unit/test_keystone.py')]) + finally: + #kill the keystone server + server.kill() + finally: + # remove test databases + subprocess.call(['rm', os.path.join(test_dir, 'keystone.db')]) + subprocess.call(['rm', os.path.join(test_dir, 'keystone.token.db')]) |
