]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: update unit file test imports
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 28 Sep 2023 21:17:03 +0000 (17:17 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sun, 10 Dec 2023 15:20:30 +0000 (10:20 -0500)
Update systemd unit file tests file to use the canonical module for
systemd units functions rather than importing them indirectly from
cephadm.py.
This future proofs the test in case the imports in cephadm.py
change.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/test_unit_file.py

index 0ebd84be3e84a1ae263edefc78b815d2fcaea5f6..ab24aab4e57b9dc74ded262f70013b3bf4c91579 100644 (file)
@@ -16,24 +16,26 @@ from tests.fixtures import (
     with_cephadm_ctx,
 )
 
+from cephadmlib import context
+from cephadmlib import systemd_unit
 from cephadmlib.constants import CGROUPS_SPLIT_PODMAN_VERSION
 
 _cephadm = import_cephadm()
 
 
 def _get_unit_file(ctx, fsid):
-    return str(_cephadm.get_unit_file(ctx, fsid))
+    return str(systemd_unit.get_unit_file(ctx, fsid))
 
 
 def test_docker_engine_requires_docker():
-    ctx = _cephadm.CephadmContext()
+    ctx = context.CephadmContext()
     ctx.container_engine = mock_docker()
     r = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')
     assert 'Requires=docker.service' in r
 
 
 def test_podman_engine_does_not_req_docker():
-    ctx = _cephadm.CephadmContext()
+    ctx = context.CephadmContext()
     ctx.container_engine = mock_podman()
     r = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')
     assert 'Requires=docker.service' not in r
@@ -42,7 +44,7 @@ def test_podman_engine_does_not_req_docker():
 def test_podman_engine_forking_service():
     # verity that the podman service uses the forking service type
     # and related parameters
-    ctx = _cephadm.CephadmContext()
+    ctx = context.CephadmContext()
     ctx.container_engine = mock_podman()
     r = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')
     assert 'Type=forking' in r
@@ -52,7 +54,7 @@ def test_podman_engine_forking_service():
 
 
 def test_podman_with_split_cgroups_sets_delegate():
-    ctx = _cephadm.CephadmContext()
+    ctx = context.CephadmContext()
     ctx.container_engine = mock_podman()
     ctx.container_engine.version = CGROUPS_SPLIT_PODMAN_VERSION
     r = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')
@@ -65,7 +67,7 @@ def _ignore_blank_lines(value):
 
 
 def test_new_docker():
-    ctx = _cephadm.CephadmContext()
+    ctx = context.CephadmContext()
     ctx.container_engine = mock_docker()
     ru = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')
     assert _ignore_blank_lines(ru) == [
@@ -104,7 +106,7 @@ def test_new_docker():
 
 
 def test_new_podman():
-    ctx = _cephadm.CephadmContext()
+    ctx = context.CephadmContext()
     ctx.container_engine = mock_podman()
     ctx.container_engine.version = CGROUPS_SPLIT_PODMAN_VERSION
     ru = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')