From 80bc025da4ee2b90f7ac9add5f5769c7cdd52bb2 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Fri, 19 Dec 2014 17:45:16 -0700 Subject: [PATCH] Set iet_conf to nonexistent file in unit test 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cinder/tests/test_iscsi.py b/cinder/tests/test_iscsi.py index ac1ed5ea3..ff1781283 100644 --- a/cinder/tests/test_iscsi.py +++ b/cinder/tests/test_iscsi.py @@ -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 ' -- 2.45.2