]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use tempdir for lock_path in tests.
authorjohn-griffith <john.griffith@solidfire.com>
Mon, 7 Jan 2013 17:08:16 +0000 (10:08 -0700)
committerjohn-griffith <john.griffith@solidfire.com>
Mon, 7 Jan 2013 17:12:41 +0000 (10:12 -0700)
Commit: 2331d3336a6adf4fc13a3b187e91a5d1b1f7c723
introduced use of lockutils but wasn't setting a lock_path, in the tests.
As a result we were polluting cinder/openstack/ with cinder-xxxx lockfiles.

This patch adds a tempfile and cleanup to the test so we don't leave any
junk behind.

Change-Id: Idd9fee928ff0fcf3f8d1c30ee88c5306b88e290c

cinder/tests/api/contrib/test_admin_actions.py

index bdfeb08731b4fa1926439db1bca721cebf9e6673..8a03466a987368a4682d06c36d4331d52dafdd70 100644 (file)
@@ -1,3 +1,5 @@
+import shutil
+import tempfile
 import webob
 
 from cinder import context
@@ -21,10 +23,15 @@ def app():
 class AdminActionsTest(test.TestCase):
 
     def setUp(self):
+        self.tempdir = tempfile.mkdtemp()
         super(AdminActionsTest, self).setUp()
         self.flags(rpc_backend='cinder.openstack.common.rpc.impl_fake')
+        self.flags(lock_path=self.tempdir)
         self.volume_api = volume_api.API()
 
+    def tearDown(self):
+        shutil.rmtree(self.tempdir)
+
     def test_reset_status_as_admin(self):
         # admin context
         ctx = context.RequestContext('admin', 'fake', True)