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 # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the # Copyright 2010 United States Government as represented by the

View File

@ -1,26 +1,36 @@
import os
import subprocess import subprocess
import time import time
if __name__ == '__main__': if __name__ == '__main__':
test_dir = os.path.dirname(__file__)
#remove pre-existing test databases #remove pre-existing test databases
subprocess.call(['rm', 'keystone.db']) subprocess.call(['rm', os.path.join(test_dir, 'keystone.db')])
subprocess.call(['rm', 'keystone.token.db']) subprocess.call(['rm', os.path.join(test_dir, 'keystone.token.db')])
# populate the test database # populate the test database
subprocess.call(['../../bin/sampledata.sh']) subprocess.check_call([os.path.join(test_dir, '../../bin/sampledata.sh')])
try:
# run the keystone server # run the keystone server
server = subprocess.Popen(['../../bin/keystone']) server = subprocess.Popen([os.path.join(test_dir,
'../../bin/keystone')])
# blatent hack. # blatent hack.
time.sleep(3) time.sleep(3)
if server.poll() is not None:
print >>sys.stderr, 'Failed to start server'
sys.exit(-1)
try:
# run tests # run tests
subprocess.call(['python', 'unit/test_keystone.py']) subprocess.check_call(['python',
os.path.join(test_dir, 'unit/test_keystone.py')])
finally:
#kill the keystone server #kill the keystone server
server.kill() server.kill()
finally:
# remove test databases # remove test databases
subprocess.call(['rm', 'keystone.db']) subprocess.call(['rm', os.path.join(test_dir, 'keystone.db')])
subprocess.call(['rm', 'keystone.token.db']) subprocess.call(['rm', os.path.join(test_dir, 'keystone.token.db')])