From e6f9a3fce0009a0bfd4e719280499f2977273126 Mon Sep 17 00:00:00 2001 From: Gustavo Sanchez Date: Fri, 3 Sep 2021 12:31:11 -0400 Subject: [PATCH] Removes method invoked only once --- zaza/openstack/charm_tests/manila/tests.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/zaza/openstack/charm_tests/manila/tests.py b/zaza/openstack/charm_tests/manila/tests.py index 6cfa80f..786efa9 100644 --- a/zaza/openstack/charm_tests/manila/tests.py +++ b/zaza/openstack/charm_tests/manila/tests.py @@ -86,13 +86,6 @@ class ManilaTests(test_utils.OpenStackBaseTest): def _list_shares(self): return self.manila_client.shares.list() - @tenacity.retry( - retry=tenacity.retry_if_result(lambda ret: ret is not None), - wait=tenacity.wait_fixed(120), - stop=tenacity.stop_after_attempt(2)) - def _retry_check_commands_on_units(self, cmds, units): - return generic_utils.check_commands_on_units(cmds, units) - def test_902_nrpe_service_checks(self): """Confirm that the NRPE service check files are created.""" units = zaza.model.get_units('manila') @@ -105,11 +98,16 @@ class ManilaTests(test_utils.OpenStackBaseTest): 'check_{}.cfg'.format(check_name) ) - ret = self._retry_check_commands_on_units(cmds, units) - if ret: - logging.info(ret) - - self.assertIsNone(ret, msg=ret) + for attempt in tenacity.Retrying( + retry=tenacity.retry_if_result(lambda ret: ret is not None), + wait=tenacity.wait_fixed(120), + stop=tenacity.stop_after_attempt(2) + ): + with attempt: + ret = generic_utils.check_commands_on_units(cmds, units) + if ret: + logging.info(ret) + self.assertIsNone(ret, msg=ret) class ManilaBaseTest(test_utils.OpenStackBaseTest):