Merge "Fix Python 3 issues in Hitachi HNAS tests"
This commit is contained in:
commit
1da350a3f1
@ -285,7 +285,7 @@ class HDSHNASBendTest(test.TestCase):
|
||||
super(HDSHNASBendTest, self).setUp()
|
||||
self.hnas_bend = hnas_backend.HnasBackend(DRV_CONF)
|
||||
|
||||
@mock.patch('__builtin__.open')
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch('os.path.isfile', return_value=True)
|
||||
@mock.patch('paramiko.RSAKey.from_private_key_file')
|
||||
@mock.patch('paramiko.SSHClient')
|
||||
|
@ -270,19 +270,16 @@ class HNASiSCSIDriverTest(test.TestCase):
|
||||
self.backend = SimulatedHnasBackend()
|
||||
_factory_bend.return_value = self.backend
|
||||
|
||||
(handle, self.config_file) = tempfile.mkstemp('.xml')
|
||||
os.write(handle, HNASCONF)
|
||||
os.close(handle)
|
||||
self.config_file = tempfile.NamedTemporaryFile("w+", suffix='.xml')
|
||||
self.addCleanup(self.config_file.close)
|
||||
self.config_file.write(HNASCONF)
|
||||
self.config_file.flush()
|
||||
|
||||
self.configuration = mock.Mock(spec=conf.Configuration)
|
||||
self.configuration.hds_hnas_iscsi_config_file = self.config_file
|
||||
self.configuration.hds_hnas_iscsi_config_file = self.config_file.name
|
||||
self.configuration.hds_svc_iscsi_chap_enabled = True
|
||||
self.driver = iscsi.HDSISCSIDriver(configuration=self.configuration)
|
||||
self.driver.do_setup("")
|
||||
self.addCleanup(self._clean)
|
||||
|
||||
def _clean(self):
|
||||
os.remove(self.config_file)
|
||||
|
||||
def _create_volume(self):
|
||||
loc = self.driver.create_volume(_VOLUME)
|
||||
@ -290,7 +287,7 @@ class HNASiSCSIDriverTest(test.TestCase):
|
||||
vol['provider_location'] = loc['provider_location']
|
||||
return vol
|
||||
|
||||
@mock.patch('__builtin__.open')
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch.object(os, 'access')
|
||||
def test_read_config(self, m_access, m_open):
|
||||
# Test exception when file is not found
|
||||
|
@ -158,16 +158,19 @@ class HDSNFSDriverTest(test.TestCase):
|
||||
self.backend = SimulatedHnasBackend()
|
||||
m_factory_bend.return_value = self.backend
|
||||
|
||||
(handle, self.config_file) = tempfile.mkstemp('.xml')
|
||||
os.write(handle, HNASCONF)
|
||||
os.close(handle)
|
||||
(handle, self.shares_file) = tempfile.mkstemp('')
|
||||
os.write(handle, SHARESCONF)
|
||||
os.close(handle)
|
||||
self.config_file = tempfile.NamedTemporaryFile("w+", suffix='.xml')
|
||||
self.addCleanup(self.config_file.close)
|
||||
self.config_file.write(HNASCONF)
|
||||
self.config_file.flush()
|
||||
|
||||
self.shares_file = tempfile.NamedTemporaryFile("w+", suffix='.xml')
|
||||
self.addCleanup(self.shares_file.close)
|
||||
self.shares_file.write(SHARESCONF)
|
||||
self.shares_file.flush()
|
||||
|
||||
self.configuration = mock.Mock(spec=conf.Configuration)
|
||||
self.configuration.hds_hnas_nfs_config_file = self.config_file
|
||||
self.configuration.nfs_shares_config = self.shares_file
|
||||
self.configuration.hds_hnas_nfs_config_file = self.config_file.name
|
||||
self.configuration.nfs_shares_config = self.shares_file.name
|
||||
self.configuration.nfs_mount_point_base = '/opt/stack/cinder/mnt'
|
||||
self.configuration.nfs_mount_options = None
|
||||
self.configuration.nas_ip = None
|
||||
@ -176,13 +179,8 @@ class HDSNFSDriverTest(test.TestCase):
|
||||
|
||||
self.driver = nfs.HDSNFSDriver(configuration=self.configuration)
|
||||
self.driver.do_setup("")
|
||||
self.addCleanup(self._clean)
|
||||
|
||||
def _clean(self):
|
||||
os.remove(self.config_file)
|
||||
os.remove(self.shares_file)
|
||||
|
||||
@mock.patch('__builtin__.open')
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch.object(os, 'access')
|
||||
def test_read_config(self, m_access, m_open):
|
||||
# Test exception when file is not found
|
||||
|
3
tox.ini
3
tox.ini
@ -64,6 +64,9 @@ commands =
|
||||
cinder.tests.unit.test_hitachi_hbsd_horcm_fc \
|
||||
cinder.tests.unit.test_hitachi_hbsd_snm2_fc \
|
||||
cinder.tests.unit.test_hitachi_hbsd_snm2_iscsi \
|
||||
cinder.tests.unit.test_hitachi_hnas_backend \
|
||||
cinder.tests.unit.test_hitachi_hnas_iscsi \
|
||||
cinder.tests.unit.test_hitachi_hnas_nfs \
|
||||
cinder.tests.unit.test_hp_xp_fc \
|
||||
cinder.tests.unit.test_hplefthand \
|
||||
cinder.tests.unit.test_huawei_drivers \
|
||||
|
Loading…
x
Reference in New Issue
Block a user