]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm/tests: updated test for crash daemon 66559/head
authorTimothy Q Nguyen <timqn22@gmail.com>
Tue, 30 Dec 2025 19:03:34 +0000 (11:03 -0800)
committerTimothy Q Nguyen <timqn22@gmail.com>
Wed, 7 Jan 2026 17:41:50 +0000 (09:41 -0800)
I added some monkeypatch attributes in order for the make check to
succeed with the new crash daemon. This is necessary as the crash
daemon will try to access uid and gid and create a directory, but in
testing these don't exist and need to be substituted.

Signed-off-by: Timothy Q Nguyen <timqn22@gmail.com>
src/cephadm/cephadmlib/daemons/ceph.py
src/cephadm/tests/test_daemon_form.py

index a4b10487b37f1d068b6a923376bd9a8e12c86688..ed30715841c7d64fa3bad8922726a4e416ac25ae 100644 (file)
@@ -52,7 +52,10 @@ class Ceph(ContainerDaemonForm):
     @classmethod
     def for_daemon_type(cls, daemon_type: str) -> bool:
         # TODO: figure out a way to un-special-case osd
-        return daemon_type in cls._daemons and daemon_type not in ('osd', 'crash')
+        return daemon_type in cls._daemons and daemon_type not in (
+            'osd',
+            'crash',
+        )
 
     def __init__(self, ctx: CephadmContext, ident: DaemonIdentity) -> None:
         self.ctx = ctx
@@ -335,6 +338,7 @@ class OSD(Ceph):
     def osd_fsid(self) -> Optional[str]:
         return self._osd_fsid
 
+
 @register_daemon_form
 class Crash(Ceph):
     @classmethod
@@ -352,11 +356,18 @@ class Crash(Ceph):
     def create(cls, ctx: CephadmContext, ident: DaemonIdentity) -> 'Ceph':
         (uid, gid) = extract_uid_gid(ctx)
         data_dir_base = f'{ctx.data_dir}/{ident.fsid}'
-        makedirs(os.path.join(data_dir_base, 'crash'), uid, gid, DATA_DIR_MODE)
-        makedirs(os.path.join(data_dir_base, 'crash', 'posted'), uid, gid,
-                 DATA_DIR_MODE)
+        makedirs(
+            os.path.join(data_dir_base, 'crash'), uid, gid, DATA_DIR_MODE
+        )
+        makedirs(
+            os.path.join(data_dir_base, 'crash', 'posted'),
+            uid,
+            gid,
+            DATA_DIR_MODE,
+        )
         return cls(ctx, ident)
 
+
 @register_daemon_form
 class CephExporter(ContainerDaemonForm):
     """Defines a Ceph exporter container"""
index a2d1773f1c84a33ea1a0fb27cf3fd8e5881d35f4..0a929e31f4bc9def517d0d238c1ec466705207f6 100644 (file)
@@ -72,6 +72,9 @@ def test_can_create_all_daemon_forms(monkeypatch):
     }
     _os_path_isdir = mock.MagicMock(return_value=True)
     monkeypatch.setattr('os.path.isdir', _os_path_isdir)
+    monkeypatch.setattr('cephadmlib.daemons.ceph.extract_uid_gid',
+                        lambda ctx: (167, 167))
+    monkeypatch.setattr('os.chown', lambda *args, **kwargs: None)
     dtypes = _cephadm.get_supported_daemons()
     for daemon_type in dtypes:
         if daemon_type == 'agent':