]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: parametrize test for haproxy protocol support
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 21 Mar 2023 17:51:48 +0000 (13:51 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 26 May 2023 14:43:11 +0000 (10:43 -0400)
Make a few small tweaks to an existing test to validate that it
functions similarly when the haxproxy protocol is disabled or enabled.

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

index d33e6b09d9bc071e464966c7d50334e1a8652625..f9817fb2fae4ec11b1aed5f2de3be884e2355aea 100644 (file)
@@ -1221,6 +1221,10 @@ class TestSNMPGateway:
 
 class TestIngressService:
 
+    @pytest.mark.parametrize(
+        "enable_haproxy_protocol",
+        [False, True],
+    )
     @patch("cephadm.inventory.Inventory.get_addr")
     @patch("cephadm.utils.resolve_ip")
     @patch("cephadm.inventory.HostCache.get_daemons_by_service")
@@ -1230,7 +1234,8 @@ class TestIngressService:
         _run_cephadm,
         _get_daemons_by_service,
         _resolve_ip, _get_addr,
-        cephadm_module: CephadmOrchestrator
+        cephadm_module: CephadmOrchestrator,
+        enable_haproxy_protocol: bool,
     ):
         _run_cephadm.side_effect = async_side_effect(('{}', '', 0))
 
@@ -1253,6 +1258,7 @@ class TestIngressService:
                 count=1,
                 hosts=['host1', 'host2']),
             port=12049,
+            enable_haproxy_protocol=enable_haproxy_protocol,
         )
 
         ispec = IngressSpec(
@@ -1265,6 +1271,7 @@ class TestIngressService:
             monitor_user='admin',
             monitor_password='12345',
             keepalived_password='12345',
+            enable_haproxy_protocol=enable_haproxy_protocol,
         )
 
         cephadm_module.spec_store._specs = {
@@ -1315,8 +1322,10 @@ class TestIngressService:
             '    mode        tcp\n'
             '    balance     source\n'
             '    hash-type   consistent\n'
-            '    server nfs.foo.0 192.168.122.111:12049\n'
         )
+        if enable_haproxy_protocol:
+            haproxy_txt += '    default-server send-proxy-v2\n'
+        haproxy_txt += '    server nfs.foo.0 192.168.122.111:12049\n'
         haproxy_expected_conf = {
             'files': {'haproxy.cfg': haproxy_txt}
         }