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
This commit is contained in:
parent
b6f47da2f5
commit
92feff7367
|
@ -82,6 +82,24 @@ class RemoteFsClientTestCase(base.TestCase):
|
||||||
self.assertEqual(mock_do_mount.call_count, 0)
|
self.assertEqual(mock_do_mount.call_count, 0)
|
||||||
self.assertEqual(mock_execute.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):
|
def _test_no_mount_point(self, fs_type):
|
||||||
self.assertRaises(exception.InvalidParameterValue,
|
self.assertRaises(exception.InvalidParameterValue,
|
||||||
remotefs.RemoteFsClient,
|
remotefs.RemoteFsClient,
|
||||||
|
|
Loading…
Reference in New Issue