mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-16 16:47:24 +00:00
fix(driver): drop retries from AUT launch method
The retries are just adding complexity and not helping. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
861af374cd
commit
9ae8173a0b
@ -1,7 +1,5 @@
|
|||||||
import logging
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
|
import logging
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import squish
|
import squish
|
||||||
@ -9,6 +7,8 @@ from PIL import ImageGrab
|
|||||||
|
|
||||||
import configs
|
import configs
|
||||||
import driver
|
import driver
|
||||||
|
from os import path
|
||||||
|
from datetime import datetime
|
||||||
from configs.system import IS_LIN
|
from configs.system import IS_LIN
|
||||||
from driver import context
|
from driver import context
|
||||||
from driver.server import SquishServer
|
from driver.server import SquishServer
|
||||||
@ -92,30 +92,26 @@ class AUT:
|
|||||||
self._kill_process()
|
self._kill_process()
|
||||||
|
|
||||||
@allure.step("Start application")
|
@allure.step("Start application")
|
||||||
def launch(self, options='', attempt: int = 2) -> 'AUT':
|
def launch(self) -> 'AUT':
|
||||||
self.options = options
|
LOG.info('Launching AUT: %s', self.path)
|
||||||
|
self.port = local_system.find_free_port(configs.squish.AUT_PORT, 100)
|
||||||
|
SquishServer().add_attachable_aut(self.aut_id, self.port)
|
||||||
|
command = [
|
||||||
|
str(configs.testpath.SQUISH_DIR / 'bin/startaut'),
|
||||||
|
f'--port={self.port}',
|
||||||
|
str(self.path),
|
||||||
|
f'-d={self.app_data}',
|
||||||
|
f'--LOG_LEVEL={configs.testpath.LOG_LEVEL}',
|
||||||
|
]
|
||||||
try:
|
try:
|
||||||
self.port = local_system.find_free_port(configs.squish.AUT_PORT, 1000)
|
|
||||||
SquishServer().add_attachable_aut(self.aut_id, self.port)
|
|
||||||
command = [
|
|
||||||
configs.testpath.SQUISH_DIR / 'bin' / 'startaut',
|
|
||||||
f'--port={self.port}',
|
|
||||||
f'"{self.path}"',
|
|
||||||
f'-d={self.app_data}',
|
|
||||||
f'--LOG_LEVEL={configs.testpath.LOG_LEVEL}',
|
|
||||||
options
|
|
||||||
]
|
|
||||||
self.pid = local_system.execute_with_log_files(command)
|
self.pid = local_system.execute_with_log_files(command)
|
||||||
self.attach()
|
self.attach()
|
||||||
assert squish.waitFor(lambda: self.ctx.isRunning, configs.timeouts.PROCESS_TIMEOUT_SEC)
|
assert squish.waitFor(lambda: self.ctx.isRunning, configs.timeouts.PROCESS_TIMEOUT_SEC)
|
||||||
return self
|
return self
|
||||||
except (AssertionError, TypeError) as err:
|
except Exception as err:
|
||||||
_logger.debug(err)
|
LOG.error('Failed to start AUT: %s', err)
|
||||||
self.stop()
|
self.stop()
|
||||||
if attempt:
|
raise err
|
||||||
return self.launch(options, attempt - 1)
|
|
||||||
else:
|
|
||||||
raise err
|
|
||||||
|
|
||||||
@allure.step('Restart application')
|
@allure.step('Restart application')
|
||||||
def restart(self):
|
def restart(self):
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
import allure
|
import allure
|
||||||
import pytest
|
import pytest
|
||||||
|
import logging
|
||||||
|
|
||||||
from driver.server import SquishServer
|
from driver.server import SquishServer
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def start_squish_server():
|
def start_squish_server():
|
||||||
squish_server = SquishServer()
|
server = SquishServer()
|
||||||
squish_server.stop()
|
server.stop()
|
||||||
attempt = 3
|
try:
|
||||||
while True:
|
server.start()
|
||||||
try:
|
server.wait()
|
||||||
squish_server.start()
|
yield server
|
||||||
squish_server.set_cursor_animation()
|
except Exception as err:
|
||||||
squish_server.set_aut_timeout()
|
LOG.error('Failed to start Squish Server: %s', error)
|
||||||
break
|
pytest.exit(err)
|
||||||
except AssertionError as err:
|
finally:
|
||||||
attempt -= 1
|
LOG.info('Stopping Squish Server...')
|
||||||
if not attempt:
|
server.stop()
|
||||||
pytest.exit(err)
|
if server.config.exists():
|
||||||
yield squish_server
|
allure.attach.file(str(server.config), 'Squish server config')
|
||||||
squish_server.stop()
|
server.config.unlink()
|
||||||
if squish_server.config.exists():
|
|
||||||
allure.attach.file(str(squish_server.config), 'Squish server config')
|
|
||||||
squish_server.config.unlink()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user