Set a lock_path for tests

oslo.concurrency 6.0.0 has relocated the lock_path that is required
for external locks from [DEFAULT] to the [oslo_concurrency] config
section.  Instead of messing with configuration, we can use the
lockutils.set_defaults() method to set this for tests.  So add this
to the BaseTestCase so that it's available for all tests.

Change-Id: I2878b4162dddaf935002c168bc544eb1eff71efd
This commit is contained in:
Brian Rosmaita 2024-02-29 16:37:17 -05:00
parent 5bf2f4e7a0
commit 9df586a5fe

View File

@ -32,6 +32,7 @@ from unittest import mock
from alembic import command as alembic_command
import fixtures
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_config import fixture as cfg_fixture
from oslo_log.fixture import logging_error as log_fixture
@ -86,6 +87,9 @@ class BaseTestCase(testtools.TestCase):
self.test_dir2 = self.useFixture(fixtures.TempDir()).path
self.conf_dir = os.path.join(self.test_dir, 'etc')
utils.safe_mkdirs(self.conf_dir)
self.lock_dir = os.path.join(self.test_dir, 'locks')
utils.safe_mkdirs(self.lock_dir)
lockutils.set_defaults(self.lock_dir)
self.set_policy()
# Limit the amount of DeprecationWarning messages in the unit test logs