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