From c72935f17272d117930a4c4c76426f26d786e421 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Wed, 12 Sep 2012 17:04:17 -0600 Subject: Use tmpdir and avoid leaving test files behind We were just creating a file for testing iscsi persist files and weren't cleaning up after the test. Change this to use a tmpdir and make sure we leave no tracks. Fixes bug #1050086 Change-Id: I714177d7789da8b628ab63c163a2c3f1698dd940 --- nova/tests/test_iscsi.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_iscsi.py b/nova/tests/test_iscsi.py index 9fcd219cc..d1a666ab8 100644 --- a/nova/tests/test_iscsi.py +++ b/nova/tests/test_iscsi.py @@ -15,7 +15,9 @@ # under the License. import os.path +import shutil import string +import tempfile from nova import test from nova.volume import iscsi @@ -89,12 +91,21 @@ class TgtAdmTestCase(test.TestCase, TargetAdminTestCase): def setUp(self): super(TgtAdmTestCase, self).setUp() TargetAdminTestCase.setUp(self) + self.persist_tempdir = tempfile.mkdtemp() self.flags(iscsi_helper='tgtadm') - self.flags(volumes_dir="./") + self.flags(volumes_dir=self.persist_tempdir) self.script_template = "\n".join([ - 'tgt-admin --conf ./blaa --update iqn.2011-09.org.foo.bar:blaa', + 'tgt-admin --conf %s/blaa --update iqn.2011-09.org.foo.bar:blaa' + % self.persist_tempdir, 'tgt-admin --delete iqn.2010-10.org.openstack:volume-blaa']) + def tearDown(self): + try: + shutil.rmtree(self.persist_tempdir) + except OSError: + pass + super(TgtAdmTestCase, self).tearDown() + class IetAdmTestCase(test.TestCase, TargetAdminTestCase): -- cgit