]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: set test for multiple vips options for ingress service
authorLuis Domingues <domingues.luis@protonmail.ch>
Tue, 9 Aug 2022 07:39:37 +0000 (08:39 +0100)
committerLuis Domingues <domingues.luis@protonmail.ch>
Tue, 9 Aug 2022 21:34:38 +0000 (22:34 +0100)
Signed-off-by: Luis Domingues <domingues.luis@protonmail.ch>
src/pybind/mgr/cephadm/tests/test_services.py

index 334afe167ec66fafd800e4d4cca4c1cb5bf94da4..32c455f05dc2fbae733dab3cdab7bc62166e2f3b 100644 (file)
@@ -926,7 +926,7 @@ class TestIngressService:
                                 'state MASTER\n  '
                                 'priority 100\n  '
                                 'interface if0\n  '
-                                'virtual_router_id 51\n  '
+                                'virtual_router_id 50\n  '
                                 'advert_int 1\n  '
                                 'authentication {\n      '
                                 'auth_type PASS\n      '
@@ -1004,6 +1004,61 @@ class TestIngressService:
 
                 assert haproxy_generated_conf[0] == haproxy_expected_conf
 
+            # Check the ingress with multiple VIPs
+            s = RGWSpec(service_id="foo", placement=PlacementSpec(count=1),
+                        rgw_frontend_type='beast')
+
+            ispec = IngressSpec(service_type='ingress',
+                                service_id='test',
+                                backend_service='rgw.foo',
+                                frontend_port=8089,
+                                monitor_port=8999,
+                                monitor_user='admin',
+                                monitor_password='12345',
+                                keepalived_password='12345',
+                                virtual_interface_networks=['1.2.3.0/24'],
+                                virtual_ips_list=["1.2.3.4/32"])
+            with with_service(cephadm_module, s) as _, with_service(cephadm_module, ispec) as _:
+                # generate the keepalived conf based on the specified spec
+                # Test with only 1 IP on the list, as it will fail with more VIPS but only one host.
+                keepalived_generated_conf = cephadm_module.cephadm_services['ingress'].keepalived_generate_config(
+                    CephadmDaemonDeploySpec(host='test', daemon_id='ingress', service_name=ispec.service_name()))
+
+                keepalived_expected_conf = {
+                    'files':
+                        {
+                            'keepalived.conf':
+                                '# This file is generated by cephadm.\n'
+                                'vrrp_script check_backend {\n    '
+                                'script "/usr/bin/curl http://localhost:8999/health"\n    '
+                                'weight -20\n    '
+                                'interval 2\n    '
+                                'rise 2\n    '
+                                'fall 2\n}\n\n'
+                                'vrrp_instance VI_0 {\n  '
+                                'state MASTER\n  '
+                                'priority 100\n  '
+                                'interface if0\n  '
+                                'virtual_router_id 50\n  '
+                                'advert_int 1\n  '
+                                'authentication {\n      '
+                                'auth_type PASS\n      '
+                                'auth_pass 12345\n  '
+                                '}\n  '
+                                'unicast_src_ip 1::4\n  '
+                                'unicast_peer {\n  '
+                                '}\n  '
+                                'virtual_ipaddress {\n    '
+                                '1.2.3.4/32 dev if0\n  '
+                                '}\n  '
+                                'track_script {\n      '
+                                'check_backend\n  }\n'
+                                '}'
+                        }
+                }
+
+                # check keepalived config
+                assert keepalived_generated_conf[0] == keepalived_expected_conf
 
 class TestCephFsMirror:
     @patch("cephadm.serve.CephadmServe._run_cephadm")