]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add a test case for custom container type
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 14 Jun 2023 15:01:27 +0000 (11:01 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 9 Aug 2023 17:48:07 +0000 (13:48 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/test_custom_container.py

index e3b419b4d19086e8280ac1ca3c51cb2a3323c56e..d98e37450265c7a0e8e1b060e045b3a029d7212c 100644 (file)
@@ -1,6 +1,11 @@
 import unittest
 
-from .fixtures import import_cephadm
+from .fixtures import (
+    cephadm_fs,
+    import_cephadm,
+    mock_podman,
+    with_cephadm_ctx,
+)
 
 
 _cephadm = import_cephadm()
@@ -88,3 +93,45 @@ class TestCustomContainer(unittest.TestCase):
                 'ro=true'
             ]
         ])
+
+
+def test_deploy_custom_container(cephadm_fs):
+    fsid = 'b01dbeef-701d-9abe-0000-e1e5a47004a7'
+    with with_cephadm_ctx([]) as ctx:
+        ctx.container_engine = mock_podman()
+        ctx.fsid = fsid
+        ctx.name = 'container.tdcc'
+        ctx.reconfig = False
+        ctx.allow_ptrace = False
+        ctx.image = 'quay.io/foobar/quux:latest'
+        ctx.extra_entrypoint_args = [
+            '--label',
+            'frobnicationist',
+            '--servers',
+            '192.168.8.42,192.168.8.43,192.168.12.11',
+        ]
+
+        _cephadm._common_deploy(ctx)
+
+        with open(f'/var/lib/ceph/{fsid}/container.tdcc/unit.run') as f:
+            runfile_lines = f.read().splitlines()
+        assert 'set -e' in runfile_lines
+        assert len(runfile_lines) > 2
+        assert runfile_lines[-1] == (
+            '/usr/bin/podman run'
+            ' --rm --ipc=host --stop-signal=SIGTERM --init'
+            ' --name ceph-b01dbeef-701d-9abe-0000-e1e5a47004a7-container-tdcc'
+            ' -d --log-driver journald'
+            ' --conmon-pidfile /run/ceph-b01dbeef-701d-9abe-0000-e1e5a47004a7@container.tdcc.service-pid'
+            ' --cidfile /run/ceph-b01dbeef-701d-9abe-0000-e1e5a47004a7@container.tdcc.service-cid'
+            ' --cgroups=split --no-hosts'
+            ' -e CONTAINER_IMAGE=quay.io/foobar/quux:latest'
+            ' -e NODE_NAME=host1'
+            ' quay.io/foobar/quux:latest'
+            ' --label frobnicationist --servers 192.168.8.42,192.168.8.43,192.168.12.11'
+        )
+        assert all([
+            l.startswith('! /usr/bin/podman rm')
+            for l in runfile_lines
+            if not l.startswith(('#', 'set', '/usr/bin/podman run'))
+        ]), 'remaining commands should be "rms"'