Skip to content

Commit

Permalink
e2e: nightly fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yevh-berdnyk committed Jul 4, 2023
1 parent c2c79cc commit 8978e92
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions test/appium/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from support.test_data import TestSuiteData


async def start_threads(quantity: int, func: type, returns: dict, *args):
async def start_threads(test_name: str, quantity: int, func: type, returns: dict, *args):
loop = asyncio.get_event_loop()
# from tests.conftest import sauce
# for _ in range(60):
Expand All @@ -26,7 +26,7 @@ async def start_threads(quantity: int, func: type, returns: dict, *args):
returns[k] = await returns[k]
break
except MaxRetryError:
print("MaxRetryError when creating a driver")
print("MaxRetryError when creating a driver for %s" % test_name)
time.sleep(10)
return returns

Expand Down
58 changes: 31 additions & 27 deletions test/appium/tests/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def create_shared_drivers(quantity):
capabilities = {'maxDuration': 3600}
print('SC Executor: %s' % executor_sauce_lab)
try:
drivers = loop.run_until_complete(start_threads(quantity,
drivers = loop.run_until_complete(start_threads(test_suite_data.current_test.name,
quantity,
Driver,
drivers,
executor_sauce_lab,
Expand All @@ -310,7 +311,7 @@ def create_shared_drivers(quantity):
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:
except (MaxRetryError, AttributeError) as e:
test_suite_data.current_test.testruns[-1].error += "%s" % e.reason
raise e

Expand Down Expand Up @@ -394,31 +395,34 @@ def teardown_class(cls):
from tests.conftest import sauce
requests_session = requests.Session()
requests_session.auth = (sauce_username, sauce_access_key)
if cls.drivers:
for _, driver in cls.drivers.items():
session_id = driver.session_id
try:
sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__)
except (RemoteDisconnected, SauceException):
pass
try:
driver.quit()
except WebDriverException:
pass
url = 'https://api.%s/rest/v1/%s/jobs/%s/assets/%s' % (apibase, sauce_username, session_id, "log.json")
try:
WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200)
commands = requests_session.get(url).json()
for command in commands:
try:
if command['message'].startswith("Started "):
for test in test_suite_data.tests:
if command['message'] == "Started %s" % test.name:
test.testruns[-1].first_commands[session_id] = commands.index(command) + 1
except KeyError:
continue
except (RemoteDisconnected, requests.exceptions.ConnectionError):
pass
try:
cls.drivers
except AttributeError:
pass
for _, driver in cls.drivers.items():
session_id = driver.session_id
try:
sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__)
except (RemoteDisconnected, SauceException):
pass
try:
driver.quit()
except WebDriverException:
pass
url = 'https://api.%s/rest/v1/%s/jobs/%s/assets/%s' % (apibase, sauce_username, session_id, "log.json")
try:
WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200)
commands = requests_session.get(url).json()
for command in commands:
try:
if command['message'].startswith("Started "):
for test in test_suite_data.tests:
if command['message'] == "Started %s" % test.name:
test.testruns[-1].first_commands[session_id] = commands.index(command) + 1
except KeyError:
continue
except (RemoteDisconnected, requests.exceptions.ConnectionError):
pass
if cls.loop:
cls.loop.close()
for test in test_suite_data.tests:
Expand Down
5 changes: 2 additions & 3 deletions test/appium/tests/critical/chats/test_1_1_public_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,7 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):

self.home_2.just_fyi('Device2 checks "Sending" status when sending message from offline')
self.chat_2.send_message(message_1)
chat_element = self.chat_2.chat_element_by_text(message_1)
status = chat_element.status
status = self.chat_2.chat_element_by_text(message_1).status
if not (status == 'Sending' or status == 'Sent'):
self.errors.append('Message status is not "Sending", it is "%s"!' % status)

Expand All @@ -1304,7 +1303,7 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):

self.home_2.just_fyi('Device1 goes back online and checks that 1-1 chat will be fetched')
try:
chat_element.wait_for_status_to_be(expected_status='Delivered', timeout=120)
self.chat_2.chat_element_by_text(message_1).wait_for_status_to_be(expected_status='Delivered', timeout=120)
except TimeoutException as e:
self.errors.append('%s after back up online!' % e.msg)
self.errors.verify_no_errors()
Expand Down
1 change: 1 addition & 0 deletions test/appium/tests/critical/test_public_chat_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ def test_restore_multiaccount_with_waku_backup_remove_switch(self):

if not pytest_config_global['pr_number']:
self.home.just_fyi("Perform back up")
self.home.click_system_back_button_until_element_is_shown()
self.home.profile_button.click()
profile.sync_settings_button.click()
profile.backup_settings_button.click()
Expand Down

0 comments on commit 8978e92

Please sign in to comment.