Fix interprocess locks when running unit-tests
When running unit-tests concurrently using testr, we might need to use interprocess file locks (e.g. for running various tests using the same DB in MySQL/PostgreSQL). At the same time file locks are only usable when they are placed to one dir, and we have a test fixture that overrides the lock_path config value for each test case with a new temporary directory. The solution is to create the one temprorary directory for locks to be used by all tests before running tests and then remove it after running tests. The corresponding helper has been already put to openstack.common.lockutils module, we just need to reuse it properly, i.e. change the way unit tests are run in tox.ini. Closes-Bug: #1261728 Change-Id: I76f95a9f7fdd31c15e6cf4fd6316c7569284f780
This commit is contained in:
parent
7d79f458d6
commit
78d62186e5
@ -31,7 +31,6 @@ import gettext
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
@ -264,8 +263,6 @@ class TestCase(testtools.TestCase):
|
||||
CONF.set_override('fatal_exception_format_errors', True)
|
||||
CONF.set_override('enabled', True, 'osapi_v3')
|
||||
CONF.set_override('force_dhcp_release', False)
|
||||
# This will be cleaned up by the NestedTempfile fixture
|
||||
CONF.set_override('lock_path', tempfile.mkdtemp())
|
||||
|
||||
def _restore_obj_registry(self):
|
||||
objects_base.NovaObject._obj_classes = self._base_test_obj_backup
|
||||
|
@ -53,7 +53,6 @@ class ConfFixture(config_fixture.Config):
|
||||
'nova.tests.utils.dns_manager')
|
||||
self.conf.set_default('instance_dns_manager',
|
||||
'nova.tests.utils.dns_manager')
|
||||
self.conf.set_default('lock_path', None)
|
||||
self.conf.set_default('network_size', 8)
|
||||
self.conf.set_default('num_networks', 2)
|
||||
self.conf.set_default('rpc_backend',
|
||||
|
2
tox.ini
2
tox.ini
@ -14,7 +14,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands =
|
||||
python setup.py test --slowest --testr-args='{posargs}'
|
||||
python -m nova.openstack.common.lockutils python setup.py test --slowest --testr-args='{posargs}'
|
||||
|
||||
[tox:jenkins]
|
||||
sitepackages = True
|
||||
|
Loading…
Reference in New Issue
Block a user