From 6d4e995e7250715fa8b17daf69ccd5d90de26246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Douglas=20Mendiz=C3=A1bal?= Date: Thu, 24 Jun 2021 13:58:09 -0500 Subject: [PATCH] Let the orders complete before using them This patch changes a test to wait a few seconds for the orders to be processed by Barbican. Currently there are intermittent failures when the test executes faster than Barbican can process orders. Change-Id: I863ca223d6732b43dd6baa1510d4206b34bfb19e --- barbican_tempest_plugin/tests/api/test_orders.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/barbican_tempest_plugin/tests/api/test_orders.py b/barbican_tempest_plugin/tests/api/test_orders.py index de8791b..0dff2fa 100644 --- a/barbican_tempest_plugin/tests/api/test_orders.py +++ b/barbican_tempest_plugin/tests/api/test_orders.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +import time + from tempest.lib import decorators from barbican_tempest_plugin.tests.api import base @@ -56,7 +58,14 @@ class OrdersTest(base.BaseKeyManagerTest): self.assertEqual(2, body.get('total'), body) self.assertEqual(2, len(body.get('orders')), body) - orders = body.get('orders') + # Wait max 60 seconds for orders to finish + for _ in range(12): + orders = self.order_client.list_orders().get('orders') + statuses = [o['status'] for o in orders] + if len(set(statuses)) == 1 and statuses[0] == 'ACTIVE': + break + time.sleep(5) + for order in orders: self.assertIn( base._get_uuid(order.get('order_ref')),