e2e: added attempts for MaxRetryError handling

This commit is contained in:
Yevheniia Berdnyk 2023-06-23 18:08:28 +03:00
parent e5e68e0e83
commit fc52d5f062
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
2 changed files with 24 additions and 14 deletions

View File

@ -1,13 +1,15 @@
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):
@ -19,7 +21,13 @@ async def start_threads(quantity: int, func: type, returns: dict, *args):
for i in range(quantity):
returns[i] = loop.run_in_executor(None, func, *args)
for k in returns:
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()
@ -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)

View File

@ -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