mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Release v1.17.2; updated trace support
This commit is contained in:
parent
2db79046d0
commit
e37c6458c3
@ -4,6 +4,13 @@ Changelog
|
||||
|
||||
.. currentmodule:: firebird.qa.plugin
|
||||
|
||||
Version 0.17.2
|
||||
==============
|
||||
|
||||
* Trace session support in plugin now uses service query with timeout (provided by
|
||||
firebird-driver 1.8.0) and terminates the trace thread gracefuly even if terminating
|
||||
trace session fails.
|
||||
|
||||
Version 0.17.1
|
||||
==============
|
||||
|
||||
|
@ -19,14 +19,14 @@ import sphinx_bootstrap_theme
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'Firebird QA'
|
||||
copyright = '2022, Pavel Cisar'
|
||||
copyright = '2021, Pavel Cisar'
|
||||
author = 'Pavel Císař'
|
||||
|
||||
# The short X.Y version
|
||||
version = '0.17.1'
|
||||
version = '0.17.2'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.17.1'
|
||||
release = '0.17.2'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
@ -54,11 +54,11 @@ from configparser import ConfigParser, ExtendedInterpolation
|
||||
from packaging.specifiers import SpecifierSet
|
||||
from packaging.version import parse
|
||||
import time
|
||||
from threading import Thread, Barrier
|
||||
from threading import Thread, Barrier, Event
|
||||
from firebird.driver import connect, connect_server, create_database, driver_config, \
|
||||
NetProtocol, Server, CHARSET_MAP, Connection, Cursor, \
|
||||
DESCRIPTION_NAME, DESCRIPTION_DISPLAY_SIZE, DatabaseConfig, DBKeyScope, DbInfoCode, \
|
||||
DbWriteMode, get_api, Error
|
||||
DbWriteMode, get_api, Error, TIMEOUT
|
||||
from firebird.driver.core import _connect_helper
|
||||
|
||||
Substitutions = List[Tuple[str, str]]
|
||||
@ -1077,7 +1077,7 @@ def user_factory(db_fixture_name: str, *, name: str, password: str='', plugin: O
|
||||
|
||||
def trace_thread(act: Action, b: Barrier, cfg: List[str], output: List[str], keep_log: bool,
|
||||
encoding: str, encoding_errors: str, user: str, password: str,
|
||||
role: str):
|
||||
role: str, stop: Event):
|
||||
"""Function used by `TraceSession` for execution in separate thread to run trace session.
|
||||
|
||||
Arguments:
|
||||
@ -1088,13 +1088,21 @@ def trace_thread(act: Action, b: Barrier, cfg: List[str], output: List[str], kee
|
||||
keep_log: When `True`, the trace session output is discarded.
|
||||
encoding: Encoding for trace session output.
|
||||
encoding_errors: Error handler for trace session output encoding.
|
||||
user: user name
|
||||
password: User password
|
||||
role: User role
|
||||
stop: Event used to stop the trace thread
|
||||
"""
|
||||
with act.connect_server(encoding=encoding, encoding_errors=encoding_errors,
|
||||
user=user, password=password) as srv:
|
||||
output.append(srv.trace.start(config='\n'.join(cfg)))
|
||||
b.wait()
|
||||
for line in srv:
|
||||
if keep_log:
|
||||
while not stop.is_set():
|
||||
line = srv.readline_timed(1)
|
||||
if line is not TIMEOUT:
|
||||
if not line:
|
||||
stop.set()
|
||||
elif keep_log:
|
||||
output.append(line)
|
||||
|
||||
class TraceSession:
|
||||
@ -1145,6 +1153,7 @@ class TraceSession:
|
||||
self.encoding: Optional[str] = encoding
|
||||
#: Encoding errors handling for trace session output.
|
||||
self.encoding_errors: Optional[str] = encoding_errors
|
||||
self.stop_event: Event = Event()
|
||||
def __enter__(self) -> TraceSession:
|
||||
b = Barrier(2)
|
||||
self.trace_thread = Thread(target=trace_thread, args=[self.act, b, self.config,
|
||||
@ -1152,7 +1161,7 @@ class TraceSession:
|
||||
self.encoding,
|
||||
self.encoding_errors,
|
||||
self.user, self.password,
|
||||
self.role])
|
||||
self.role, self.stop_event])
|
||||
self.trace_thread.start()
|
||||
b.wait()
|
||||
return self
|
||||
@ -1161,6 +1170,7 @@ class TraceSession:
|
||||
session = self.output.pop(0)
|
||||
with self.act.connect_server() as srv:
|
||||
srv.trace.stop(session_id=session)
|
||||
self.stop_event.set()
|
||||
self.trace_thread.join(5.0)
|
||||
if self.trace_thread.is_alive():
|
||||
pytest.fail('Trace thread still alive')
|
||||
|
@ -5,7 +5,7 @@ all-files=True
|
||||
|
||||
[metadata]
|
||||
name = firebird-qa
|
||||
version = 0.17.1
|
||||
version = 0.17.2
|
||||
description = pytest plugin for Firebird QA
|
||||
long_description = file: README.rst
|
||||
long_description_content_type = text/x-rst; charset=UTF-8
|
||||
@ -37,8 +37,8 @@ classifiers =
|
||||
zip_safe = True
|
||||
python_requires = >=3.8, <4
|
||||
install_requires =
|
||||
firebird-base>=1.3.0
|
||||
firebird-driver>=1.5.1
|
||||
firebird-base>=1.5.0
|
||||
firebird-driver>=1.8.0
|
||||
pytest>=7.0.0
|
||||
psutil>=5.9.1
|
||||
packages = find_namespace:
|
||||
|
Loading…
Reference in New Issue
Block a user