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: I9b9a2400a172d52987d76f3132793cb042fd201c
  • Loading branch information
j-griffith committed Sep 12, 2012
1 parent 81061b1 commit 96f72f2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cinder/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 cinder import test
from cinder.volume import iscsi
Expand Down Expand Up @@ -89,12 +91,20 @@ 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


class IetAdmTestCase(test.TestCase, TargetAdminTestCase):

Expand Down

0 comments on commit 96f72f2

Please sign in to comment.