From: John Mulligan Date: Wed, 3 Jan 2024 14:47:47 +0000 (-0500) Subject: cepahdm: add some specific tests for daemon id systemd name generation X-Git-Tag: testing/wip-batrick-testing-20240411.154038~702^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6e0af1d00df841101b032959fdbf6e6c6194870e;p=ceph-ci.git cepahdm: add some specific tests for daemon id systemd name generation Signed-off-by: John Mulligan --- diff --git a/src/cephadm/tests/test_util_funcs.py b/src/cephadm/tests/test_util_funcs.py index c52852db679..6b5380711f3 100644 --- a/src/cephadm/tests/test_util_funcs.py +++ b/src/cephadm/tests/test_util_funcs.py @@ -872,3 +872,37 @@ def test_daemon_sub_identity_from_service_invalid(): service_name = 'random-task@elsewise.service' with pytest.raises(ValueError): DaemonSubIdentity.from_service_name(service_name) + + +def test_daemon_id_systemd_names(): + from cephadmlib.daemon_identity import DaemonIdentity + + di = DaemonIdentity( + '244c9842-866b-11ee-80ad-3497f6318048', 'test', 'foo.bar' + ) + assert ( + di.unit_name + == 'ceph-244c9842-866b-11ee-80ad-3497f6318048@test.foo.bar' + ) + assert ( + di.service_name + == 'ceph-244c9842-866b-11ee-80ad-3497f6318048@test.foo.bar.service' + ) + assert ( + di.init_service_name + == 'ceph-244c9842-866b-11ee-80ad-3497f6318048-init@test.foo.bar.service' + ) + + +def test_daemon_sub_id_systemd_names(): + from cephadmlib.daemon_identity import DaemonSubIdentity + + dsi = DaemonSubIdentity( + '244c9842-866b-11ee-80ad-3497f6318048', 'test', 'foo.bar', 'quux', + ) + assert ( + dsi.sidecar_service_name + == 'ceph-244c9842-866b-11ee-80ad-3497f6318048-sidecar@test.foo.bar:quux.service' + ) + with pytest.raises(ValueError): + dsi.service_name