From bc4e996d6a2dc9fe191ecc59250f7e0e01ccb6b3 Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Mon, 16 Nov 2020 16:30:25 +0100 Subject: [PATCH] Check OVN DBs listening on VIP (BZ1600151) Verify OVN DBs are listening on proper VIP IP and both SB and NB ports Change-Id: I4909a764834f970c9f77a2a0c958171944fdb68d --- tobiko/openstack/tests/__init__.py | 2 +- tobiko/openstack/tests/_neutron.py | 65 +++++++++++++++++-- tobiko/tests/faults/ha/test_cloud_recovery.py | 2 +- tobiko/tripleo/containers.py | 5 +- 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/tobiko/openstack/tests/__init__.py b/tobiko/openstack/tests/__init__.py index 282831e65..4077d521b 100644 --- a/tobiko/openstack/tests/__init__.py +++ b/tobiko/openstack/tests/__init__.py @@ -20,7 +20,7 @@ from tobiko.openstack.tests import _neutron from tobiko.openstack.tests import _nova test_neutron_agents_are_alive = _neutron.test_neutron_agents_are_alive -test_ovn_dbs_are_synchronized = _neutron.test_ovn_dbs_are_synchronized +test_ovn_dbs_validations = _neutron.test_ovn_dbs_validations test_evacuable_server_creation = _nova.test_evacuable_server_creation test_server_creation = _nova.test_server_creation diff --git a/tobiko/openstack/tests/_neutron.py b/tobiko/openstack/tests/_neutron.py index 49b8a644a..3dde7ff01 100644 --- a/tobiko/openstack/tests/_neutron.py +++ b/tobiko/openstack/tests/_neutron.py @@ -95,13 +95,7 @@ def test_neutron_agents_are_alive(timeout=300., interval=5.): return agents -def test_ovn_dbs_are_synchronized(): - if not is_ovn_configured(): - LOG.debug('OVN not configured. OVN DB sync validations skipped') - return - - test_case = tobiko.get_test_case() - +def ovn_dbs_are_synchronized(test_case): # declare commands search_container_cmd = ( "%s ps --format '{{.Names}}' -f name=ovn-dbs-bundle" % @@ -171,3 +165,60 @@ def test_ovn_dbs_are_synchronized(): ovn_master_dbs_show_dict[db]) LOG.info("All OVN DBs are synchronized") + + +def ovn_dbs_vip_bindings(test_case): + # commands to obtain OVN SB and NB connection strings + get_ovn_nb_conn_cmd = ( + 'crudini --get /var/lib/config-data/puppet-generated/neutron/etc/' + 'neutron/plugins/ml2/ml2_conf.ini ovn ovn_nb_connection') + get_ovn_sb_conn_cmd = get_ovn_nb_conn_cmd.replace('ovn_nb_connection', + 'ovn_sb_connection') + + controllers = topology.list_openstack_nodes(group='controller') + ovn_conn_str = {} + ovn_conn_str['nb'] = sh.execute(get_ovn_nb_conn_cmd, + ssh_client=controllers[0].ssh_client, + sudo=True).stdout.splitlines()[0] + ovn_conn_str['sb'] = sh.execute(get_ovn_sb_conn_cmd, + ssh_client=controllers[0].ssh_client, + sudo=True).stdout.splitlines()[0] + ovn_conn = {} + for db in ('nb', 'sb'): + ovn_conn[db] = {} + ipv6 = re.findall(r'\[.*\]', ovn_conn_str[db]) + if len(ipv6) == 1: + ovn_conn[db]['ip'] = ipv6[0] + elif len(ipv6) == 0: + ovn_conn[db]['ip'] = ovn_conn_str[db].split(':')[1] + else: + raise RuntimeError('Error parsing ovn db connection string from ' + 'configuration file') + ovn_conn[db]['port'] = ovn_conn_str[db].split(':')[-1] + + # command to obtain sockets listening on OVN SB and DB DBs + get_ovn_db_sockets_listening_cmd = \ + "ss -p state listening 'sport = {srcport} and src {srcip}'" + + for controller in controllers: + for db in ('nb', 'sb'): + ovn_db_sockets_listening = sh.execute( + get_ovn_db_sockets_listening_cmd.format( + srcport=ovn_conn[db]['port'], + srcip=ovn_conn[db]['ip']), + ssh_client=controller.ssh_client, + sudo=True).stdout.splitlines() + test_case.assertEqual(2, len(ovn_db_sockets_listening)) + test_case.assertIn('ovsdb-server', ovn_db_sockets_listening[1]) + + +def test_ovn_dbs_validations(): + if not is_ovn_configured(): + LOG.debug('OVN not configured. OVN DB sync validations skipped') + return + + test_case = tobiko.get_test_case() + + # run validations + ovn_dbs_are_synchronized(test_case) + ovn_dbs_vip_bindings(test_case) diff --git a/tobiko/tests/faults/ha/test_cloud_recovery.py b/tobiko/tests/faults/ha/test_cloud_recovery.py index 2891b6878..ef2768505 100644 --- a/tobiko/tests/faults/ha/test_cloud_recovery.py +++ b/tobiko/tests/faults/ha/test_cloud_recovery.py @@ -27,7 +27,7 @@ def overcloud_health_checks(passive_checks_only=False): containers.assert_all_tripleo_containers_running() containers.assert_equal_containers_state() containers.run_container_config_validations() - tests.test_ovn_dbs_are_synchronized() + tests.test_ovn_dbs_validations() validations.run_post_deployment_validations() diff --git a/tobiko/tripleo/containers.py b/tobiko/tripleo/containers.py index 098ce7d9f..f9ace81d1 100644 --- a/tobiko/tripleo/containers.py +++ b/tobiko/tripleo/containers.py @@ -284,11 +284,8 @@ def run_container_config_validations(): for node in topology.list_openstack_nodes( group=config_check['node_group']): for param_check in config_check['param_validations']: - # 'docker' is used here in order to be compatible with old OSP - # versions. On versions with podman, 'docker' command is - # linked to 'podman' obtained_param = sh.execute( - "docker exec -uroot " + f"{container_runtime_name} exec -uroot " f"{config_check['container_name']} crudini " f"--get {config_check['config_file']} " f"{param_check['section']} {param_check['param']}",