Fix locking in migration tests

The migration test code included an external lock with a hard-coded
relative path that breaks when run in Jenkins.  It wasn't being hit
in Oslo because it was only locking for the postgres code path,
which isn't currently tested in Oslo.

This change moves the lock so that it applies to all db types and
removes the relative path.  For the locks to work properly it was
also necessary to add the lockutils wrapper to the Oslo tox.ini.

Closes-Bug: 1255608
Change-Id: I333b833022f208e48e3b7e82e8cfad2764be5ea0
This commit is contained in:
Ben Nemec 2013-11-27 17:41:25 +00:00
parent a957fee618
commit 4c47d3e759
2 changed files with 5 additions and 3 deletions

View File

@ -164,7 +164,6 @@ class BaseMigrationTestCase(test.BaseTestCase):
self.assertEqual('', err,
"Failed to run: %s\n%s" % (cmd, output))
@_set_db_lock('pgadmin', 'tests-')
def _reset_pg(self, conn_pieces):
(user, password, database, host) = get_db_connection_info(conn_pieces)
os.environ['PGPASSWORD'] = password
@ -186,6 +185,7 @@ class BaseMigrationTestCase(test.BaseTestCase):
os.unsetenv('PGPASSWORD')
os.unsetenv('PGUSER')
@_set_db_lock(lock_prefix='migration_tests-')
def _reset_databases(self):
for key, engine in self.engines.items():
conn_string = self.test_databases[key]

View File

@ -12,7 +12,8 @@ deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
# due to dependencies between tests (bug 1192207) we use `--concurrency=1` option
python setup.py test --slowest --testr-args='--concurrency=1 {posargs}'
# Use the lockutils wrapper to ensure that external locking works correctly
python -m openstack.common.lockutils python setup.py test --slowest --testr-args='--concurrency=1 {posargs}'
{toxinidir}/tools/config/generate_sample.sh -p openstack
[flake8]
@ -32,7 +33,8 @@ commands = python ./tools/lint.py ./openstack
setenv = VIRTUAL_ENV={envdir}
commands =
# due to dependencies between tests (bug 1192207) we use `--concurrency=1` option
python setup.py test --coverage --testr-args='--concurrency=1 {posargs}'
# Use the lockutils wrapper to ensure that external locking works correctly
python -m openstack.common.lockutils python setup.py test --coverage --testr-args='--concurrency=1 {posargs}'
[testenv:venv]
commands = {posargs}