diff options
| author | melanie witt <melwittt@gmail.com> | 2022-01-12 04:09:29 +0000 |
|---|---|---|
| committer | melanie witt <melwittt@gmail.com> | 2022-01-12 04:15:26 +0000 |
| commit | 887c445a7a6a17b92a37b6ed1dcdcc7dd009f65d (patch) | |
| tree | 19cb2a4a64e97219ef94ee00998679345275dee7 /nova/tests/unit/test_hacking.py | |
| parent | f2b364df641ba0489ebabbedaf587159c13506ed (diff) | |
| download | nova-887c445a7a6a17b92a37b6ed1dcdcc7dd009f65d.tar.gz | |
Add wrapper for oslo.concurrency lockutils.ReaderWriterLock()
This is a follow up change to I168fffac8002f274a905cfd53ac4f6c9abe18803
which added a hackaround to enable our tests to pass with
fasteners>=0.15 which was upgraded recently as part of a
openstack/requirements update.
The ReaderWriterLock from fasteners (and thus lockutils) cannot work
correctly with eventlet patched code, so this adds a wrapper containing
the aforementioned hackaround along with a hacking check to do our best
to ensure that future use of ReaderWriterLock will be through the
wrapper.
Change-Id: Ia7bcb40a21a804c7bc6b74f501d95ce2a88b09b5
Diffstat (limited to 'nova/tests/unit/test_hacking.py')
| -rw-r--r-- | nova/tests/unit/test_hacking.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py index 1ed47e389f..03b7692217 100644 --- a/nova/tests/unit/test_hacking.py +++ b/nova/tests/unit/test_hacking.py @@ -1000,3 +1000,23 @@ class HackingTestCase(test.NoDBTestCase): self._assert_has_no_errors( code, checks.do_not_use_mock_class_as_new_mock_value, filename="nova/tests/unit/test_context.py") + + def test_check_lockutils_rwlocks(self): + code = """ + lockutils.ReaderWriterLock() + lockutils.ReaderWriterLock(condition_cls=MyClass) + oslo_concurrency.lockutils.ReaderWriterLock() + fasteners.ReaderWriterLock() + fasteners.ReaderWriterLock(condition_cls=MyClass) + """ + errors = [(x + 1, 0, 'N369') for x in range(5)] + self._assert_has_errors( + code, checks.check_lockutils_rwlocks, expected_errors=errors) + + code = """ + nova.utils.ReaderWriterLock() + utils.ReaderWriterLock() + utils.ReaderWriterLock(condition_cls=MyClass) + nova_utils.ReaderWriterLock() + """ + self._assert_has_no_errors(code, checks.check_lockutils_rwlocks) |
