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.
This commit is contained in:
Yuriy Taraday 2011-07-05 18:08:41 +04:00
parent c48bd132e8
commit 0dd9400aa3
2 changed files with 32 additions and 22 deletions

View File

@ -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

View File

@ -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'])
#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')])
# run the keystone server
server = subprocess.Popen(['../../bin/keystone'])
# populate the test database
subprocess.check_call([os.path.join(test_dir, '../../bin/sampledata.sh')])
# blatent hack.
time.sleep(3)
try:
# run the keystone server
server = subprocess.Popen([os.path.join(test_dir,
'../../bin/keystone')])
# run tests
subprocess.call(['python', 'unit/test_keystone.py'])
# blatent hack.
time.sleep(3)
if server.poll() is not None:
print >>sys.stderr, 'Failed to start server'
sys.exit(-1)
#kill the keystone server
server.kill()
# remove test databases
subprocess.call(['rm', 'keystone.db'])
subprocess.call(['rm', 'keystone.token.db'])
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')])