From 5915d2ecd08c1289da38d4fbeb646898f9c5dccf Mon Sep 17 00:00:00 2001 From: Luis Domingues Date: Tue, 9 Aug 2022 08:39:37 +0100 Subject: [PATCH] mgr/cephadm: set test for multiple vips options for ingress service Signed-off-by: Luis Domingues --- src/pybind/mgr/cephadm/tests/test_services.py | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/tests/test_services.py b/src/pybind/mgr/cephadm/tests/test_services.py index 334afe167ec66..32c455f05dc2f 100644 --- a/src/pybind/mgr/cephadm/tests/test_services.py +++ b/src/pybind/mgr/cephadm/tests/test_services.py @@ -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") -- 2.39.5