lockutils-wrapper cleanup
There were a couple of issues with the lockutils wrapper. Most importantly, lockutils silently did nothing if it was called in the same way as the old incubator lockutils module. This had the potential to cause problems when simply doing a find and replace to migrate to oslo.concurrency. The problem is fixed by making lockutils raise an exception if it is called directly. There was also a name mismatch in the docstring for the console entry point, which is also fixed in this change. Closes-Bug: 1386734 Change-Id: I8868820ca314eb8d6fee83cc66fea886c1e74e27
This commit is contained in:
parent
78ba143879
commit
d5ea62c53a
@ -358,10 +358,10 @@ def _lock_wrapper(argv):
|
||||
"""Create a dir for locks and pass it to command from arguments
|
||||
|
||||
This is exposed as a console script entry point named
|
||||
oslo-concurrency-lock-wrapper
|
||||
lockutils-wrapper
|
||||
|
||||
If you run this:
|
||||
oslo-concurrency-lock-wrapper python setup.py testr <etc>
|
||||
lockutils-wrapper python setup.py testr <etc>
|
||||
|
||||
a temporary directory will be created for all your locks and passed to all
|
||||
your tests in an environment variable. The temporary dir will be deleted
|
||||
@ -379,3 +379,9 @@ def _lock_wrapper(argv):
|
||||
|
||||
def main():
|
||||
sys.exit(_lock_wrapper(sys.argv))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise NotImplementedError(_('Calling lockutils directly is no longer '
|
||||
'supported. Please use the '
|
||||
'lockutils-wrapper console script instead.'))
|
||||
|
@ -18,6 +18,7 @@ import multiprocessing
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
@ -520,6 +521,13 @@ class LockutilsModuleTestCase(test_base.BaseTestCase):
|
||||
retval = lockutils._lock_wrapper(argv)
|
||||
self.assertEqual(retval, 1)
|
||||
|
||||
def test_direct_call_explodes(self):
|
||||
cmd = [sys.executable, '-m', 'oslo.concurrency.lockutils']
|
||||
with open(os.devnull, 'w') as devnull:
|
||||
retval = subprocess.call(cmd, stderr=devnull)
|
||||
# 1 for Python 2.7 and 3.x, 255 for 2.6
|
||||
self.assertIn(retval, [1, 255])
|
||||
|
||||
|
||||
class TestLockFixture(test_base.BaseTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user