]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add deployment test for osd 54141/head
authorJohn Mulligan <jmulligan@redhat.com>
Sun, 22 Oct 2023 12:14:24 +0000 (08:14 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sun, 22 Oct 2023 12:53:54 +0000 (08:53 -0400)
Add a deployment test case for OSD. OSD has some special properties that
we have extra assertions for.

Part of a series of commits to increase coverage of deployment
path features with regards to container engine options, env vars
and mounts. This will serve future refactoring efforts.

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

index ced9a0bb7f5d7d4bd2cb4c2e5669f8df1fd9f724..c77b243dfa774cc59b8117c34cc617202f730b90 100644 (file)
@@ -404,6 +404,51 @@ def test_deploy_ceph_mgr_container(cephadm_fs, monkeypatch):
     assert _make_var_run.call_args[0][3] == 8765
 
 
+def test_deploy_ceph_osd_container(cephadm_fs, monkeypatch):
+    mocks = _common_mp(monkeypatch)
+    _firewalld = mocks['Firewalld']
+    _make_var_run = mock.MagicMock()
+    monkeypatch.setattr('cephadm.make_var_run', _make_var_run)
+    fsid = 'b01dbeef-701d-9abe-0000-e1e5a47004a7'
+    with with_cephadm_ctx([]) as ctx:
+        ctx.container_engine = mock_podman()
+        ctx.fsid = fsid
+        ctx.name = 'osd.quux'
+        ctx.image = 'quay.io/ceph/ceph:latest'
+        ctx.reconfig = False
+        ctx.allow_ptrace = False
+        ctx.osd_fsid = '00000000-0000-0000-0000-000000000000'
+        ctx.config_blobs = {
+            'config': 'XXXXXXX',
+            'keyring': 'YYYYYY',
+        }
+        _cephadm._common_deploy(ctx)
+
+    basedir = pathlib.Path(f'/var/lib/ceph/{fsid}/osd.quux')
+    assert basedir.is_dir()
+    with open(basedir / 'unit.run') as f:
+        runfile_lines = f.read().splitlines()
+    assert 'podman' in runfile_lines[-1]
+    assert runfile_lines[-1].endswith(
+        'quay.io/ceph/ceph:latest -n osd.quux -f --setuser ceph --setgroup ceph --default-log-to-file=false --default-log-to-journald=true --default-log-to-stderr=false'
+    )
+    assert '-e TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES' in runfile_lines[-1]
+    assert '--privileged' in runfile_lines[-1]
+    assert '--pids-limit' in runfile_lines[-1]
+    assert '--entrypoint /usr/bin/ceph-osd' in runfile_lines[-1]
+    assert f'-v /var/lib/ceph/{fsid}/osd.quux:/var/lib/ceph/osd/ceph-quux:z' in runfile_lines[-1]
+    assert f'-v /var/log/ceph/{fsid}:/var/log/ceph:z' in runfile_lines[-1]
+    assert '-v /dev:/dev' in runfile_lines[-1]
+    _firewalld().open_ports.assert_not_called()
+    with open(basedir / 'config') as f:
+        assert f.read() == 'XXXXXXX'
+    with open(basedir / 'keyring') as f:
+        assert f.read() == 'YYYYYY'
+    assert _make_var_run.call_count == 1
+    assert _make_var_run.call_args[0][2] == 8765
+    assert _make_var_run.call_args[0][3] == 8765
+
+
 def test_deploy_ceph_exporter_container(cephadm_fs, monkeypatch):
     mocks = _common_mp(monkeypatch)
     _firewalld = mocks['Firewalld']