From 570a9f1a5719ff84e6b79a0fca46bd422449b0c2 Mon Sep 17 00:00:00 2001 From: Martin Kalcok Date: Fri, 21 Oct 2022 14:29:55 +0200 Subject: [PATCH] Include fix for race condition when using `wait_for_application_states` In some testing environment, `wait_for_application_states()` can execute before juju starts actually performing changes on the units, causing it to return immediately. --- zaza/openstack/charm_tests/ovn/tests.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zaza/openstack/charm_tests/ovn/tests.py b/zaza/openstack/charm_tests/ovn/tests.py index 0e49b6a..b4cb7cf 100644 --- a/zaza/openstack/charm_tests/ovn/tests.py +++ b/zaza/openstack/charm_tests/ovn/tests.py @@ -623,6 +623,7 @@ class OVSOVNMigrationTest(test_utils.BaseCharmTest): except KeyError: pass zaza.model.wait_for_agent_status() + zaza.model.block_until_all_units_idle() zaza.model.wait_for_application_states( states=self.target_deploy_status) @@ -706,8 +707,8 @@ class OVNCentralDeferredRestartTest( class OVNCentralDownscaleTests(test_utils.BaseCharmTest): """Tests for cluster-status and cluster-kick actions.""" - SB_CMD = "ovs-appctl -t /var/run/ovn/ovnsb_db.ctl {}" - NB_CMD = "ovs-appctl -t /var/run/ovn/ovnnb_db.ctl {}" + SB_CMD = "ovn-appctl -t /var/run/ovn/ovnsb_db.ctl {}" + NB_CMD = "ovn-appctl -t /var/run/ovn/ovnnb_db.ctl {}" def _cluster_status_action(self): """Return Southbound and Northbound cluster status. @@ -741,7 +742,7 @@ class OVNCentralDownscaleTests(test_utils.BaseCharmTest): def _add_unit(number_of_units=1): """Add specified number of units to ovn-central application. - This function also waits unit the application reaches active state. + This function also waits until the application reaches active state. """ zaza.model.add_unit( "ovn-central", @@ -752,11 +753,13 @@ class OVNCentralDownscaleTests(test_utils.BaseCharmTest): @staticmethod def _remove_unit(unit_name): - """Add specified unit from ovn-central application. + """Remove specified unit from ovn-central application. - This function also waits unit the application reaches active state. + This function also waits until the application reaches active state + again. """ zaza.model.destroy_unit("ovn-central", unit_name) + zaza.model.block_until_all_units_idle() zaza.model.wait_for_application_states() def _assert_servers_cleanly_removed(self, sb_id, nb_id):