]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Set iet_conf to nonexistent file in unit test
authorJohn Griffith <john.griffith@solidfire.com>
Sat, 20 Dec 2014 00:45:16 +0000 (17:45 -0700)
committerJohn Griffith <john.griffith8@gmail.com>
Sun, 21 Dec 2014 17:55:34 +0000 (10:55 -0700)
The Iet test in test_iscsi isn't setup to deal with
an actual iet.conf file.  The result is that if you happen
to be on a system that has an iet.conf file the test will fail
when it gets to the os.stat check.

This patch just uses a tempdir with a bogus file name that is
set as the iet_conf option to make sure the test never runs into
a situation where the file is actually there.

Change-Id: I5c8653a17250063660ca8aa369c537cc340bc4e9
Closes-Bug: #1400780

cinder/tests/test_iscsi.py

index ac1ed5ea3505d6110e2545eaee5e0f93ec6215ac..ff178128331f95611aa37c03f98f83b866f89c03 100644 (file)
@@ -174,7 +174,12 @@ class IetAdmTestCase(test.TestCase, TargetAdminTestCase):
     def setUp(self):
         super(IetAdmTestCase, self).setUp()
         TargetAdminTestCase.setUp(self)
+
+        self.iet_conffile = str(self.persist_tempdir) + '/bogus-file'
+
         self.flags(iscsi_helper='ietadm')
+        self.flags(iet_conf=self.iet_conffile)
+
         self.script_template = "\n".join([
             'ietadm --op new --tid=%(tid)s --params Name=%(target_name)s',
             'ietadm --op new --tid=%(tid)s --lun=%(lun)s '
@@ -191,8 +196,12 @@ class IetAdmBlockIOTestCase(test.TestCase, TargetAdminTestCase):
     def setUp(self):
         super(IetAdmBlockIOTestCase, self).setUp()
         TargetAdminTestCase.setUp(self)
+
+        self.iet_conffile = str(self.persist_tempdir) + '/bogus-file'
+
         self.flags(iscsi_helper='ietadm')
         self.flags(iscsi_iotype='blockio')
+        self.flags(iet_conf=self.iet_conffile)
         self.script_template = "\n".join([
             'ietadm --op new --tid=%(tid)s --params Name=%(target_name)s',
             'ietadm --op new --tid=%(tid)s --lun=%(lun)s '
@@ -209,6 +218,10 @@ class IetAdmFileIOTestCase(test.TestCase, TargetAdminTestCase):
     def setUp(self):
         super(IetAdmFileIOTestCase, self).setUp()
         TargetAdminTestCase.setUp(self)
+
+        self.iet_conffile = str(self.persist_tempdir) + '/bogus-file'
+
+        self.flags(iet_conf=self.iet_conffile)
         self.flags(iscsi_helper='ietadm')
         self.flags(iscsi_iotype='fileio')
         self.script_template = "\n".join([
@@ -227,9 +240,12 @@ class IetAdmAutoIOTestCase(test.TestCase, TargetAdminTestCase):
     def setUp(self):
         super(IetAdmAutoIOTestCase, self).setUp()
         TargetAdminTestCase.setUp(self)
+        self.iet_conffile = 'this-bogus-conf-file-dne'
         self.stubs.Set(iscsi.IetAdm, '_is_block', lambda a, b: True)
+
         self.flags(iscsi_helper='ietadm')
         self.flags(iscsi_iotype='auto')
+        self.flags(iet_conf=self.iet_conffile)
         self.script_template = "\n".join([
             'ietadm --op new --tid=%(tid)s --params Name=%(target_name)s',
             'ietadm --op new --tid=%(tid)s --lun=%(lun)s '