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,25 +1,33 @@
import asyncio import asyncio
import logging import functools
from datetime import datetime
import os
import json 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.appium_container import AppiumContainer
from support.test_data import TestSuiteData from support.test_data import TestSuiteData
import functools
import time
async def start_threads(quantity: int, func: type, returns: dict, *args): async def start_threads(quantity: int, func: type, returns: dict, *args):
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
# from tests.conftest import sauce # from tests.conftest import sauce
# for _ in range(60): # for _ in range(60):
# if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity: # if 16 - len([job for job in sauce.jobs.get_user_jobs() if job['status'] == 'in progress']) < quantity:
# time.sleep(10) # time.sleep(10)
for i in range(quantity): for i in range(quantity):
returns[i] = loop.run_in_executor(None, func, *args) returns[i] = loop.run_in_executor(None, func, *args)
for k in returns: 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 return returns
@ -44,6 +52,7 @@ def get_current_time():
def debug(text: str): def debug(text: str):
logging.debug(text) logging.debug(text)
appium_root_project_path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]), '../') appium_root_project_path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]), '../')
pytest_config_global = dict() pytest_config_global = dict()
@ -54,7 +63,7 @@ common_password = 'qwerty1234'
unique_password = 'unique' + get_current_time() unique_password = 'unique' + get_current_time()
pin = '121212' pin = '121212'
puk = '000000000000' puk = '000000000000'
pair_code= '000000' pair_code = '000000'
background_service_message = 'Background service for notifications' background_service_message = 'Background service for notifications'
bootnode_address = "enode://a8a97f126f5e3a340cb4db28a1187c325290ec08b2c9a6b1f19845ac86c46f9fac2ba13328822590" \ 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} 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: with open(os.sep.join(__file__.split(os.sep)[:-1]) + '/../../../translations/en.json') as json_file:
transl = json.load(json_file) transl = json.load(json_file)

View File

@ -307,9 +307,11 @@ def create_shared_drivers(quantity):
for i in range(quantity): for i in range(quantity):
test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1 test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1
drivers[i].implicitly_wait(implicit_wait) 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 return drivers, loop
except MaxRetryError as e: 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 raise e