]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add test coverage for action chosen in _check_daemons
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 11 Mar 2026 16:50:54 +0000 (12:50 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 26 Mar 2026 13:31:38 +0000 (09:31 -0400)
Add a test that verifies that the special cases for the jaeger daemon's
choice of action is handled.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/cephadm/tests/conftest.py
src/pybind/mgr/cephadm/tests/services/test_jaeger.py

index 5cc2fabaf49b6ba9e2f8fb689ace1e4d869971b7..72a1b2f6d7811e675efc611acb92499d5c851fc3 100644 (file)
@@ -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
index 1ac4225503022021486b4fbd654e5db95732acbb..f75c5fd24a36bd73c6a47130a296bf3e26647980 100644 (file)
@@ -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")