Mock out CLI execution in NEC driver tests

The VolumeStats_test was not mocking the CLI code that retieves
backend stats, resulting in an ssh_known_hosts file being created
in the local directory. This mocks out the calls to avoid this.

Change-Id: I60898272e0da165fe3168e51d8595250682179c0
Closes-bug: #1732992
This commit is contained in:
Sean McGinnis 2017-11-28 15:58:15 -06:00
parent 94dba4647d
commit 4e0b199d17
1 changed files with 3 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import mock
from cinder import exception
from cinder import test
from cinder.volume import configuration as conf
from cinder.volume.drivers.nec import volume_common
from cinder.volume.drivers.nec import volume_helper
@ -1095,8 +1096,6 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver,
class VolumeStats_test(volume_helper.MStorageDSVDriver, test.TestCase):
@mock.patch('cinder.volume.drivers.nec.volume_common.MStorageVolumeCommon.'
'_create_ismview_dir', new=mock.Mock())
def setUp(self):
super(VolumeStats_test, self).setUp()
self._set_config(conf.Configuration(None), 'dummy', 'dummy')
@ -1106,6 +1105,8 @@ class VolumeStats_test(volume_helper.MStorageDSVDriver, test.TestCase):
self._properties['pool_backup_pools'] = {2, 3}
def test_update_volume_status(self):
self.mock_object(volume_common.MStorageVolumeCommon, 'parse_xml',
side_effect=Exception)
stats = self._update_volume_status()
self.assertEqual('dummy', stats.get('volume_backend_name'))
self.assertEqual('NEC', stats.get('vendor_name'))