]> 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 18:44:47 +0000 (14:44 -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 nfs daemon's
choice of action is handled.

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

index 087bb40f8696d0beec9fb5d0aa65f889d4761da5..a9092ebd7696f47ca2da8ea6e3b0790865efb6fb 100644 (file)
@@ -1,4 +1,5 @@
-from unittest.mock import MagicMock, patch
+import contextlib
+from unittest.mock import MagicMock, patch, ANY
 
 from cephadm.services.service_registry import service_registry
 from cephadm.services.cephadmservice import CephadmDaemonDeploySpec
@@ -476,3 +477,30 @@ class TestNFS:
                     '}\n'
                 )
                 assert expected_tls_block in ganesha_conf
+
+
+@patch("cephadm.services.nfs.NFSService.run_grace_tool", MagicMock())
+@patch("cephadm.services.nfs.NFSService.purge", MagicMock())
+@patch("cephadm.services.nfs.NFSService.create_rados_config_obj", MagicMock())
+def test_nfs_choose_next_action(cephadm_module, mock_cephadm):
+    nfs_spec = NFSServiceSpec(
+        service_id="foo",
+        placement=PlacementSpec(hosts=['test']),
+        ssl=True,
+        ssl_cert=ceph_generated_cert,
+        ssl_key=ceph_generated_key,
+        ssl_ca_cert=cephadm_root_ca,
+        certificate_source='inline',
+    )
+    with contextlib.ExitStack() as stack:
+        stack.enter_context(with_host(cephadm_module, "test"))
+        stack.enter_context(with_service(cephadm_module, nfs_spec))
+        nfs_spec.tls_ktls = True
+        cephadm_module.apply([nfs_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")
+        # NB: it appears that the code is designed to redeploy unless all
+        # dependencies are prefixed with 'kmip' but I can't find any code
+        # that would produce any dependencies prefixed with 'kmip'!