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:
parent
c48bd132e8
commit
0dd9400aa3
@ -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
|
||||||
|
@ -1,26 +1,36 @@
|
|||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#remove pre-existing test databases
|
test_dir = os.path.dirname(__file__)
|
||||||
subprocess.call(['rm', 'keystone.db'])
|
|
||||||
subprocess.call(['rm', 'keystone.token.db'])
|
|
||||||
|
|
||||||
# populate the test database
|
#remove pre-existing test databases
|
||||||
subprocess.call(['../../bin/sampledata.sh'])
|
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
|
||||||
# run tests
|
server = subprocess.Popen([os.path.join(test_dir,
|
||||||
subprocess.call(['python', 'unit/test_keystone.py'])
|
'../../bin/keystone')])
|
||||||
|
|
||||||
#kill the keystone server
|
# blatent hack.
|
||||||
server.kill()
|
time.sleep(3)
|
||||||
|
if server.poll() is not None:
|
||||||
# remove test databases
|
print >>sys.stderr, 'Failed to start server'
|
||||||
subprocess.call(['rm', 'keystone.db'])
|
sys.exit(-1)
|
||||||
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')])
|
||||||
|
Loading…
Reference in New Issue
Block a user