From 78d62186e5b0388f740d42cb8da5798cd67d7880 Mon Sep 17 00:00:00 2001 From: Roman Podoliaka Date: Tue, 17 Dec 2013 13:52:45 +0200 Subject: [PATCH] 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 --- nova/test.py | 3 --- nova/tests/conf_fixture.py | 1 - tox.ini | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/nova/test.py b/nova/test.py index 8c89c783fbfb..a613ee914a97 100644 --- a/nova/test.py +++ b/nova/test.py @@ -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 diff --git a/nova/tests/conf_fixture.py b/nova/tests/conf_fixture.py index 3c3170c31f08..e29087f18f7e 100644 --- a/nova/tests/conf_fixture.py +++ b/nova/tests/conf_fixture.py @@ -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', diff --git a/tox.ini b/tox.ini index 53e10c8e4436..8f5970705e3e 100644 --- a/tox.ini +++ b/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