Skip to content

Commit

Permalink
Use tmpdir and avoid leaving test files behind
Browse files Browse the repository at this point in the history
 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
  • Loading branch information
j-griffith committed Sep 13, 2012
1 parent 114109d commit c72935f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions nova/tests/test_iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):

Expand Down

0 comments on commit c72935f

Please sign in to comment.