From 92dce405f15f1e571e686dae25d9347d5d36d63b Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Fri, 28 Oct 2022 12:30:26 -0300 Subject: [PATCH 1/3] Retry check of service IP configured (#970) There are scenarios where the config-changed hook can complete, yet the service IP get configured many seconds after, because a relation-changed hook execution needs to be triggered on the hacluster side of the relation. This change adds a retry to the check (10 times with a 2 seconds wait time). This issue was found at the gate https://review.opendev.org/c/openstack/charm-designate-bind/+/861417 (cherry picked from commit d083dde10c772a1fd9b1915707167d7723e245a5) --- .../charm_tests/designate_bind/tests.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/zaza/openstack/charm_tests/designate_bind/tests.py b/zaza/openstack/charm_tests/designate_bind/tests.py index 7526fc7c6..77da133ae 100644 --- a/zaza/openstack/charm_tests/designate_bind/tests.py +++ b/zaza/openstack/charm_tests/designate_bind/tests.py @@ -16,6 +16,13 @@ import logging import os +from tenacity import ( + Retrying, + retry_if_exception_type, + stop_after_attempt, + wait_fixed, +) + import zaza.model as zaza_model import zaza.openstack.charm_tests.test_utils as test_utils @@ -43,8 +50,14 @@ def test_configure_ips(self): zaza_model.set_application_config(self.APPLICATION, config) zaza_model.wait_for_application_states() - configured_ips = zaza_model.run_on_unit(self.UNIT, "ip addr") - self.assertIn(self.VIP, configured_ips["Stdout"]) + for attempt in Retrying(wait=wait_fixed(2), + retry=retry_if_exception_type(AssertionError), + reraise=True, + stop=stop_after_attempt(10)): + with attempt: + configured_ips = zaza_model.run_on_unit(self.UNIT, + "ip addr") + self.assertIn(self.VIP, configured_ips["Stdout"]) logging.info("Removing service IP configuration from %s unit.", self.UNIT) From 8fcb3407e1bd5864ba9316830bbf058829ef2b18 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Tue, 18 Apr 2023 14:12:04 -0400 Subject: [PATCH 2/3] Retry assert after service_ips removal Similar to when an IP has been added to the service_ips earlier in test_configure_ips(), this adds tenacity Retrying after an IP has been removed from the service_ips. (cherry picked from commit 080a715130b76dc546ed61c6c20af84a88d7dfba) --- zaza/openstack/charm_tests/designate_bind/tests.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/zaza/openstack/charm_tests/designate_bind/tests.py b/zaza/openstack/charm_tests/designate_bind/tests.py index 77da133ae..d7bea8435 100644 --- a/zaza/openstack/charm_tests/designate_bind/tests.py +++ b/zaza/openstack/charm_tests/designate_bind/tests.py @@ -55,8 +55,7 @@ def test_configure_ips(self): reraise=True, stop=stop_after_attempt(10)): with attempt: - configured_ips = zaza_model.run_on_unit(self.UNIT, - "ip addr") + configured_ips = zaza_model.run_on_unit(self.UNIT, "ip addr") self.assertIn(self.VIP, configured_ips["Stdout"]) logging.info("Removing service IP configuration from %s unit.", @@ -65,5 +64,10 @@ def test_configure_ips(self): zaza_model.set_application_config(self.APPLICATION, config) zaza_model.wait_for_application_states() - configured_ips = zaza_model.run_on_unit(self.UNIT, "ip addr") - self.assertNotIn(self.VIP, configured_ips["Stdout"]) + for attempt in Retrying(wait=wait_fixed(2), + retry=retry_if_exception_type(AssertionError), + reraise=True, + stop=stop_after_attempt(10)): + with attempt: + configured_ips = zaza_model.run_on_unit(self.UNIT, "ip addr") + self.assertNotIn(self.VIP, configured_ips["Stdout"]) From 58f1dcf1446b7d36a9824ffd9af41ff8c46e0bc7 Mon Sep 17 00:00:00 2001 From: Seyeong Kim Date: Thu, 2 Jul 2026 07:44:52 +0000 Subject: [PATCH 3/3] Fix designate-bind ServiceIPs test wait states Pass target_deploy_status so blocked nrpe is tolerated. Signed-off-by: Seyeong Kim (cherry picked from commit 8e968022e604559a0a066bd2bf3bd93eed0439fe) --- zaza/openstack/charm_tests/designate_bind/tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zaza/openstack/charm_tests/designate_bind/tests.py b/zaza/openstack/charm_tests/designate_bind/tests.py index d7bea8435..de21c4d68 100644 --- a/zaza/openstack/charm_tests/designate_bind/tests.py +++ b/zaza/openstack/charm_tests/designate_bind/tests.py @@ -24,6 +24,7 @@ ) import zaza.model as zaza_model +import zaza.charm_lifecycle.utils as lifecycle_utils import zaza.openstack.charm_tests.test_utils as test_utils @@ -44,11 +45,13 @@ def setUp(self): def test_configure_ips(self): """Configure and un-configure 'service_ips' option.""" config = {"service_ips": self.VIP} + test_config = lifecycle_utils.get_charm_config(fatal=False) + states = test_config.get("target_deploy_status", {}) logging.info("Configuring %s as a Service IP for %s unit.", self.VIP, self.UNIT) zaza_model.set_application_config(self.APPLICATION, config) - zaza_model.wait_for_application_states() + zaza_model.wait_for_application_states(states=states) for attempt in Retrying(wait=wait_fixed(2), retry=retry_if_exception_type(AssertionError), @@ -62,7 +65,7 @@ def test_configure_ips(self): self.UNIT) config["service_ips"] = "" zaza_model.set_application_config(self.APPLICATION, config) - zaza_model.wait_for_application_states() + zaza_model.wait_for_application_states(states=states) for attempt in Retrying(wait=wait_fixed(2), retry=retry_if_exception_type(AssertionError),