]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add a test on 'ceph orch ls'
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 29 Sep 2021 06:42:33 +0000 (08:42 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 2 Nov 2021 09:01:22 +0000 (10:01 +0100)
This adds a unittest in order to cover the output of 'orch ls' command
and check the reporting about the running osd number is displayed as
expected.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Co-Authored-by: Sebastian Wagner <sewagner@redhat.com>
(cherry picked from commit 1d848dc447fd4df18893903a053d58129fb8c13a)

src/pybind/mgr/orchestrator/tests/test_orchestrator.py

index 7ccd06146661a3e92f3122a0705931725c023b3c..5b421d09c53e23164d1e987e5c7f089573665691 100644 (file)
@@ -12,9 +12,10 @@ from mgr_module import HandleCommandResult
 
 from test_orchestrator import TestOrchestrator as _TestOrchestrator
 
-from orchestrator import InventoryHost, DaemonDescription, ServiceDescription, DaemonDescriptionStatus
+from orchestrator import InventoryHost, DaemonDescription, ServiceDescription, DaemonDescriptionStatus, OrchResult
 from orchestrator import OrchestratorValidationError
 from orchestrator.module import to_format, Format, OrchestratorCli, preview_table_osd
+from unittest import mock
 
 
 def _test_resource(data, resource_class, extra=None):
@@ -142,6 +143,21 @@ def test_handle_command():
         retval=-2, stdout='', stderr='No orchestrator configured (try `ceph orch set backend`)')
 
 
+r = OrchResult([ServiceDescription(spec=ServiceSpec(service_type='osd'), running=123)])
+
+
+@mock.patch("orchestrator.OrchestratorCli.describe_service", return_value=r)
+def test_orch_ls(_describe_service):
+    cmd = {
+        'prefix': 'orch ls',
+    }
+    m = OrchestratorCli('orchestrator', 0, 0)
+    r = m._handle_command(None, cmd)
+    out = 'NAME  PORTS  RUNNING  REFRESHED  AGE  PLACEMENT  \n' \
+          'osd              123  -          -               '
+    assert r == HandleCommandResult(retval=0, stdout=out, stderr='')
+
+
 def test_preview_table_osd_smoke():
     data = [
         {