From 2fb7dcbdfc76626a949ea8267e53ea4b47d8c441 Mon Sep 17 00:00:00 2001 From: Edin Sarajlic Date: Thu, 19 Sep 2019 14:09:09 +1000 Subject: [PATCH] Add function that waits until Rmq units are clustered and ready --- .../charm_tests/rabbitmq_server/utils.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zaza/openstack/charm_tests/rabbitmq_server/utils.py b/zaza/openstack/charm_tests/rabbitmq_server/utils.py index e429521..7599511 100644 --- a/zaza/openstack/charm_tests/rabbitmq_server/utils.py +++ b/zaza/openstack/charm_tests/rabbitmq_server/utils.py @@ -11,3 +11,23 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import zaza.model + + +def wait_for_cluster(model_name=None, timeout=1200): + """Wait for rmq units extended status to show cluster readiness, + after an optional initial sleep period. Initial sleep is likely + necessary to be effective following a config change, as status + message may not instantly update to non-ready.""" + states = { + 'rabbitmq-server': { + 'workload-status-messages': 'Unit is ready and clustered' + } + } + + zaza.model.wait_for_application_states(model_name=model_name, + states=states, + timeout=timeout) + +