From fc52d5f062bc258bc0e3fbf4c296ab3bcdc2c4b2 Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Fri, 23 Jun 2023 18:08:28 +0300 Subject: [PATCH] e2e: added attempts for MaxRetryError handling --- test/appium/tests/__init__.py | 34 ++++++++++++++++++----------- test/appium/tests/base_test_case.py | 4 +++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/test/appium/tests/__init__.py b/test/appium/tests/__init__.py index 54179b7772..bf87fa2e7a 100644 --- a/test/appium/tests/__init__.py +++ b/test/appium/tests/__init__.py @@ -1,25 +1,33 @@ import asyncio -import logging -from datetime import datetime -import os +import functools import json +import logging +import os +import time +from datetime import datetime + +from urllib3.exceptions import MaxRetryError + from support.appium_container import AppiumContainer from support.test_data import TestSuiteData -import functools - -import time async def start_threads(quantity: int, func: type, returns: dict, *args): loop = asyncio.get_event_loop() -# from tests.conftest import sauce -# for _ in range(60): -# if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity: -# time.sleep(10) + # from tests.conftest import sauce + # for _ in range(60): + # if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity: + # time.sleep(10) for i in range(quantity): returns[i] = loop.run_in_executor(None, func, *args) for k in returns: - returns[k] = await returns[k] + for _ in range(3): + try: + returns[k] = await returns[k] + break + except MaxRetryError: + print("MaxRetryError when creating a driver") + time.sleep(10) return returns @@ -44,6 +52,7 @@ def get_current_time(): def debug(text: str): logging.debug(text) + appium_root_project_path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]), '../') pytest_config_global = dict() @@ -54,7 +63,7 @@ common_password = 'qwerty1234' unique_password = 'unique' + get_current_time() pin = '121212' puk = '000000000000' -pair_code= '000000' +pair_code = '000000' background_service_message = 'Background service for notifications' bootnode_address = "enode://a8a97f126f5e3a340cb4db28a1187c325290ec08b2c9a6b1f19845ac86c46f9fac2ba13328822590" \ @@ -77,6 +86,5 @@ test_dapp_name = 'simpledapp.status.im' emojis = {'thumbs-up': 2, 'thumbs-down': 3, 'love': 1, 'laugh': 4, 'angry': 6, 'sad': 5} - with open(os.sep.join(__file__.split(os.sep)[:-1]) + '/../../../translations/en.json') as json_file: transl = json.load(json_file) diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index 1fdec301f1..c3d08202fc 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -307,9 +307,11 @@ def create_shared_drivers(quantity): for i in range(quantity): test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1 drivers[i].implicitly_wait(implicit_wait) + if len(drivers) < quantity: + test_suite_data.current_test.testruns[-1].error = "Not all %s drivers are created" % quantity return drivers, loop except MaxRetryError as e: - test_suite_data.current_test.testruns[-1].error = e.reason + test_suite_data.current_test.testruns[-1].error += "%s" % e.reason raise e