From 7b228348a0f1e8c30264c2b0dd2f5993442a125e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Fran=C3=A7oise?= Date: Wed, 24 Aug 2016 14:45:51 +0200 Subject: [PATCH] Fixed flaky tempest test Fixed the flaky test_delete_audit test which was failing if the delete query was sent before the audit reaches an 'idle' state. Change-Id: I244643b1f7c9b31baa5c25753e62dd3da0a53544 --- .../tests/api/admin/test_audit.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/watcher_tempest_plugin/tests/api/admin/test_audit.py b/watcher_tempest_plugin/tests/api/admin/test_audit.py index 8bb6ba464..10c5ad025 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_audit.py +++ b/watcher_tempest_plugin/tests/api/admin/test_audit.py @@ -16,6 +16,8 @@ from __future__ import unicode_literals +import functools + from tempest.lib import exceptions from tempest import test @@ -123,10 +125,28 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest): _, body = self.create_audit(audit_template['uuid']) audit_uuid = body['uuid'] + test.call_until_true( + func=functools.partial( + self.is_audit_idle, audit_uuid), + duration=10, + sleep_for=.5 + ) + + def is_audit_deleted(uuid): + try: + return not bool(self.client.show_audit(uuid)) + except exceptions.NotFound: + return True + self.delete_audit(audit_uuid) - self.assertRaises( - exceptions.NotFound, self.client.show_audit, audit_uuid) + test.call_until_true( + func=functools.partial(is_audit_deleted, audit_uuid), + duration=5, + sleep_for=1 + ) + + self.assertTrue(is_audit_deleted(audit_uuid)) class TestShowListAudit(base.BaseInfraOptimTest):