_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')
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)