Merge "Scality SOFS: don't always read /proc/mounts twice"

This commit is contained in:
Jenkins 2016-01-06 16:24:21 +00:00 committed by Gerrit Code Review
commit 6001f50cd7
2 changed files with 20 additions and 4 deletions

View File

@ -149,6 +149,21 @@ class ScalityDriverTestCase(test.TestCase):
_FAKE_MNT_POINT)
self.assertEqual(expected_args, mock_execute.call_args[0])
@mock.patch("cinder.volume.utils.read_proc_mounts")
@mock.patch("oslo_concurrency.processutils.execute")
@mock.patch("oslo_utils.fileutils.ensure_tree", mock.Mock())
@mock.patch("os.symlink", mock.Mock())
def test_ensure_shares_mounted_when_sofs_mounted(self, mock_execute,
mock_read_proc_mounts):
mock_read_proc_mounts.return_value = _FAKE_MOUNTS_TABLE[1]
self.drv._ensure_shares_mounted()
# Because SOFS is mounted from the beginning, we shouldn't read
# /proc/mounts more than once.
mock_read_proc_mounts.assert_called_once_with()
self.assertFalse(mock_execute.called)
def test_find_share_when_no_shares_mounted(self):
self.assertRaises(exception.RemoteFSNoSharesMounted,
self.drv._find_share, 'ignored')

View File

@ -135,10 +135,11 @@ class ScalityDriver(remotefs_drv.RemoteFSSnapDriver):
if not self._sofs_is_mounted():
self._execute('mount', '-t', 'sofs', self.sofs_config,
self.sofs_mount_point, run_as_root=True)
if not self._sofs_is_mounted():
msg = _("Cannot mount Scality SOFS, check syslog for errors")
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
# Check whether the mount command succeeded
if not self._sofs_is_mounted():
msg = _("Cannot mount Scality SOFS, check syslog for errors")
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
fileutils.ensure_tree(self.sofs_abs_volume_dir)