From: Guillaume Abrioux Date: Wed, 29 Sep 2021 06:42:33 +0000 (+0200) Subject: cephadm: add a test on 'ceph orch ls' X-Git-Tag: v16.2.7~67^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1271bade3ee48e03dd3b404871f7d1c73512656f;p=ceph.git cephadm: add a test on 'ceph orch ls' 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 Co-Authored-by: Sebastian Wagner (cherry picked from commit 1d848dc447fd4df18893903a053d58129fb8c13a) --- diff --git a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py index 7ccd06146661a..5b421d09c53e2 100644 --- a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py +++ b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py @@ -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 = [ {