From 6252fd08472cf2be649de7c8285e3ec16c1d006e Mon Sep 17 00:00:00 2001 From: Marek Stastny Date: Fri, 22 Nov 2024 13:21:43 +0100 Subject: [PATCH 1/2] fix test_metrics_hierarchies teardown error --- Pipfile | 2 ++ testsuite/tests/ui/conftest.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index e8467a1c..efdbfb57 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ types-braintree = "*" types-stripe = "*" types-Pillow = "*" black = "*" +types-retry = "*" # Have commented out python-language-server to make it available quickly # for the development #python-language-server = "*" @@ -58,6 +59,7 @@ pytest-persistence = "*" pytest-metadata = ">=3.0.0" pytest-html = "*" ansi2html = "*" +retry = "==0.9.2" [requires] python_version = "3" diff --git a/testsuite/tests/ui/conftest.py b/testsuite/tests/ui/conftest.py index 92a46329..206f01a9 100644 --- a/testsuite/tests/ui/conftest.py +++ b/testsuite/tests/ui/conftest.py @@ -11,7 +11,9 @@ import pytest import pytest_html from auth0.management import auth0 +from retry.api import retry from selenium.common import InvalidSessionIdException, WebDriverException +from threescale_api.errors import ApiClientError from threescale_api.resources import Account, ApplicationPlan, Service from PIL import Image @@ -252,7 +254,7 @@ def _custom_ui_backend(name: str, system_name: str, description: str = "", endpo backend.create(name, system_name, description, endpoint) backend = resilient.resource_read_by_name(threescale.backends, system_name) if autoclean and not testconfig["skip_cleanup"]: - request.addfinalizer(backend.delete) + request.addfinalizer(retry(exceptions=ApiClientError, tries=3, delay=1, backoff=2)(backend.delete)) return backend return _custom_ui_backend @@ -265,8 +267,9 @@ def ui_backend(custom_ui_backend, request): return custom_ui_backend(name, name) +# custom_ui_backend dependency forces delete product first (backend cannot be deleted when is used by some product) @pytest.fixture(scope="module") -def custom_ui_product(custom_admin_login, navigator, threescale, testconfig, request): +def custom_ui_product(custom_admin_login, navigator, threescale, testconfig, request, custom_ui_backend): """Parametrized custom Product created via UI""" def _custom_ui_product(name: str, system_name: str, description: str = "", autoclean=True): From 4d163e22791e8b28c80444d2776318a312e88b13 Mon Sep 17 00:00:00 2001 From: Marek Stastny Date: Thu, 28 Nov 2024 11:09:04 +0100 Subject: [PATCH 2/2] remove retry dependency --- Pipfile | 2 -- testsuite/tests/ui/conftest.py | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Pipfile b/Pipfile index efdbfb57..e8467a1c 100644 --- a/Pipfile +++ b/Pipfile @@ -9,7 +9,6 @@ types-braintree = "*" types-stripe = "*" types-Pillow = "*" black = "*" -types-retry = "*" # Have commented out python-language-server to make it available quickly # for the development #python-language-server = "*" @@ -59,7 +58,6 @@ pytest-persistence = "*" pytest-metadata = ">=3.0.0" pytest-html = "*" ansi2html = "*" -retry = "==0.9.2" [requires] python_version = "3" diff --git a/testsuite/tests/ui/conftest.py b/testsuite/tests/ui/conftest.py index 206f01a9..8dddc12a 100644 --- a/testsuite/tests/ui/conftest.py +++ b/testsuite/tests/ui/conftest.py @@ -11,7 +11,6 @@ import pytest import pytest_html from auth0.management import auth0 -from retry.api import retry from selenium.common import InvalidSessionIdException, WebDriverException from threescale_api.errors import ApiClientError from threescale_api.resources import Account, ApplicationPlan, Service @@ -254,7 +253,11 @@ def _custom_ui_backend(name: str, system_name: str, description: str = "", endpo backend.create(name, system_name, description, endpoint) backend = resilient.resource_read_by_name(threescale.backends, system_name) if autoclean and not testconfig["skip_cleanup"]: - request.addfinalizer(retry(exceptions=ApiClientError, tries=3, delay=1, backoff=2)(backend.delete)) + + @backoff.on_exception(backoff.fibo, ApiClientError, max_tries=3, jitter=None) + def finalizer(): + backend.delete() + return backend return _custom_ui_backend