Browse Source

Tests: Add unit tests for nfs mount race

Add unit tests to cover
2f32c98 RemoteFS: don't fail in do_mount if already mounted

Change-Id: Ieddcc1138d9a069b96d06c4bf0b93bd6b4cd6a45
(cherry picked from commit 92feff7367)
(cherry picked from commit d9327bc0b7)
changes/37/623237/1
Eric Harney 3 years ago
parent
commit
e6b4bf3ae0
  1. 18
      os_brick/tests/remotefs/test_remotefs.py

18
os_brick/tests/remotefs/test_remotefs.py

@ -82,6 +82,24 @@ class RemoteFsClientTestCase(base.TestCase):
self.assertEqual(mock_do_mount.call_count, 0)
self.assertEqual(mock_execute.call_count, 0)
@mock.patch.object(priv_rootwrap, 'execute')
def test_mount_race(self, mock_execute):
err_msg = 'mount.nfs: /var/asdf is already mounted'
mock_execute.side_effect = putils.ProcessExecutionError(stderr=err_msg)
client = remotefs.RemoteFsClient("nfs", root_helper='true',
nfs_mount_point_base='/var/asdf')
client._do_mount('nfs', '192.0.2.20:/share', '/var/asdf')
@mock.patch.object(priv_rootwrap, 'execute')
def test_mount_failure(self, mock_execute):
err_msg = 'mount.nfs: nfs broke'
mock_execute.side_effect = putils.ProcessExecutionError(stderr=err_msg)
client = remotefs.RemoteFsClient("nfs", root_helper='true',
nfs_mount_point_base='/var/asdf')
self.assertRaises(putils.ProcessExecutionError,
client._do_mount,
'nfs', '192.0.2.20:/share', '/var/asdf')
def _test_no_mount_point(self, fs_type):
self.assertRaises(exception.InvalidParameterValue,
remotefs.RemoteFsClient,

Loading…
Cancel
Save