summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2011-06-25 17:26:38 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2011-06-25 17:26:38 -0700
commit9978d656d262a95e17a60a2c137664b315f8191a (patch)
tree046187cf89451cc17523776405760d568f8ab630
parent8a8c013cd4513b07e936125a23188e7608f40d58 (diff)
downloadnova-9978d656d262a95e17a60a2c137664b315f8191a.tar.gz
nova-9978d656d262a95e17a60a2c137664b315f8191a.tar.xz
nova-9978d656d262a95e17a60a2c137664b315f8191a.zip
only create the db if it doesn't exist, add an option -r to run_tests.py to delete it
-rw-r--r--nova/tests/__init__.py2
-rw-r--r--run_tests.py7
-rwxr-xr-xrun_tests.sh7
3 files changed, 11 insertions, 5 deletions
diff --git a/nova/tests/__init__.py b/nova/tests/__init__.py
index 7fba02a93..5e0cb718e 100644
--- a/nova/tests/__init__.py
+++ b/nova/tests/__init__.py
@@ -50,7 +50,7 @@ def setup():
testdb = os.path.join(FLAGS.state_path, FLAGS.sqlite_db)
if os.path.exists(testdb):
- os.unlink(testdb)
+ return
migration.db_sync()
ctxt = context.get_admin_context()
network_manager.VlanManager().create_networks(ctxt,
diff --git a/run_tests.py b/run_tests.py
index bb33f9139..fd836967e 100644
--- a/run_tests.py
+++ b/run_tests.py
@@ -69,7 +69,6 @@ from nose import core
from nose import result
from nova import log as logging
-from nova.tests import fake_flags
class _AnsiColorizer(object):
@@ -211,11 +210,11 @@ class NovaTestResult(result.TextTestResult):
break
sys.stdout = stdout
- # NOTE(lorinh): Initialize start_time in case a sqlalchemy-migrate
- # error results in it failing to be initialized later. Otherwise,
+ # NOTE(lorinh): Initialize start_time in case a sqlalchemy-migrate
+ # error results in it failing to be initialized later. Otherwise,
# _handleElapsedTime will fail, causing the wrong error message to
# be outputted.
- self.start_time = time.time()
+ self.start_time = time.time()
def getDescription(self, test):
return str(test)
diff --git a/run_tests.sh b/run_tests.sh
index c3f06f837..2ea221ae3 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -6,6 +6,7 @@ function usage {
echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
+ echo " -r, --recreate-db Recreate the test database."
echo " -x, --stop Stop running tests after the first error or failure."
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " -p, --pep8 Just run pep8"
@@ -23,6 +24,7 @@ function process_option {
-h|--help) usage;;
-V|--virtual-env) let always_venv=1; let never_venv=0;;
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
+ -r|--recreate-db) let recreate_db=1;;
-f|--force) let force=1;;
-p|--pep8) let just_pep8=1;;
-*) noseopts="$noseopts $1";;
@@ -39,6 +41,7 @@ noseargs=
noseopts=
wrapper=""
just_pep8=0
+recreate_db=0
for arg in "$@"; do
process_option $arg
@@ -108,6 +111,10 @@ if [ $just_pep8 -eq 1 ]; then
exit
fi
+if [ $recreate_db -eq 1 ]; then
+ rm tests.sqlite
+fi
+
run_tests || exit
# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,