fix(driver): killing process using pid not port number
* Drop unnecessary killing of processes by port, we have the PID. * Split `stop()` method into `_detach_context()` and `_kill_process()`. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
917a4bfde1
commit
fc665cf5ec
|
@ -73,28 +73,23 @@ class AUT:
|
||||||
self.ctx = context.attach(self.aut_id, timeout_sec)
|
self.ctx = context.attach(self.aut_id, timeout_sec)
|
||||||
squish.setApplicationContext(self.ctx)
|
squish.setApplicationContext(self.ctx)
|
||||||
|
|
||||||
@allure.step('Close application')
|
def _detach_context(self):
|
||||||
def stop(self):
|
if self.ctx is None:
|
||||||
if self.ctx is not None:
|
return
|
||||||
squish.currentApplicationContext().detach()
|
squish.currentApplicationContext().detach()
|
||||||
self.ctx = None
|
self.ctx = None
|
||||||
|
|
||||||
if self.port is not None:
|
def _kill_process(self):
|
||||||
pid_list = local_system.find_process_by_port(self.port)
|
if self.pid is None:
|
||||||
if pid_list:
|
raise Exception('No process to kill, no PID available.')
|
||||||
for pid in pid_list:
|
|
||||||
local_system.kill_process(pid, verify=True)
|
|
||||||
assert driver.waitFor(
|
|
||||||
lambda: not local_system.find_process_by_port(self.port), configs.timeouts.PROCESS_TIMEOUT_SEC), \
|
|
||||||
f'Port {self.port} still in use by process: {local_system.find_process_by_port(self.port)}'
|
|
||||||
self.port = None
|
|
||||||
if self.pid in pid_list:
|
|
||||||
self.pid = None
|
|
||||||
|
|
||||||
if self.pid is not None:
|
|
||||||
local_system.kill_process(self.pid, verify=True)
|
local_system.kill_process(self.pid, verify=True)
|
||||||
self.pid = None
|
self.pid = None
|
||||||
|
|
||||||
|
@allure.step('Close application')
|
||||||
|
def stop(self):
|
||||||
|
self._detach_context()
|
||||||
|
self._kill_process()
|
||||||
|
|
||||||
@allure.step("Start application")
|
@allure.step("Start application")
|
||||||
def launch(self, options='', attempt: int = 2) -> 'AUT':
|
def launch(self, options='', attempt: int = 2) -> 'AUT':
|
||||||
self.options = options
|
self.options = options
|
||||||
|
|
Loading…
Reference in New Issue