From 1d848dc447fd4df18893903a053d58129fb8c13a Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 29 Sep 2021 08:42:33 +0200 Subject: [PATCH] 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 --- .../orchestrator/tests/test_orchestrator.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py index 35154270449..73a6d9b2889 100644 --- a/src/pybind/mgr/orchestrator/tests/test_orchestrator.py +++ b/src/pybind/mgr/orchestrator/tests/test_orchestrator.py @@ -11,9 +11,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): @@ -140,6 +141,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 = [ { -- 2.47.3