From 010172b5925298d3b831612b9badc0e94d884716 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Tue, 18 Apr 2023 14:12:04 -0400 Subject: [PATCH] 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-pick form 080a715130b76dc546ed61c6c20af84a88d7dfba that was PR#1036 --- 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"])