Skip to content

Commit

Permalink
Enlarge abort_wait_timeout to fix leftover driver when abort testplan…
Browse files Browse the repository at this point in the history
… from interactive UI.
  • Loading branch information
Pyifan committed Sep 26, 2023
1 parent 147bee5 commit 1c482ad
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/Transports/FIX/over_one_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def get_multitest():
target="ISLD",
msgclass=FixMessage,
codec=CODEC,
logoff_at_stop=False,
),
],
)
Expand Down
20 changes: 18 additions & 2 deletions testplan/common/entity/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def get_options(cls):
ConfigOption("initial_context", default={}): dict,
ConfigOption("path_cleanup", default=False): bool,
ConfigOption("status_wait_timeout", default=600): int,
ConfigOption("abort_wait_timeout", default=30): int,
ConfigOption("abort_wait_timeout", default=300): int,
ConfigOption("active_loop_sleep", default=0.005): float,
}

Expand Down Expand Up @@ -632,7 +632,15 @@ def _abort_entity(self, entity, wait_timeout=None):
self.logger.error(traceback.format_exc())
self.logger.error("Exception on aborting %s - %s", entity, exc)
else:
if wait(lambda: entity.aborted is True, timeout) is False:

if (
wait(
predicate=lambda: entity.aborted is True,
timeout=timeout,
raise_on_timeout=False, # continue even if some entity timeout
)
is False
):
self.logger.error("Timeout on waiting to abort %s.", entity)

def aborting(self):
Expand Down Expand Up @@ -1133,9 +1141,16 @@ def run(self):
while self._ihandler.active:
time.sleep(self.cfg.active_loop_sleep)
else:
# TODO: need some rework
# if we abort from ui, the ihandler.abort executes in http thread
# if we abort by ^C, ihandler.abort is called in main thread
# anyway this join will not be blocked
interruptible_join(
thread, timeout=self.cfg.abort_wait_timeout
)
# if we abort from ui, we abort ihandler first, then testrunner
# this abort will wait ihandler to be aborted
# if we abort by ^C, testrunner.abort is already called, this will be noop
self.abort()
return self._ihandler
else:
Expand Down Expand Up @@ -1693,6 +1708,7 @@ def _handle_abort(self, signum, frame):
signum,
threading.current_thread(),
)

self.abort()

def pausing(self):
Expand Down
6 changes: 4 additions & 2 deletions testplan/runnable/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,12 @@ def _wait_ongoing(self):
"Timeout: Aborting execution after %d seconds",
self.cfg.timeout,
)
# Abort dependencies, wait sometime till test reports are ready
# Abort resources e.g pools
for dep in self.abort_dependencies():
self._abort_entity(dep)
time.sleep(self.cfg.abort_wait_timeout)
# TODO: we shall not need this:
# # wait sometime till test reports are ready
# time.sleep(self.cfg.abort_wait_timeout)
break

pending_work = False
Expand Down
8 changes: 1 addition & 7 deletions testplan/runners/pools/tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ def uid(self) -> str:
@property
def name(self) -> str:
"""Task name."""
if not isinstance(self._target, str):
try:
name = self._target.__class__.__name__
except AttributeError:
name = self._target
else:
name = self._target
name = self._uid or self._target
return "Task[{}]".format(name)

@property
Expand Down

0 comments on commit 1c482ad

Please sign in to comment.