From: John Mulligan Date: Wed, 11 Mar 2026 16:50:54 +0000 (-0400) Subject: mgr/cephadm: add test coverage for action chosen in _check_daemons X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=22ac40053c52d7a03d67b7e1482532a2e82ec32c;p=ceph.git mgr/cephadm: add test coverage for action chosen in _check_daemons Add a test that verifies that the special cases for the jaeger daemon's choice of action is handled. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/cephadm/tests/conftest.py b/src/pybind/mgr/cephadm/tests/conftest.py index 5cc2fabaf49b..72a1b2f6d781 100644 --- a/src/pybind/mgr/cephadm/tests/conftest.py +++ b/src/pybind/mgr/cephadm/tests/conftest.py @@ -1,8 +1,8 @@ import pytest from cephadm.services.osd import RemoveUtil, OSD -from mock import mock -from .fixtures import with_cephadm_module +from unittest import mock +from .fixtures import with_cephadm_module, async_side_effect from cephadm import CephadmOrchestrator from typing import Generator @@ -26,3 +26,22 @@ def osd_obj(): with mock.patch("cephadm.services.osd.RemoveUtil"): o = OSD(0, mock.MagicMock()) yield o + + +@pytest.fixture() +def mock_cephadm(monkeypatch): + import cephadm.module + import cephadm.serve + + mm = mock.MagicMock() + mm._run_cephadm.side_effect = async_side_effect(('{}', '', 0)) + monkeypatch.setattr( + cephadm.serve.CephadmServe, '_run_cephadm', mm._run_cephadm + ) + monkeypatch.setattr( + cephadm.module.CephadmOrchestrator, + '_daemon_action', + mm._daemon_action, + ) + mm.serve = cephadm.serve.CephadmServe + return mm diff --git a/src/pybind/mgr/cephadm/tests/services/test_jaeger.py b/src/pybind/mgr/cephadm/tests/services/test_jaeger.py index 1ac422550302..f75c5fd24a36 100644 --- a/src/pybind/mgr/cephadm/tests/services/test_jaeger.py +++ b/src/pybind/mgr/cephadm/tests/services/test_jaeger.py @@ -1,5 +1,6 @@ +import contextlib import json -from unittest.mock import patch +from unittest.mock import patch, ANY from cephadm.module import CephadmOrchestrator from ceph.deployment.service_spec import TracingSpec @@ -185,3 +186,18 @@ class TestJaeger: error_ok=True, use_current_daemon_image=False, ) + + +def test_jaeger_agent_choose_next_action(cephadm_module, mock_cephadm): + jaeger_spec = TracingSpec(service_type="jaeger-agent") + coll_spec = TracingSpec(service_type="jaeger-collector") + es_spec = TracingSpec(service_type="elasticsearch") + with contextlib.ExitStack() as stack: + stack.enter_context(with_host(cephadm_module, "test")) + stack.enter_context(with_service(cephadm_module, jaeger_spec)) + stack.enter_context(with_service(cephadm_module, es_spec)) + stack.enter_context(with_service(cephadm_module, coll_spec)) + # manually invoke _check_daemons to trigger a call to + # _daemon_action so we can check what action was chosen + mock_cephadm.serve(cephadm_module)._check_daemons() + mock_cephadm._daemon_action.assert_called_with(ANY, action="redeploy")