From 7a30b2455e6cd41b49b0d78a369e3aa39d6473fd Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Wed, 9 Jun 2021 13:09:24 +0530 Subject: [PATCH] fix(test): Retry flaky test test_update_document test randomly breaks in Postgres CI. The remedy right now is to re-run the builds until the success checks come up. This change retries the specific test 2 more times before failing the build --- frappe/tests/test_api.py | 2 ++ requirements.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/frappe/tests/test_api.py b/frappe/tests/test_api.py index 7e77aab779..f99e771fbb 100644 --- a/frappe/tests/test_api.py +++ b/frappe/tests/test_api.py @@ -3,6 +3,7 @@ from random import choice import requests from semantic_version import Version +from tenacity import retry, stop_after_attempt, retry_if_exception_type, wait_fixed import frappe from frappe.utils import get_site_url @@ -124,6 +125,7 @@ class TestResourceAPI(unittest.TestCase): self.assertIsInstance(docname, str) self.GENERATED_DOCUMENTS.append(docname) + @retry(stop=stop_after_attempt(2) | retry_if_exception_type(AssertionError), wait=wait_fixed(3)) def test_update_document(self): # test 8: PUT method on /api/resource to update doc generated_desc = frappe.mock("paragraph") diff --git a/requirements.txt b/requirements.txt index 0791f01b27..04c36b4231 100644 --- a/requirements.txt +++ b/requirements.txt @@ -68,6 +68,7 @@ simple-chalk~=0.1.0 six~=1.15.0 sqlparse~=0.4.1 stripe~=2.56.0 +tenacity~=7.0.0 terminaltables~=3.1.0 unittest-xml-reporting~=3.0.4 urllib3~=1.26.4