summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Griffith <john.griffith@solidfire.com>2012-09-12 17:04:17 -0600
committerJohn Griffith <john.griffith@solidfire.com>2012-09-13 08:43:50 -0600
commitc72935f17272d117930a4c4c76426f26d786e421 (patch)
tree93488eddb1e3396a4a838f8af1fb87387f238f0f
parent114109dbf4094ae6b6333d41c84bebf6f85c4e48 (diff)
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
-rw-r--r--nova/tests/test_iscsi.py15
1 files 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):