]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: add unit test coverage for deploying ceph-exporter
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 3 Oct 2023 18:43:51 +0000 (14:43 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 5 Oct 2023 21:05:33 +0000 (17:05 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/test_deploy.py

index a5511a34d1d36d50cfd21b19db03c3ee07e21bb6..1f4eddf3a70d6d6e42d4e1ed50594153a9e18654 100644 (file)
@@ -368,3 +368,48 @@ def test_deploy_ceph_mgr_container(cephadm_fs, monkeypatch):
     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']
+    _get_ip_addresses = mock.MagicMock(return_value=(['10.10.10.10'], []))
+    monkeypatch.setattr('cephadm.get_ip_addresses', _get_ip_addresses)
+    _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 = 'ceph-exporter.zaq'
+        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',
+            'prio-limit': 12,
+        }
+
+        # ceph-exporter is weird and special. it requires the "sock dir"
+        # to already exist. that dir defaults to /var/run/ceph
+        vrc = pathlib.Path('/var/run/ceph')
+        (vrc / fsid).mkdir(parents=True)
+
+        _cephadm._common_deploy(ctx)
+
+    basedir = pathlib.Path(f'/var/lib/ceph/{fsid}/ceph-exporter.zaq')
+    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 client.ceph-exporter.zaq -f --sock-dir=/var/run/ceph/ --addrs=0.0.0.0 --port=9926 --prio-limit=12 --stats-period=5'
+    )
+    assert '--entrypoint /usr/bin/ceph-exporter' 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'