]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add unit test coverage for deploying haproxy
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 3 Oct 2023 17:19:18 +0000 (13:19 -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 fff88ba637558fe587a59db48783f9c8e2cc4c0c..fdc6f582dbdc172f35051f3aa6f9e1e919b79c12 100644 (file)
@@ -142,3 +142,45 @@ def test_deploy_keepalived_container(cephadm_fs, monkeypatch):
     assert (si.st_uid, si.st_gid) == (8765, 8765)
     assert _install_sysctl.call_count == 1
     assert len(_install_sysctl.call_args[0][-1].get_sysctl_settings()) > 1
+
+
+def test_deploy_haproxy_container(cephadm_fs, monkeypatch):
+    mocks = _common_mp(monkeypatch)
+    _firewalld = mocks['Firewalld']
+    _install_sysctl = mocks['install_sysctl']
+    fsid = 'b01dbeef-701d-9abe-0000-e1e5a47004a7'
+    with with_cephadm_ctx([]) as ctx:
+        ctx.container_engine = mock_podman()
+        ctx.fsid = fsid
+        ctx.name = 'haproxy.yyz'
+        ctx.image = 'quay.io/lfeuwbo/haproxy:latest'
+        ctx.reconfig = False
+        ctx.config_blobs = {
+            'config': 'XXXXXXX',
+            'keyring': 'YYYYYY',
+            'files': {
+                'haproxy.cfg': 'bifrost',
+            },
+        }
+        _cephadm._common_deploy(ctx)
+
+    basedir = pathlib.Path(f'/var/lib/ceph/{fsid}/haproxy.yyz')
+    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/lfeuwbo/haproxy:latest haproxy -f /var/lib/haproxy/haproxy.cfg'
+    )
+    _firewalld().open_ports.assert_not_called()
+    assert not (basedir / 'config').exists()
+    assert not (basedir / 'keyring').exists()
+    assert (basedir / 'haproxy').is_dir()
+    si = (basedir / 'haproxy').stat()
+    assert (si.st_uid, si.st_gid) == (8765, 8765)
+    with open(basedir / 'haproxy/haproxy.cfg') as f:
+        assert f.read() == 'bifrost'
+        si = os.fstat(f.fileno())
+        assert (si.st_uid, si.st_gid) == (8765, 8765)
+    assert _install_sysctl.call_count == 1
+    assert len(_install_sysctl.call_args[0][-1].get_sysctl_settings()) > 1