]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/tests/__init__.py
import ceph quincy 17.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / tests / __init__.py
index 2859e89a2599815cdf0a888711a0bc5714a5cee9..d262d27d7fc58f951aceeca621ee44afe2b7ee32 100644 (file)
@@ -14,7 +14,7 @@ import cherrypy
 from cherrypy._cptools import HandlerWrapperTool
 from cherrypy.test import helper
 from mgr_module import HandleCommandResult
-from orchestrator import HostSpec, InventoryHost
+from orchestrator import DaemonDescription, HostSpec, InventoryHost
 from pyfakefs import fake_filesystem
 
 from .. import mgr
@@ -290,7 +290,8 @@ class RgwStub(Stub):
                     'id': 'daemon1',
                     'realm_name': 'realm1',
                     'zonegroup_name': 'zonegroup1',
-                    'zone_name': 'zone1'
+                    'zone_name': 'zone1',
+                    'hostname': 'daemon1.server.lan'
                 }
             },
             '5398': {
@@ -300,7 +301,8 @@ class RgwStub(Stub):
                     'id': 'daemon2',
                     'realm_name': 'realm2',
                     'zonegroup_name': 'zonegroup2',
-                    'zone_name': 'zone2'
+                    'zone_name': 'zone2',
+                    'hostname': 'daemon2.server.lan'
                 }
             }
         }}}})
@@ -345,12 +347,22 @@ class Waiter(threading.Thread):
 @contextlib.contextmanager
 def patch_orch(available: bool, missing_features: Optional[List[str]] = None,
                hosts: Optional[List[HostSpec]] = None,
-               inventory: Optional[List[dict]] = None):
+               inventory: Optional[List[dict]] = None,
+               daemons: Optional[List[DaemonDescription]] = None):
     with mock.patch('dashboard.controllers.orchestrator.OrchClient.instance') as instance:
         fake_client = mock.Mock()
         fake_client.available.return_value = available
         fake_client.get_missing_features.return_value = missing_features
 
+        if not daemons:
+            daemons = [
+                DaemonDescription(
+                    daemon_type='mon',
+                    daemon_id='a',
+                    hostname='node0'
+                )
+            ]
+        fake_client.services.list_daemons.return_value = daemons
         if hosts is not None:
             fake_client.hosts.list.return_value = hosts