]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: update haproxy/keepalive service test for newly generated files
authorLuis Domingues <domingues.luis@protonmail.ch>
Tue, 9 Aug 2022 08:25:20 +0000 (09:25 +0100)
committerLuis Domingues <domingues.luis@protonmail.ch>
Tue, 9 Aug 2022 21:34:42 +0000 (22:34 +0100)
Signed-off-by: Luis Domingues <domingues.luis@protonmail.ch>
src/pybind/mgr/cephadm/tests/test_services.py

index 32c455f05dc2fbae733dab3cdab7bc62166e2f3b..655dbccf52970705d2c532dcd875271281488844 100644 (file)
@@ -940,7 +940,7 @@ class TestIngressService:
                                 '}\n  '
                                 'track_script {\n      '
                                 'check_backend\n  }\n'
-                                '}'
+                                '}\n'
                         }
                 }
 
@@ -1053,13 +1053,71 @@ class TestIngressService:
                                 '}\n  '
                                 'track_script {\n      '
                                 'check_backend\n  }\n'
-                                '}'
+                                '}\n'
                         }
                 }
 
                 # check keepalived config
                 assert keepalived_generated_conf[0] == keepalived_expected_conf
 
+                # generate the haproxy conf based on the specified spec
+                haproxy_generated_conf = cephadm_module.cephadm_services['ingress'].haproxy_generate_config(
+                    CephadmDaemonDeploySpec(host='test', daemon_id='ingress', service_name=ispec.service_name()))
+
+                haproxy_expected_conf = {
+                    'files':
+                        {
+                            'haproxy.cfg':
+                                '# This file is generated by cephadm.'
+                                '\nglobal\n    log         '
+                                '127.0.0.1 local2\n    '
+                                'chroot      /var/lib/haproxy\n    '
+                                'pidfile     /var/lib/haproxy/haproxy.pid\n    '
+                                'maxconn     8000\n    '
+                                'daemon\n    '
+                                'stats socket /var/lib/haproxy/stats\n'
+                                '\ndefaults\n    '
+                                'mode                    http\n    '
+                                'log                     global\n    '
+                                'option                  httplog\n    '
+                                'option                  dontlognull\n    '
+                                'option http-server-close\n    '
+                                'option forwardfor       except 127.0.0.0/8\n    '
+                                'option                  redispatch\n    '
+                                'retries                 3\n    '
+                                'timeout queue           20s\n    '
+                                'timeout connect         5s\n    '
+                                'timeout http-request    1s\n    '
+                                'timeout http-keep-alive 5s\n    '
+                                'timeout client          1s\n    '
+                                'timeout server          1s\n    '
+                                'timeout check           5s\n    '
+                                'maxconn                 8000\n'
+                                '\nfrontend stats\n    '
+                                'mode http\n    '
+                                'bind *:8999\n    '
+                                'bind localhost:8999\n    '
+                                'stats enable\n    '
+                                'stats uri /stats\n    '
+                                'stats refresh 10s\n    '
+                                'stats auth admin:12345\n    '
+                                'http-request use-service prometheus-exporter if { path /metrics }\n    '
+                                'monitor-uri /health\n'
+                                '\nfrontend frontend\n    '
+                                'bind *:8089\n    '
+                                'default_backend backend\n\n'
+                                'backend backend\n    '
+                                'option forwardfor\n    '
+                                'balance static-rr\n    '
+                                'option httpchk HEAD / HTTP/1.0\n    '
+                                'server '
+                                + haproxy_generated_conf[1][0] + ' 1::4:80 check weight 100\n'
+                        }
+                }
+
+                assert haproxy_generated_conf[0] == haproxy_expected_conf
+
+
 class TestCephFsMirror:
     @patch("cephadm.serve.CephadmServe._run_cephadm")
     def test_config(self, _run_cephadm, cephadm_module: CephadmOrchestrator):