From 7cbf30b983b222b452e693eb546bb3ddace32944 Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Fri, 22 Sep 2023 15:58:39 +0200 Subject: [PATCH] Skip background ping checks during controllers reboot with nonDVR When DVR is disabled, rebooting or applying network disruptions on the controllers nodes can affect dataplane traffic because the packets are not directly routed to the compute nodes. Due to this, some faults tests fail during the background ping checks. This patch skips the background ping checks on those tests. Change-Id: If51016ce7c3562d1f18ac1f2124db72ef29c90d7 --- tobiko/tests/faults/ha/test_cloud_recovery.py | 9 ++++++++- tobiko/tripleo/__init__.py | 1 + tobiko/tripleo/_overcloud.py | 12 ++++++++++++ tobiko/tripleo/nova.py | 15 ++++++++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tobiko/tests/faults/ha/test_cloud_recovery.py b/tobiko/tests/faults/ha/test_cloud_recovery.py index d72baa639..e5a7a9a01 100644 --- a/tobiko/tests/faults/ha/test_cloud_recovery.py +++ b/tobiko/tests/faults/ha/test_cloud_recovery.py @@ -165,7 +165,7 @@ class DisruptTripleoNodesTest(testtools.TestCase): def test_0vercloud_health_check(self): OvercloudHealthCheck.run_before(skip_mac_table_size_test=False) - @nova.skip_background_vm_ping_checks + @nova.skip_background_vm_ping_checks_when_nondvr def test_z99_hard_reboot_controllers_recovery(self): OvercloudHealthCheck.run_before() cloud_disruptions.reset_all_controller_nodes() @@ -215,6 +215,7 @@ class DisruptTripleoNodesTest(testtools.TestCase): except nova_osp.ServerNotFoundError: LOG.debug(f"Server {vm_id} not found") + @nova.skip_background_vm_ping_checks_when_nondvr @testtools.skipIf(has_external_lb, SKIP_MESSAGE_EXTLB) def test_z99_reboot_controller_galera_main_vip(self): # This test case may fail at times if RHBZ#2124877 is not resolved @@ -231,24 +232,28 @@ class DisruptTripleoNodesTest(testtools.TestCase): cloud_disruptions.check_no_duplicate_ips( self.vms_detailed_info, ports_before_stack_creation) + @nova.skip_background_vm_ping_checks_when_nondvr @testtools.skipIf(has_external_lb, SKIP_MESSAGE_EXTLB) def test_z99_reboot_controller_main_vip(self): OvercloudHealthCheck.run_before() cloud_disruptions.reset_controller_main_vip() OvercloudHealthCheck.run_after() + @nova.skip_background_vm_ping_checks_when_nondvr @testtools.skipIf(has_external_lb, SKIP_MESSAGE_EXTLB) def test_z99_reboot_controller_non_main_vip(self): OvercloudHealthCheck.run_before() cloud_disruptions.reset_controllers_non_main_vip() OvercloudHealthCheck.run_after() + @nova.skip_background_vm_ping_checks_when_nondvr @testtools.skipIf(has_external_lb, SKIP_MESSAGE_EXTLB) def test_z99_crash_controller_main_vip(self): OvercloudHealthCheck.run_before() cloud_disruptions.crash_controller_main_vip() OvercloudHealthCheck.run_after() + @nova.skip_background_vm_ping_checks_when_nondvr @overcloud.skip_unless_kexec_tools_installed @testtools.skipIf(has_external_lb, SKIP_MESSAGE_EXTLB) def test_z99_crash_controller_non_main_vip(self): @@ -256,6 +261,7 @@ class DisruptTripleoNodesTest(testtools.TestCase): cloud_disruptions.crash_controllers_non_main_vip() OvercloudHealthCheck.run_after() + @nova.skip_background_vm_ping_checks_when_nondvr @pacemaker.skip_if_fencing_not_deployed @testtools.skipIf(has_external_lb, SKIP_MESSAGE_EXTLB) def test_network_disruptor_main_vip(self): @@ -317,6 +323,7 @@ class DisruptTripleoNodesTest(testtools.TestCase): cloud_disruptions.request_galera_sst() OvercloudHealthCheck.run_after() + @nova.skip_background_vm_ping_checks_when_nondvr @pytest.mark.flaky(reruns=0) def test_controllers_shutdown(self): OvercloudHealthCheck.run_before() diff --git a/tobiko/tripleo/__init__.py b/tobiko/tripleo/__init__.py index 9a325aab2..76e65f628 100644 --- a/tobiko/tripleo/__init__.py +++ b/tobiko/tripleo/__init__.py @@ -54,6 +54,7 @@ skip_if_missing_overcloud = overcloud.skip_if_missing_overcloud skip_unless_has_overcloud = overcloud.skip_unless_has_overcloud get_overcloud_ssh_username = overcloud.get_overcloud_ssh_username skip_if_ceph_rgw = containers.skip_if_ceph_rgw +get_container_runtime_name = containers.get_container_runtime_name get_rhosp_release = _rhosp.get_rhosp_release get_rhosp_version = _rhosp.get_rhosp_version diff --git a/tobiko/tripleo/_overcloud.py b/tobiko/tripleo/_overcloud.py index ff8510276..5e5a6a1a4 100644 --- a/tobiko/tripleo/_overcloud.py +++ b/tobiko/tripleo/_overcloud.py @@ -445,3 +445,15 @@ def setup_overcloud_keystone_credentials(): keystone.register_default_keystone_credentials( credentials=overcloud_keystone_credentials(), position=0) + + +@functools.lru_cache() +def is_dvr_enabled(): + controller0 = topology.list_openstack_nodes(group='controller')[0] + container_runtime = tripleo.get_container_runtime_name() + command = (f"{container_runtime} exec neutron_api crudini --get " + "/etc/neutron/neutron.conf DEFAULT enable_dvr") + enable_dvr = sh.execute(command, + ssh_client=controller0.ssh_client, + sudo=True).stdout.lower() + return "true" in enable_dvr diff --git a/tobiko/tripleo/nova.py b/tobiko/tripleo/nova.py index 3e3a13d1f..210a4108f 100644 --- a/tobiko/tripleo/nova.py +++ b/tobiko/tripleo/nova.py @@ -268,7 +268,20 @@ def skip_background_vm_ping_checks(func): must be dropped for the duration of the test - func""" @wraps(func) def wrapper(*args): # pylint: disable=W0613 + tobiko.add_cleanup(skip_check_or_start_background_vm_ping) check_or_start_background_vm_ping() func(*args) - skip_check_or_start_background_vm_ping() + return wrapper + + +def skip_background_vm_ping_checks_when_nondvr(func): + """Similar to skip_background_vm_ping_checks, but the background ping + checks and the restart of the background ping process is only executed when + DVR is disabled""" + @wraps(func) + def wrapper(*args): # pylint: disable=W0613 + if not overcloud.is_dvr_enabled(): + tobiko.add_cleanup(skip_check_or_start_background_vm_ping) + check_or_start_background_vm_ping() + func(*args) return wrapper