status = {'available': True, 'message': None}
try:
mgr.remote('nfs', 'cluster_ls')
- except ImportError as error:
+ except (ImportError, RuntimeError) as error:
logger.exception(error)
status['available'] = False
status['message'] = str(error) # type: ignore
from .. import mgr
from ..controllers._version import APIVersion
-from ..controllers.nfs import NFSGaneshaExports, NFSGaneshaUi
+from ..controllers.nfs import NFSGanesha, NFSGaneshaExports, NFSGaneshaUi
from ..tests import ControllerTestCase
from ..tools import NotificationQueue, TaskManager
cephfs_class.return_value.ls_dir.assert_called_once_with('/foo', 3)
self.assertStatus(200)
self.assertJsonBody({'paths': []})
+
+
+class NFSGaneshaControllerTest(ControllerTestCase):
+ @classmethod
+ def setup_server(cls):
+ cls.setup_controllers([NFSGanesha])
+
+ def test_status_available(self):
+ self._get('/api/nfs-ganesha/status')
+ self.assertStatus(200)
+ self.assertJsonBody({'available': True, 'message': None})
+
+ def test_status_not_available(self):
+ mgr.remote = Mock(side_effect=RuntimeError('Test'))
+ self._get('/api/nfs-ganesha/status')
+ self.assertStatus(200)
+ self.assertJsonBody({'available': False, 'message': 'Test'})